Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module Issue
#4
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.
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Module Issue - by Vinwarez - 07-20-2012, 04:37 PM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-20-2012, 04:44 PM
Re: Module Issue - by Vinwarez - 07-20-2012, 04:48 PM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-20-2012, 06:37 PM
Re: Module Issue - by Vinwarez - 07-21-2012, 01:33 AM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-21-2012, 12:25 PM
Re: Module Issue - by Vinwarez - 07-21-2012, 01:37 PM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-22-2012, 04:19 AM
Re: Module Issue - by Vinwarez - 07-22-2012, 06:29 AM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-22-2012, 05:32 PM
Re: Module Issue - by Vinwarez - 07-22-2012, 05:52 PM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-22-2012, 09:23 PM
Re: Module Issue - by Vinwarez - 07-23-2012, 02:08 AM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-23-2012, 01:20 PM
Re: Module Issue - by Vinwarez - 07-24-2012, 08:18 AM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-24-2012, 10:43 PM
Re: Module Issue - by Vinwarez - 07-24-2012, 11:25 PM
Re: Module Issue - by brandonio21_phpbb3_import2 - 07-24-2012, 11:38 PM
Re: Module Issue - by Vinwarez - 07-24-2012, 11:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dual Menu Strip Issue Moldraxian 3 15,914 08-15-2012, 12:36 PM
Last Post: brandonio21
  MySQL Database Issue Moldraxian 7 27,593 08-13-2012, 08:58 PM
Last Post: brandonio21
  Remove Enemy [Game Issue] Vinwarez 3 13,552 07-14-2012, 02:15 PM
Last Post: brandonio21
  Launching Projectile [Game Issue] Vinwarez 11 31,108 07-13-2012, 03:29 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)