-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal-game-code.js
More file actions
153 lines (102 loc) · 3.27 KB
/
final-game-code.js
File metadata and controls
153 lines (102 loc) · 3.27 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
cfa_final_game_code = `
########################### DO NOT EDIT ABOVE THIS LINE ###########################
################################ PYTHON CODE BELOW ################################
# STUDENTS:
# - Type your own game code below
# - Do not change any code outside of the designated area
import random
table = None
cup = None
cup2 = None
cup3 = None
ball = None
reveal_button = None
seconds = 0
ready_button = None
scramble = None
black = None
guess_button = None
positions = [475, 675, 875]
randomPosition = random.randint(0, 2)
choose = positions[randomPosition]
instruction = print_text("Instructions:", 50)
ball_instructions = print_text('''Hit the ball back and forth''', 35)
ball_instructions2 = print_text('''Ball speeds up with each hit''', 35)
ball_instructions3 = print_text('''Go until someone dies''', 35)
start_button = add_image("startbutton.png", 200)
place_element(start_button, 630, 400)
place_element(instruction, 575, 45)
place_element(ball_instructions, 509, 130)
place_element(ball_instructions2, 490, 175)
place_element(ball_instructions3, 540, 220)
add_background("ClosedCurtains.jpeg")
def startGame(target):
global reveal_button
remove_el(target)
remove_el(instruction)
remove_el(ball_instructions)
remove_el(ball_instructions2)
remove_el(ball_instructions3)
playerElements()
reveal_button = add_image("reveal.png", 300)
place_element(reveal_button, 585, 200)
ready_button = add_image("ready.png", 300)
place_element(ready_button, 590, 50)
click(reveal_button, showPlayer)
click(ready_button, blackScreen)
def playerElements():
global ball
global table
global cup
global cup2
global cup3
add_background("Open.png")
ball = add_image("ball.png", 125)
place_element(ball, -3000, 420)
table = add_image("Table.png", 900)
place_element(table, 300, 525)
cup = add_image("redcup.png", 375)
place_element(cup, 350, 273)
cup2 = add_image("redcup.png", 375)
place_element(cup2, 550, 273)
cup3 = add_image("redcup.png", 375)
place_element(cup3, 750, 273)
# Showing the player the game
def showPlayer(target):
global reveal_button
remove_el(target)
revealHint()
def revealHint():
randomBallPlacement()
if randomPosition == 0:
reverseCupAnimation1()
elif randomPosition == 1:
reverseCupAnimation2()
else:
reverseCupAnimation3()
# Blinding the Player
def blackScreen(target):
global black
global scramble
global guess_button
remove_el(target)
black = add_image("Black.jpeg", 2000)
place_element(black, -1, -1)
scramble = print_text("Scrambling!", 100)
place_element(scramble, 465, 230)
# Reshowing the game
# Randomizing ball placement
def randomBallPlacement():
global choose
place_element(ball, choose, 420)
# Cup Animations
def reverseCupAnimation1():
animate_y(cup, 25, 273, 1, False, 80)
def reverseCupAnimation2():
animate_y(cup2, 25, 273, 1, False, 80)
def reverseCupAnimation3():
animation_y(cup3, 25, 273, 1, False, 80)
click(start_button, startGame)
################################ PYTHON CODE ABOVE ################################
########################### DO NOT EDIT BELOW THIS LINE ###########################
`