07-20-2012, 06:37 PM
You're definitely starting at the right point! So, here is a nice example of a somewhat completed Bullet class. If you have any questions, feel free to ask!
[code2=vbnet]Public Class Bullet
'Location
Private _x As Integer
Private _y As Integer
'Size
Private _width As Integer
Private _height As Integer
'Image
Private _image As Image
'Damage
Private _damage As Integer
Public ReadOnly Property X As Integer
Get
Return _x
End Get
End Property
Public ReadOnly Property Y As Integer
Get
Return _y
End Get
End Property
Public ReadOnly Property Width As Integer
Get
Return _width
End Get
End Property
Public ReadOnly Property Height As Integer
Get
Return _height
End Get
End Property
Public ReadOnly Property Image As Image
Get
Return _image
End Get
End Property
Public ReadOnly Property Damage As Integer
Get
Return _damage
End Get
End Property
Public Sub New(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal image As Image, ByVal damage As Integer)
'This is the constructor, all information needs to be set
_x = x
_y = y
_width = width
_height = height
_image = image
_damage = damage
End Sub
Public Sub SetLocation(ByVal x As Integer, ByVal y As Integer)
'This method sets the location
_x = x
_y = y
End Sub
Public Sub SetSize(ByVal width As Integer, ByVal height As Integer)
'This method sets the size
_width = width
_height = height
End Sub
Public Sub SetDamage(ByVal dmg As Integer)
'This method sets the damage
_damage = dmg
End Sub
Public Sub SetImage(ByVal image As Image)
'This method sets the image
_image = image
End Sub
Public Sub Move(ByVal direction As Integer)
If (direction = 1) Then
'The bullet moves up
Me._y -= 1
Else
'The bullet moves down
Me._y += 1
End If
End Sub
End Class[/code2]
Now, this is just for keeping track of information. If you want to actually add it to the form, you're going to want to have the class inherit a picturebox. If you have any questions on doing that, just ask! I may make a tutorial about doing something like this soon.
[code2=vbnet]Public Class Bullet
'Location
Private _x As Integer
Private _y As Integer
'Size
Private _width As Integer
Private _height As Integer
'Image
Private _image As Image
'Damage
Private _damage As Integer
Public ReadOnly Property X As Integer
Get
Return _x
End Get
End Property
Public ReadOnly Property Y As Integer
Get
Return _y
End Get
End Property
Public ReadOnly Property Width As Integer
Get
Return _width
End Get
End Property
Public ReadOnly Property Height As Integer
Get
Return _height
End Get
End Property
Public ReadOnly Property Image As Image
Get
Return _image
End Get
End Property
Public ReadOnly Property Damage As Integer
Get
Return _damage
End Get
End Property
Public Sub New(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal image As Image, ByVal damage As Integer)
'This is the constructor, all information needs to be set
_x = x
_y = y
_width = width
_height = height
_image = image
_damage = damage
End Sub
Public Sub SetLocation(ByVal x As Integer, ByVal y As Integer)
'This method sets the location
_x = x
_y = y
End Sub
Public Sub SetSize(ByVal width As Integer, ByVal height As Integer)
'This method sets the size
_width = width
_height = height
End Sub
Public Sub SetDamage(ByVal dmg As Integer)
'This method sets the damage
_damage = dmg
End Sub
Public Sub SetImage(ByVal image As Image)
'This method sets the image
_image = image
End Sub
Public Sub Move(ByVal direction As Integer)
If (direction = 1) Then
'The bullet moves up
Me._y -= 1
Else
'The bullet moves down
Me._y += 1
End If
End Sub
End Class[/code2]
Now, this is just for keeping track of information. If you want to actually add it to the form, you're going to want to have the class inherit a picturebox. If you have any questions on doing that, just ask! I may make a tutorial about doing something like this soon.