Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bouncing_square.py <<< ZZZ ? flickers
- from appuifw import *
- import e32
- from graphics import *
- running = 1
- def quit():
- global running
- running = 0
- app.exit_key_handler = quit
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- img = None
- app.screen = 'large'
- app.orientation = 'portrait'
- app.directional_pad = False
- app.body = canvas = Canvas(redraw_callback=draw)
- img = Image.new(canvas.size)
- res_x, res_y = canvas.size
- dy = 1
- dx = 1
- x1 = 0
- y1 = 0
- while running:
- x1 = x1 + dx
- y1 = y1 + dy
- x2 = x1 + 100
- y2 = y1 + 100
- if (x1 < -50):
- dx = -1 * dx
- elif (x1 > res_x - 50):
- dx = -1 * dx
- if (y1 < -50):
- dy = -1 * dy
- elif (y1 > res_y - 50):
- dy = -1 * dy
- img.clear(0x000000)
- img.rectangle((x1, y1, x2, y2), fill=0xff0000)
- draw(())
- e32.ao_yield()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement