mulitple copies of an image
I''ve been having some trouble figuring out a way to program firing a weapon. Once you have the image of the projectile loaded up how would you go about copying it again and again for each shot (and then drawing them and deleting them)? Im using the CDX library and I''ve seen this done with the function SpriteList but I haven''t been able to get it to work.
Thanx,
ViPeR
From what I know, you will need seperate projectile structures for each one you fire. Well, there are two ways you could do this though. If you are talking about bullets, then all you need to do it vector to get the ending point of the shot, and check for collisions, and draw the impact graphics on the target, be it wall or another sprite/object. Or, if you are doing rockets, or something else that you need to see on it''s way, then you will (I think) need to create several different objects, that share the same data. For example, you have
class Rocket
{
// ...
int x, y; // screen coords, generated from world coords
};
Rocket playerRockets[PLAYER_NUM_ROCKETS];
Bitmap rocketPic;
Then when you draw it, you go
DrawPic(rocketPic,playerRockets[rocketNum].x,playerRockets[rocketNum].y);
Do you see what I mean?
I don''t know if I''m right though, I''ve never done this before really
------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
class Rocket
{
// ...
int x, y; // screen coords, generated from world coords
};
Rocket playerRockets[PLAYER_NUM_ROCKETS];
Bitmap rocketPic;
Then when you draw it, you go
DrawPic(rocketPic,playerRockets[rocketNum].x,playerRockets[rocketNum].y);
Do you see what I mean?
I don''t know if I''m right though, I''ve never done this before really
------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement