-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscores.py
40 lines (31 loc) · 1.09 KB
/
scores.py
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
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="karlo"
__date__ ="$Jun 5, 2011 4:02:31 PM$"
from gasp import *
def scores():
begin_graphics(800, 600, title="Catch", background=color.YELLOW)
set_speed(120)
player_score = 0
comp_score = 0
player = Text("Player: %d Points" % player_score, (10, 570), size=24)
computer = Text("Computer: %d Points" % comp_score, (640, 570), size=24)
while player_score < 5 and comp_score < 5:
sleep(1)
winner = random_between(0, 1)
if winner:
player_score += 1
remove_from_screen(player)
player = Text("Player: %d Points" % player_score, (10, 570), size=24)
else:
comp_score += 1
remove_from_screen(computer)
computer = Text("Computer: %d Points" % comp_score, (640, 570), size=24)
if player_score == 5:
Text("Player Wins!", (340, 290), size=32)
else:
Text("Computer Wins!", (340, 290), size=32)
sleep(4)
end_graphics()
if __name__ == "__main__":
scores()