2D sidescroller

Hi,

I’m an experienced Java developer but new at writing games. I’m trying to implement a 2D sidescrolling airplane-type game. I’ve been reading tutorials from all over, but would like to ask some more specific questions.

The main character sprite will be a plane that flies left/right and is able to loop. The base image for the plane would be a nice horizontal picture of the plane. The plane should be able to fly at any angle. In order to render the plane at an arbitrary angle, I was going to rotate on demand - during the update process. Is it common to rotate on demand, or should I pre-generate frames for the plane in every possible position and store them in an array somewhere? Perhaps I should point out that the image will be in the region of 50x30 pixels when horizontal.

While I have plenty more questions, that’s probably most pressing for now.

Thanks

It depends. ;D

If you’re using Java2D you might find it too slow to rotate a single sprite each time you display it, in which case pre-rotated would obviously be the way to go. If you’re using OpenGL / LWJGL then it’ll be plenty fast enough to do it on the fly. But if you’re running at a low resolution or with tiny sprites then for best quality you might still prefer to have lots of sprites drawn at specific angles. This tends to depend on your style of art though (and whether you can find an artist willing to do all the extra work!).

If you expose a method like draw(Graphics g, int x, int y, double angle) then you can start by rotating on the fly, see if it works, then if there’s trouble with the performance you can just provide another implementation which uses prerotated sprites. Rotating on the run is probably good enough, though, if there are not too many.