-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfox_game.py
More file actions
54 lines (40 loc) · 793 Bytes
/
Copy pathfox_game.py
File metadata and controls
54 lines (40 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pgzrun
WIDTH = 800
HEIGHT = 400
game_over = False
jumping = False
car_speed = 30
fox = Actor('fox')
car = Actor('car')
fox.pos = 80, 300
car.pos = 700, 300
def draw():
screen.clear()
fox.draw()
car.draw()
def move_car():
global car_speed
if car.right <= 0:
car.pos = 700, 300
else:
car.left -= car_speed
def fox_jump():
fox.image = 'flying'
fox.y -= 130
clock.schedule(fox_land, 0.5)
def fox_land():
global jumping
fox.y += 130
fox.image = 'fox'
jumping = False
def on_key_up(key):
global jumping
if key == key.SPACE and not jumping:
jumping = True
fox_jump()
def update():
move_car()
collision = car.colliderect(fox)
if collision:
print("Oh no!")
pgzrun.go()