Hello Rafael T.!
Originally Posted by Rafael T.
Look at the link over here.
Getting Started with Game Programming
The above example is based on the event based code.
In the above code/example which i mentioned, i have used these two lines;
These two lines makes the application listen for events. we can also call it the main method of the game or application. if you test this example and remove these two lines, the application will appear and then disappear.
so the point is these two lines makes the application run forever now how to stop it.
then when we want to stop it, we send it a signal, you can see it in my code in quit() method;
this was all about event based code
now if you wants to see a non event based code, here it is;
Note: i have removed the above mentioned lines.
i have just added a new global variable "running", you can see it here;
# __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
global x,y, running
x = 110
y = 160
running = 1
# 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
changed the quit method to;
global x,y, running
and changed the last three lines to;