View Single Post
Posts: 67 | Thanked: 26 times | Joined on Jan 2010
#1
Hi,

Was working on this on and off while kind of learning python on N900 after using the 30 minute guide.

Its basically a snake python (Sna-py!) game that is controlled using the accelerometer.

I'm only uploading as the code might be of some use to people wanting to write an accelerometer based game or use vibrate etc.... I don't really intend to add much more features as I might try my hand at a full qt game next ... If I can get my head round it!

You need to have pygame installed
On the N900 install pygame:
# apt-get install python-pygame

The run this on the device just put the snapy.py in opt folder and the images / sfx folder in opt as well.

Edit: NO NEED to Gain root
..just CD go into opt
(cd ..
cd opt)
then run python snapy.py
you should see it load a few things then the game will start

It takes a bit of getting used to at first - it might seems like you randomly die at first until you get used to the accelerometer - if you move back onto yourself you have hit yourself so you need to kind of move forward avoiding hitting yourself on the way back around.

You can go through your own snake body where you first start and the snake is blue (Though there might be a bit of a bug in the very very starting point i didn't track down! )

You collect the food to up a level and you get faster each level

Also there are pink yokes you can eat to slow you back down again.

it has a basic high score screen and the code can show how to write a basic file to the device to store a score (It will create snapy.dat in the folder you run from)

The game uses pygame but only really for moving the snake around and displaying the food/pink yoke and playing sound.

I wrote my own collision detection using python strings as a map..

Errrr... thats about it - I'll be happy to answer any questions about the code - its a bit messy as I was learning as I was going along so don't expect it to be all that clear to understand!

Have fun.....
Attached Files
File Type: zip Snapy.zip (473.5 KB, 263 views)

Last edited by toucan murphy; 2010-04-29 at 20:00.
 

The Following 8 Users Say Thank You to toucan murphy For This Useful Post: