42 lines
731 B
Python
42 lines
731 B
Python
import pgzrun
|
|
import random
|
|
|
|
WIDTH = 800
|
|
HEIGHT = 600
|
|
|
|
apple = Actor("apple")
|
|
apple_x = WIDTH / 2
|
|
apple_y = HEIGHT / 2
|
|
apple.pos = (WIDTH / 2 , HEIGHT / 2)
|
|
|
|
sword = Actor("sword")
|
|
|
|
dinosuars = []
|
|
corpses = []
|
|
|
|
spawn_interval = 2.0
|
|
min_spawn_interval = 0.2
|
|
spawn_timer = 0
|
|
game_time = 0
|
|
|
|
def draw():
|
|
screen.fill((100,220,100))
|
|
apple.draw()
|
|
|
|
def spawn_dinosaur():
|
|
dino = Actor("dino")
|
|
|
|
side = random.randint(0,3)
|
|
if side == 0:
|
|
dino_x = random.randint(0.WIDTH)
|
|
dino_y = -50
|
|
elif side == 1:
|
|
dino_x = random.randint(0,WIDTH)
|
|
dino_y = HEIGHT + 50
|
|
elif side == 2:
|
|
dino_x = WIDTH + 50
|
|
dino_y = random.randint(0,HEIGHT)
|
|
dinosuars.append(dino)
|
|
|
|
|
|
pgzrun.go() |