Hi i was just wondering how i could achieve a moving line across the screen such that i can implement it on space key pressed, i have the following idea.
1 - create a circle or line to represent the bullet.
2 - rotate, translate and scale it to required properties.
3 = Attach it to variable stored in ships movement in case statement keyEvent so when the space bar is pressed the object will appear next to (infront of the ship.
4 - pushmatrix save current state, and increment line or circles x coordinte by small amount popmatrix.
5 keep incrementing so the line or circle that represents my bullet carry’s on over to the far side of the screen.
ok, is this the right way to do this, and how do i create the effect so the movement of the bullet keeps incrementing while i can still move my ship object around.
I thank all of you and appreciate any help, steve.
Basicly you should have a class for the bullet, a function that draws/fires the bullet, and a function that moves it. You should have a function that moves your ship. You should use the bullet class to keep up with the postion of the bullet, and a variable to keep track if the bullet exist or not
under your render function you should have something like
firebullet() // bullet exist
drawbullet() // if bullet exist draw it
this is just a simple way I could think of to do it, there are a million ways to do it better than this, you just need to have seperate draw functions for each, that way you can draw the ship and the bullet fired from it in the render function at the same time, you just set the location of each independently, so when your scene is updated they will both be in thier expected location.
sorry if i confused you even more…
this is more of an algorithm/programming question than a rendering question, you should try a search on it for a better solution