Reply
Thread Tools
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, 261 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:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#2
lol i'm working on a v similar one - will get it packaged and in extras soon
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
Posts: 67 | Thanked: 26 times | Joined on Jan 2010
#3
Originally Posted by noobmonkey View Post
lol i'm working on a v similar one - will get it packaged and in extras soon
Cheers - I used some of you code from HealthCheck to work out accelerometer - Hope you don't mind! :P
 

The Following 2 Users Say Thank You to toucan murphy For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#4
Of course not!! really good to hear (As i took it all from the wiki anyway!)

Great to see everyone hunting and using what is available
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
Posts: 729 | Thanked: 155 times | Joined on Dec 2009
#5
 

The Following User Says Thank You to DaSilva For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#6
Voted - well raised!
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 67 | Thanked: 26 times | Joined on Jan 2010
#7
Originally Posted by noobmonkey View Post
Of course not!! really good to hear (As i took it all from the wiki anyway!)

Great to see everyone hunting and using what is available
Yeah its hard to find the right stuff sometimes....but eventually it turns up!
 
Posts: 67 | Thanked: 26 times | Joined on Jan 2010
#8
Originally Posted by DaSilva View Post
You should vote for https://bugs.maemo.org/show_bug.cgi?id=5244
Voted.....cool i never realised there was an S60 version in development too.... Might try see if I can get this working on my old N958GB too!.. I guess all the dbus commands will have to be changed with something else.

It would be cool if the accelerometer and vibrate could become builtint functions of pygame.
 
Posts: 67 | Thanked: 26 times | Joined on Jan 2010
#9
Originally Posted by noobmonkey View Post
lol i'm working on a v similar one - will get it packaged and in extras soon

....I was going to try and package this and put it up into extras if anybody wanted to play it.

I'm getting stuck though when i try to run the run-standalone.sh python2.5 command to create the packages on the device.



Traceback (most recent call last):
File "build_snapy.py", line 54, in <module>
r = p.generate(version,build,changelog=changeloginform ation,tar=True,dsc=True,changes=True,build=False,s rc=True)
File "/usr/lib/python2.5/site-packages/py2deb.py", line 228, in generate
raise Py2debException("no files are defined")
py2deb.Py2debException: no files are defined

I have created snapy.desktop and snapy.service files and put them and the src files into /home/user/MyDocs/snapy with source files in src subfolder......

Not really sure where to go after this.... anybody?
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#10
Originally Posted by toucan murphy View Post
....I was going to try and package this and put it up into extras if anybody wanted to play it.

I'm getting stuck though when i try to run the run-standalone.sh python2.5 command to create the packages on the device.



Traceback (most recent call last):
File "build_snapy.py", line 54, in <module>
r = p.generate(version,build,changelog=changeloginform ation,tar=True,dsc=True,changes=True,build=False,s rc=True)
File "/usr/lib/python2.5/site-packages/py2deb.py", line 228, in generate
raise Py2debException("no files are defined")
py2deb.Py2debException: no files are defined

I have created snapy.desktop and snapy.service files and put them and the src files into /home/user/MyDocs/snapy with source files in src subfolder......

Not really sure where to go after this.... anybody?
Bit chocca with work this week - (Anyone notice the lack of Healthcheck updates?!)
But got time this weekend - so if no one has done it by then i'll give it a go
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Reply


 
Forum Jump


All times are GMT. The time now is 04:40.