Archived:Getting started with game programming on PySymbian
This example shows how to do the basic key handling, how to draw graphics to screen,, how to move a graphic with the help of keypad, and how to clear the screen.
# __author__='Fayyaz Ali'
# version = '1.0 beta'
# license='GNU GPL'
# import the required modules
import e32, appuifw, key_codes, graphics
# define the exit function
# make the screen large
x = 110
y = 160
# this method is for handling the redraw event of canvas
# this method is called when the ok button is pressed
# this method is called when the right button is pressed
# this method is called when the left button is pressed
# this method is called when the up button is pressed
# this method is called when the down button is pressed
# clear img
# open an image
# resize the image
img2 = img1.resize((20,20))
# copy the img1 to img
img.blit(img2, (0,0), (x, y))
# create an empty image according to the resolution of the phone
# create an object of the Canvas
# bind the canvas with keys, so that it can listen to
# key presses of those keys and do some actions on each key
# we are passing two parameters to the bind method of canvas class.
# The first is the key code to which we want our application to
# listen to events. And the second is handler for the event.
# set the application body to canvas