Hey I am creating a simple game. But right now all I have is a simple Ball class that creates a filled circle on the screen.
As you can see my InsideBall class is empty. I am getting the two x and y from the form where its being clicked, but I have no idea how to check if the click is in the circle. Looking for some guidelines on where to start.Code:Imports System.Drawing Public Class Ball Private GR As Graphics Private _radius As Integer Public Property Radius() As Integer Get Return _radius End Get Set(ByVal value As Integer) _radius = value End Set End Property Private _diameter As Integer Public Property Diameter() As Integer Get Return _diameter End Get Set(ByVal value As Integer) _diameter = value End Set End Property Private _color As Color Public Property Color() As Color Get Return _color End Get Set(ByVal value As Color) _color = value End Set End Property Private _x As Double Public Property x() As Double Get Return _x End Get Set(ByVal value As Double) _x = value End Set End Property Private _y As Double Public Property y() As Double Get Return _y End Get Set(ByVal value As Double) _y = value End Set End Property Public Sub New(ByVal g As Graphics) Diameter = 10 Radius = Diameter / 2 Color = Drawing.Color.Black x = 90 y = 134 GR = g End Sub Public Sub New(ByVal g As Graphics, ByVal d As Integer, ByVal c As Color) Diameter = d Radius = Diameter / 2 Color = c GR = g End Sub Public Sub Draw() GR.DrawArc(Pens.Blue, Convert.ToInt16(x), Convert.ToInt16(y), Diameter, Diameter, 0, 360) End Sub Public Sub DrawFill() GR.FillEllipse(Brushes.BurlyWood, Convert.ToInt16(x), Convert.ToInt16(y), Diameter, Diameter) End Sub Public Sub Del() GR.FillEllipse(Brushes.White, Convert.ToInt16(x), Convert.ToInt16(y), Diameter, Diameter) End Sub Public Function InsideBall(ByVal x As Integer, ByVal y As Integer) As Boolean End Function End Class
Also I tried drawing it on paper, but I am way to tired I guess.




Reply With Quote