Reputation: 9
I'm making a side-scrolling Mega Man based game in C#. I am NOT using the XNA frame work to do so. I'm looking at creating multiple "bullets" from one location using one single image within my game class. The only thing I can think of at this point is something similar to this:
if (shooting == true)
{
BulletLocation.X += 3.0F;
Bullet = Properties.Resources.Bullet;
Charecter = Properties.Resources.shooting;
}
Shooting is set true on the keyDown event, and set to false on the keyUp event. I'm positive i would need an array of the sorts, but I'm not sure exactly how I should go about it. Thanks for your help!
EDIT: What portion of that code would actually allow you to generate multiple "bullets" from one sprite single sprite? When the user presses the space bar, I would like to create a bullet that moves forward until it reaches the end of the screen. I can do that part easily. I cannot, however, do it with multiple bullets. I can only have one bullet alive at a time. I'm not sure how I would go about creating multiple bullets on the forum from one single image.
Upvotes: 0
Views: 229
Reputation: 906
If I understand it correctly, you want to show multiple bullets, right? I would make a variable for # of bullets and bulletposition.
So lets say:
const DISTBETWEENBULLETS = 3.0;
int distToOpponent = 9.0:
int curBulletDist = 0;
do{
curBulletDist += DISTBETWEENBULLETS;
//Draw bullet
}while(distToOpponent <= curBulletDist);
I hope this helps, and if it doesn't answer your question, or you mean something else, feel free to ask.
Upvotes: -1