Friday night I got some time to get started. I was able to get a background and a spaceship sprite (which I borrowed from the Internet) on the screen. This is only placeholder artwork to let me concentrate on the game mechanics.Hooked up the accelerometer and, after getting the axes (apparently the plural of axis) correct I was able to move the ship by tilting the iPod. Screenshot above. The background is only small (1000 x 600 pixels) and doesn't wrap, so flying area is limited.
I've implemented variable speed by multiplying the accelerometer output by a constant (slightly different value for Y than X, so you speed up faster when travelling horizontally), and capping it at 4 pixels/frame. I've also had to implement a 'dead' area around 0ยบ (flat) to stop the ship flicking left and right from the slight movement you get when holding the iPod in your hand.
Must say, it scrolls very smoothly. I've got the framerate fixed at 60/second
The code at the moment is a bit rough, and the background moves relative to the ship - fine for a demo, but a rubbish way of managing multiple objects. This method will be gone shortly and all objects will have a position relative to some fixed point.
Next task is to create a means of tiling backgrounds and enabling it to wrap horizontally.
Cool buddy looking good.
ReplyDeleteHows it going today. Anymore news ?
ReplyDeleteHaven't done much more yet. Been busy, but I've worked out my method for tiling etc, just need to code it.
ReplyDeleteShould be able to get some more done tonight.