![]() |
|
360 Degree Spaceship slide question - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Game Programming Fundamentals (/forum-7.html) +--- Thread: 360 Degree Spaceship slide question (/thread-3026.html) |
360 Degree Spaceship slide question - YetAnotherSuperhero - Sep 19, 2007 01:21 PM Hey, I'm new here. But this looks like a good board. My questions is: I have a space ship movement using: vx = v * cos(angle) vy = v * sin(angle) How can I make it that when I change the angle the ship will continue to slide in the direction it was. I hope I made that clear. Thanks for any help. YAS 360 Degree Spaceship slide question - Nevada - Sep 19, 2007 02:19 PM You'll have to make some modifications to how you control movement. Rather than setting the velocity when the user presses a key, you will want to accelerate it. The psuedo-code will go something like this: Code: // When player presses keyI'm assuming you have a time based physics system (that way the game physics is the same across all machines) so the delta_t term is the time elapsed since the last frame. If you don't use this yet, just leave 'em out (Though you will have to be careful what values you choose for DRAG and MASS). You could also make the drag effect second order (more dramatic and more accurate at high velocities) by multiplying the length of the velocity vector into the into the DRAG/MASS*delta_T part. 360 Degree Spaceship slide question - ThemsAllTook - Sep 19, 2007 02:19 PM Implement velocity. Example: Code: float velocityX, velocityY;Depending on how you want your game mechanics to work, you may want to damp velocity a bit each frame (though if this takes place in space, probably not). Edit: Nevada beat me to it. 360 Degree Spaceship slide question - YetAnotherSuperhero - Sep 19, 2007 02:33 PM I think I get it, BUT, and excuse my ignorance, but if player.vx is maxed out, how do I keep player.vy from increasing and changing the angle that the player moves? Thanks again 360 Degree Spaceship slide question - Nevada - Sep 19, 2007 02:57 PM I'm sorry, that was my mistake. The code should be Code: boostPlayer(float angle, float delta_t)360 Degree Spaceship slide question - YetAnotherSuperhero - Sep 19, 2007 09:58 PM Yep! That got it! thank you so much!!!!
360 Degree Spaceship slide question - DoG - Sep 21, 2007 02:17 AM Just as an aside, the concept you were looking for is inertia. |