Added spaceship

This commit is contained in:
2026-05-28 10:58:15 +08:00
parent a1fdd93d26
commit a4ccefcc1f
3 changed files with 29 additions and 0 deletions

BIN
images/gemgreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/playership1_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

29
main.py
View File

@@ -1,6 +1,35 @@
import pgzrun
import random
WIDTH = 800
HEIGHT = 600
ship = Actor('playership1_blue')
ship.x = 370
ship.y = 550
gem = Actor('gemgreen')
gem.x = random.randint(20, 780)
gem.y = 0
def update():
if keyboard.left:
ship.x = ship.x - 5
if keyboard.right:
ship.x = ship.x + 5
gem.y = gem.y + 4
if gem.y > 600:
gem.x = random.randint(20, 780)
gem.y = 0
if gem.colliderect(ship):
gem.x = random.randint(20, 780)
gem.y = 0
def draw():
screen.fill((80,0,70))
gem.draw()
ship.draw()
pgzrun.go() # Must be last line