This commit is contained in:
2026-06-15 10:08:51 +08:00
parent 3cf5d463aa
commit e76e396274
9 changed files with 55 additions and 0 deletions

BIN
images/coingold.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
images/p3_front.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
images/run__000.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/run__002.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/run__004.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

55
import pgzrun.py Normal file
View File

@@ -0,0 +1,55 @@
import pgzrun
import random
WIDTH = 800
HEIGHT = 600
background = Actor('grass')
player = Actor('p3_front')
player.x = 400
player.y = 300
coin = Actor('coingold')
coin.x = random.randint(0, 800)
coin.y = random.randint(0, 600)
score = 0
timer = 10
def update():
global score
global timer
if timer <= 0:
return
timer -= 1 / 60
if keyboard.up:
player.y -= 5
if keyboard.down:
player.y += 5
if keyboard.left:
player.x -= 5
if keyboard.right:
player.x += 5
if player.colliderect(coin):
coin.x = random.randint(0, 800)
coin.y = random.randint(0, 600)
score += 1
def draw():
if timer <= 0:
screen.clear()
screen.draw.text('Game Over', (350,270), color=(255,255,255), fontsize=30)
screen.draw.text('Score: ' + str(score), (350,330), color=(255,255,255), fontsize=30)
else:
background.draw()
player.draw()
coin.draw()
screen.draw.text('Score: ' + str(score), (15,10), color=(255,255,255), fontsize=30)
screen.draw.text('Time: ' + str(round(timer, 2)), (330,10), color=(255,255,255), fontsize=30)
pgzrun.go() # Must be last line

BIN
sfx_coin_single1.wav Normal file

Binary file not shown.

BIN
sfx_sounds_fanfare1.wav Normal file

Binary file not shown.