Question 2d scrolling game, bullet class

Sige

New member
Joined
Dec 6, 2014
Messages
2
Programming Experience
Beginner
Hi,
I am making a 2d side scrolling game and the basic idea is that you are flying arround with your character
and at the ground there are enemies shooting bullets to the top of the form. I made a class that makes the bullets from
a picturebox. This is how the class looks like:
Public class Enemy
inherits picturebox

Public sub New()
With Me
.Size = New Size(10,10)
.Location = Form1.PicEnemy.Location
.Backcolor = color.black
End With
End sub
Public Sub Move()
Me.top -=3
Me.left -=3
End Sub
End class

Sorry for the messed up colors.
As you can see I can only add 1 'starting' location (the orange line). My question is, if it is possible to
make all enemies use this class to shoot bullets so with extra locations without making hundreds of classes for every enemy or
is this impossible to do?
I hope someone can help me!
thanks in advance
 
Last edited:
Sorry for the messed up colors.
Please post code snippets as plain text inside
 tags.
[QUOTE="Sige, post: 169469, member: 50838"]My question is, if it is possible to 
make all enemies use this class to shoot bullets so with extra locations without making hundreds of classes for every enemy or 
is this impossible to do?[/QUOTE]
Of course it's possible.  You create loads of forms, TextBoxes, Buttons, etc, with different locations don't you?  This is exactly the same.  If each one is supposed to have a different location then set the Location property of each one differently.  You can either set the Location property from the outside after creating the instance or else pass the value in as a constructor argument.
 

Latest posts

Back
Top