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