diff --git a/aladdin.py b/aladdin.py new file mode 100644 index 0000000..0a70ed5 --- /dev/null +++ b/aladdin.py @@ -0,0 +1,32 @@ +import pgzrun +from pgzero.builtins import Actor + +TITLE = 'Aladdin' +WIDTH = 686 +HEIGHT = 490 + +genius = Actor('genie', midtop=(343, 245)) +genius.x_direction = 1 # right +genius.y_direction = 1 # down +genius.speed = 2 + + +def update(): + if genius.x+genius.width/2 >= WIDTH and genius.x_direction == 1: + genius.x_direction = -1 + if genius.x-genius.width/2 <= 0 and genius.x_direction == -1: + genius.x_direction = 1 + + if genius.y+genius.height/2 >= HEIGHT and genius.y_direction == 1: + genius.y_direction = -1 + if genius.y-genius.height/2 <= 0 and genius.y_direction == -1: + genius.y_direction = 1 + genius.x += genius.x_direction * genius.speed + genius.y += genius.y_direction * genius.speed + +def draw(): + screen.blit('background', (0, 0)) + genius.draw() + + +pgzrun.go() diff --git a/images/background.jpg b/images/background.jpg new file mode 100644 index 0000000..1d89f42 Binary files /dev/null and b/images/background.jpg differ diff --git a/images/genie.png b/images/genie.png new file mode 100644 index 0000000..d5d2583 Binary files /dev/null and b/images/genie.png differ