Hello everyone.
Im trying to create a quite simple 2D game using allegro library. The one thing I need to know, what is the best way of making the shooting part. I have a character, it can move around ETC., and I have a bitmap of the character in attack position and of bubble, which will be shooted thing.
How can I create a good shooting function?
I hope You understood me.
Thank you in advance,
Daniels
Are you talking about weapon movement? Or bullet movement?
I'm assuming you have velocity with your bullet objects, in which case you can do something like this:
1 2 3 4 5
double theta = atan2(diff.y,diff.x); //diff is an object holding the distance between your object and your mouse.
double power = .6; //speed of your bullet, change this to increase the velocity of your bullet
double xvel = cos(theta)*power;
double yvel = sin(theta)*power;
//now add a bullet and set it's velocity to xvel,yvel
Well, You showed me the part where Math comes in, thank You for it.
But I need just how to create an object which is bullet and to move it straight forward.
The system is that to move the the bullet without flickering is to clear screen after each frame, but that means I need to redraw the character and map etc. Is there a way to do without redrawing anything? And what is the best way of creating a bullets? I don't need actual code, just an idea.