The Following 28 Users Say Thank You to kojacker For This Useful Post: | ||
|
2010-06-14
, 03:33
|
Posts: 13 |
Thanked: 20 times |
Joined on Jun 2010
|
#2
|
The Following 4 Users Say Thank You to timconradinc For This Useful Post: | ||
|
2010-06-16
, 21:28
|
Posts: 44 |
Thanked: 28 times |
Joined on Mar 2010
|
#3
|
The Following User Says Thank You to ny-hardcore For This Useful Post: | ||
|
2012-03-30
, 13:11
|
Posts: 372 |
Thanked: 61 times |
Joined on Jan 2012
|
#4
|
|
2012-03-30
, 13:55
|
|
Posts: 1,411 |
Thanked: 1,330 times |
Joined on Jan 2010
@ Tatooine
|
#5
|
is it possible to crete a game clone of lane splitter or temple run. just simple. may be a box moving with obstacles. there are many simple games in android which have no esp graphics at all. like impossible jump and speedes 3D or falling ball. or smthng like stick games. those games do not have any esp graphics but are damn addictive. is it possible to make them?
This is another beginner tutorial in association with the N900 coding competition , running til July 21st. Please get involved
Part1: Building a hello world style app with a spaceship that moves to keypresses
Part2: Building an accelerometer app which makes a hammer sound when the N900 is held and moved downwards in a hammering motion
This short tutorial covers:
Pre-requisites
• Python should be installed correctly on your PC and n900. If not, please read over the start of MikeC's excellent tutorial to get your environment set up. Python for the N900 is available in the 'extras' repository.
• You should have WinSCP on your PC and OpenSSH client-server on your n900 (or equivalents) for copying the files over.
Caveats
I am also a beginner, this tutorial is put out there in the hope it helps but should not be seen as well written or particularly ‘good’
Get Python and PyGame
PyGame for you development machine can be downloaded from pygame.org. The 'python-pygame' module is available to install on your N900 via the extras repository. You can also install it from xterm, using the following command:
It's basically Hello World, but with an added moveable space ship. I created two images for this example, star_background.jpg and starship.jpg. Feel free to use the files attached or substitute your own.
Next we build the code. The first step is to import and intialize PyGame. Open up a new file in your IDE or text editor and type in:
We need to create a clock object to manage the loop timing, a fps variable to assign the speed, and a boolean 'mainloop' to set to false when we want the loop to stop running (e.g. quitting the app)
Part2 - adding sound and accelerometer with maeHammer
Start off with a hammer image. You can use the one I've drawn or substitute it for one of your own. You also need a sound file of a hammer noise (or any noise), you'll find hammeronce.wav in my attached files or again feel free to substitute one of your own.
Here is the full code, a lot of it should be familiar to the previous example. Copy and paste it into your ide/text editor, and save as maeHammer.py. To test, grip the n900 at the right side (handle of the hammer image) like you're holding a hammer and do a hammer type motion. A sound should play when the left side of the n900 goes down past the horizontal orientation. Please do not hammer anything other than air with your n900!
Anyway, you cant run this locally as the accelerometer file wont exist on your computer im sure So use WinSCP and OpenSSH to transfer the files into your N900’s Opt directory. To run, open Xterm and cd into the opt directory and run the main.py file.
That's it from me. Make sure you check out the much better tutorials on pygame.org - http://www.pygame.org/wiki/tutorials. There are also lots of examples and ideas there, it's a great resource
Follow me on my neglected twitter @kojacker
Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun
Last edited by kojacker; 2010-06-13 at 00:23.