I am developing a simple platformer game using the arcade game library of Python. I am still new to this, but I have tried to use as much object oriented programming as I could. I have successfully setup two “rooms” or levels of the game. However, I cannot figure out how to move to the second room after finishing the first room. Here is my code:
JavaScript
x
336
336
1
import arcade
2
import os
3
import random
4
5
SPRITE_SCALING = 0.5
6
SPRITE_SCALING_COIN = 0.3
7
SPRITE_NATIVE_SIZE = 128
8
SPRITE_SIZE = int(SPRITE_NATIVE_SIZE * SPRITE_SCALING)
9
10
SCREEN_WIDTH = 800
11
SCREEN_HEIGHT = 600
12
SCREEN_TITLE = "Help Nick Adams!"
13
14
# Physics
15
MOVEMENT_SPEED = 5
16
JUMP_SPEED = 12
17
GRAVITY = 0.5
18
19
20
class Room:
21
# Class to hold info about rooms/levels
22
23
def __init__(self):
24
self.wall_list = self.goal_list = self.enemy_list = self.victory_sprite = None
25
self.collectedCoins = 0
26
self.numCoins = 0
27
28
29
def setup_room_1():
30
room = Room()
31
room.wall_list = arcade.SpriteList(use_spatial_hash=True)
32
room.enemy_list = arcade.SpriteList()
33
room.goal_list = arcade.SpriteList(use_spatial_hash=True)
34
room.victory_sprite = arcade.SpriteList(use_spatial_hash=True)
35
36
# Draw platforms and ground
37
for x in range(0, SCREEN_WIDTH, SPRITE_SIZE):
38
wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING)
39
40
wall.bottom = 0
41
wall.left = x
42
room.wall_list.append(wall)
43
44
for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE):
45
wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING)
46
47
wall.bottom = SPRITE_SIZE * 3
48
wall.left = x
49
room.wall_list.append(wall)
50
51
# Draw the crates
52
for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5):
53
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING)
54
55
wall.bottom = SPRITE_SIZE
56
wall.left = x
57
room.wall_list.append(wall)
58
59
# Draw an enemy 1
60
enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING)
61
62
enemy.bottom = SPRITE_SIZE
63
enemy.left = SPRITE_SIZE * 2
64
65
enemy.change_x = 2
66
room.enemy_list.append(enemy)
67
68
# -- Draw enemy2 on the platform
69
enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING)
70
71
enemy.bottom = SPRITE_SIZE * 4
72
enemy.left = SPRITE_SIZE * 4
73
74
# Set boundaries for enemy
75
enemy.boundary_right = SPRITE_SIZE * 8
76
enemy.boundary_left = SPRITE_SIZE * 3
77
enemy.change_x = 2
78
room.enemy_list.append(enemy)
79
80
# Set up coins
81
for pos in [[128, 96], [418, 300], [670, 150]]:
82
goal = arcade.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING)
83
goal.center_x = pos[0]
84
goal.center_y = pos[1]
85
room.goal_list.append(goal)
86
room.numCoins += 1
87
88
# Set up checkpoint/level clear
89
flag = arcade.Sprite(":resources:images/tiles/signExit.png", SPRITE_SCALING)
90
flag.center_x = 770
91
flag.center_y = 96
92
room.victory_sprite.append(flag)
93
94
# Load the background image for this level.
95
room.background = arcade.load_texture(":resources:images/backgrounds/abstract_1.jpg")
96
97
return room
98
99
100
def setup_room_2():
101
room = Room()
102
room.wall_list = arcade.SpriteList(use_spatial_hash=True)
103
room.enemy_list = arcade.SpriteList()
104
room.goal_list = arcade.SpriteList(use_spatial_hash=True)
105
room.victory_sprite = arcade.SpriteList(use_spatial_hash=True)
106
107
# Set up walls
108
for y in range(0, 800, 200):
109
for x in range(100, 700, 64):
110
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING)
111
wall.center_x = x
112
wall.center_y = y
113
room.wall_list.append(wall)
114
115
for pos in [[35, 40], [765, 80], [35, 280], [765, 480]]:
116
wall = arcade.Sprite(":resources:images/tiles/grassHalf.png", SPRITE_SCALING)
117
wall.center_x = pos[0]
118
wall.center_y = pos[1]
119
room.wall_list.append(wall)
120
121
# Create the coins
122
for i in range(50):
123
124
# Create the coin instance
125
# Coin image from kenney.nl
126
goal = arcade.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING_COIN)
127
128
# Boolean variable if we successfully placed the coin
129
coin_placed_successfully = False
130
131
# Keep trying until success
132
while not coin_placed_successfully:
133
# Position the coin
134
goal.center_x = random.randrange(100, 700)
135
goal.center_y = random.randrange(SCREEN_HEIGHT)
136
137
# See if the coin is hitting a wall
138
wall_hit_list = arcade.check_for_collision_with_list(goal, room.wall_list)
139
140
# See if the coin is hitting another coin
141
coin_hit_list = arcade.check_for_collision_with_list(goal, room.goal_list)
142
143
if len(wall_hit_list) == 0 and len(coin_hit_list) == 0:
144
coin_placed_successfully = True
145
146
# Add the coin to the lists
147
room.goal_list.append(goal)
148
room.numCoins += 1
149
150
# Draw an enemy1
151
enemy = arcade.Sprite(":resources:images/enemies/fly.png", SPRITE_SCALING_COIN)
152
153
enemy.bottom = SPRITE_SIZE
154
enemy.left = SPRITE_SIZE * 2
155
156
enemy.boundary_right = SPRITE_SIZE * 8 + 60
157
enemy.boundary_left = SPRITE_SIZE * 1 + 60
158
enemy.change_x = 3
159
room.enemy_list.append(enemy)
160
161
# Draw a enemy2
162
enemy = arcade.Sprite(":resources:images/enemies/fly.png", SPRITE_SCALING_COIN)
163
164
enemy.bottom = SPRITE_SIZE * 4
165
enemy.left = SPRITE_SIZE * 4
166
167
enemy.boundary_right = SPRITE_SIZE * 8
168
enemy.boundary_left = SPRITE_SIZE * 3
169
enemy.change_x = 4
170
room.enemy_list.append(enemy)
171
172
# Draw a enemy3
173
enemy = arcade.Sprite(":resources:images/enemies/fly.png", SPRITE_SCALING_COIN)
174
175
enemy.bottom = SPRITE_SIZE * 7.2
176
enemy.left = SPRITE_SIZE * 4
177
178
enemy.boundary_right = SPRITE_SIZE * 8 + 80
179
enemy.boundary_left = SPRITE_SIZE * 3
180
enemy.change_x = 4.8
181
room.enemy_list.append(enemy)
182
183
# Draw victory point
184
flag = arcade.Sprite(":resources:images/tiles/signExit.png", SPRITE_SCALING)
185
flag.center_x = 765
186
flag.center_y = 545
187
room.victory_sprite.append(flag)
188
189
# Load the background image for this level.
190
room.background = arcade.load_texture(":resources:images/backgrounds/abstract_1.jpg")
191
192
return room
193
194
195
class MainGame(arcade.Window):
196
197
def __init__(self):
198
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
199
200
file_path = os.path.dirname(os.path.abspath(__file__))
201
os.chdir(file_path)
202
203
# Sprites and set up player
204
self.player_list = self.rooms = self.player_sprite = self.physics_engine = None
205
self.current_room = self.view_left = self.view_bottom = self.collectedCoins = 0
206
self.game_over = False
207
208
# Load sounds
209
self.collect_goal_sound = arcade.load_sound(":resources:sounds/coin1.wav")
210
self.jump_sound = arcade.load_sound(":resources:sounds/jump1.wav")
211
212
def setup(self):
213
""" Set up the game and initialize the variables. """
214
215
# -- Set up the player
216
self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png",
217
SPRITE_SCALING)
218
219
# list of rooms
220
self.rooms = []
221
222
# Create the rooms
223
room = setup_room_1()
224
self.rooms.append(room)
225
226
room = setup_room_2()
227
self.rooms.append(room)
228
229
# Starting room number
230
self.current_room = 0
231
232
# Player start position according to room number
233
if self.current_room == 0:
234
self.player_sprite.center_x = 64
235
self.player_sprite.center_y = 270
236
elif self.current_room == 1:
237
self.player_sprite.center_x = 35
238
self.player_sprite.center_y = 55
239
self.player_list = arcade.SpriteList()
240
self.player_list.append(self.player_sprite)
241
242
# Create a physics engine
243
self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite, self.rooms[self.current_room].wall_list
244
)
245
246
# Set the background color
247
arcade.set_background_color(arcade.color.AMAZON)
248
249
def on_draw(self):
250
251
arcade.start_render()
252
253
self.rooms[self.current_room].wall_list.draw()
254
self.rooms[self.current_room].goal_list.draw()
255
self.rooms[self.current_room].enemy_list.draw()
256
self.rooms[self.current_room].victory_sprite.draw()
257
258
# Draw all the sprites.
259
self.player_list.draw()
260
261
def on_key_press(self, key, modifiers):
262
if key == arcade.key.UP:
263
if self.physics_engine.can_jump():
264
self.player_sprite.change_y = JUMP_SPEED
265
elif key == arcade.key.LEFT:
266
self.player_sprite.change_x = -MOVEMENT_SPEED
267
elif key == arcade.key.RIGHT:
268
self.player_sprite.change_x = MOVEMENT_SPEED
269
270
def on_key_release(self, key, modifiers):
271
if key == arcade.key.LEFT or key == arcade.key.RIGHT:
272
self.player_sprite.change_x = 0
273
274
def on_update(self, delta_time):
275
276
if not self.game_over:
277
# Move the enemies
278
self.rooms[self.current_room].enemy_list.update()
279
280
# Check each enemy
281
for enemy in self.rooms[self.current_room].enemy_list:
282
# If the enemy hit a wall, reverse
283
if len(arcade.check_for_collision_with_list(enemy, self.rooms[self.current_room].wall_list)) > 0:
284
enemy.change_x *= -1
285
# If the enemy hit the left boundary, reverse
286
elif enemy.boundary_left is not None and enemy.left < enemy.boundary_left:
287
enemy.change_x *= -1
288
# If the enemy hit the right boundary, reverse
289
elif enemy.boundary_right is not None and enemy.right > enemy.boundary_right:
290
enemy.change_x *= -1
291
292
# Update the player using the physics engine
293
self.physics_engine.update()
294
295
# See if we hit any coins
296
goal_hit_list = arcade.check_for_collision_with_list(self.player_sprite,
297
self.rooms[self.current_room].goal_list)
298
299
# Loop through each coin we hit (if any) and remove it
300
for goal in goal_hit_list:
301
# Remove the coin
302
goal.remove_from_sprite_lists()
303
# Play a sound
304
arcade.play_sound(self.collect_goal_sound)
305
# Count number of coins collected
306
self.collectedCoins += 1
307
308
if self.player_sprite.center_x <= -10 or self.player_sprite.center_x >= 800:
309
self.player_sprite.change_x = 0
310
self.player_sprite.change_y = 0
311
self.player_sprite.center_x = 64
312
self.player_sprite.center_y = 270
313
314
# See if the player hit a worm
315
if len(arcade.check_for_collision_with_list(self.player_sprite,
316
self.rooms[self.current_room].enemy_list)) > 0:
317
self.game_over = True
318
319
# See if the player hit the flag. If so, progress to round 2 ??????
320
if arcade.check_for_collision_with_list(self.player_sprite,
321
self.rooms[
322
self.current_room].victory_sprite) and self.collectedCoins ==
323
self.rooms[self.current_room].numCoins:
324
self.game_over = True
325
self.current_room += 1
326
327
328
def main():
329
window = MainGame()
330
window.setup()
331
arcade.run()
332
333
334
if __name__ == "__main__":
335
main()
336
If I delete self.gameover= True from the def update, the program transitions into room 2 but the sprites aren’t loaded properly and player position is not reset.
Advertisement
Answer
- replace
self.game_over = True
withself.setup()
- Move creation of rooms from
setup
to__init__
Updated script:
JavaScript
1
330
330
1
import arcade
2
import os
3
import random
4
5
SPRITE_SCALING = 0.5
6
SPRITE_SCALING_COIN = 0.3
7
SPRITE_NATIVE_SIZE = 128
8
SPRITE_SIZE = int(SPRITE_NATIVE_SIZE * SPRITE_SCALING)
9
10
SCREEN_WIDTH = 800
11
SCREEN_HEIGHT = 600
12
SCREEN_TITLE = "Help Nick Adams!"
13
14
# Physics
15
MOVEMENT_SPEED = 5
16
JUMP_SPEED = 12
17
GRAVITY = 0.5
18
19
20
class Room:
21
# Class to hold info about rooms/levels
22
23
def __init__(self):
24
self.wall_list = self.goal_list = self.enemy_list = self.victory_sprite = None
25
self.collectedCoins = 0
26
self.numCoins = 0
27
28
29
def setup_room_1():
30
room = Room()
31
room.wall_list = arcade.SpriteList(use_spatial_hash=True)
32
room.enemy_list = arcade.SpriteList()
33
room.goal_list = arcade.SpriteList(use_spatial_hash=True)
34
room.victory_sprite = arcade.SpriteList(use_spatial_hash=True)
35
36
# Draw platforms and ground
37
for x in range(0, SCREEN_WIDTH, SPRITE_SIZE):
38
wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING)
39
40
wall.bottom = 0
41
wall.left = x
42
room.wall_list.append(wall)
43
44
for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE):
45
wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING)
46
47
wall.bottom = SPRITE_SIZE * 3
48
wall.left = x
49
room.wall_list.append(wall)
50
51
# Draw the crates
52
for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5):
53
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING)
54
55
wall.bottom = SPRITE_SIZE
56
wall.left = x
57
room.wall_list.append(wall)
58
59
# Draw an enemy 1
60
enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING)
61
62
enemy.bottom = SPRITE_SIZE
63
enemy.left = SPRITE_SIZE * 2
64
65
enemy.change_x = 2
66
room.enemy_list.append(enemy)
67
68
# -- Draw enemy2 on the platform
69
enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING)
70
71
enemy.bottom = SPRITE_SIZE * 4
72
enemy.left = SPRITE_SIZE * 4
73
74
# Set boundaries for enemy
75
enemy.boundary_right = SPRITE_SIZE * 8
76
enemy.boundary_left = SPRITE_SIZE * 3
77
enemy.change_x = 2
78
room.enemy_list.append(enemy)
79
80
# Set up coins
81
for pos in [[128, 96], [418, 300], [670, 150]]:
82
goal = arcade.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING)
83
goal.center_x = pos[0]
84
goal.center_y = pos[1]
85
room.goal_list.append(goal)
86
room.numCoins += 1
87
88
# Set up checkpoint/level clear
89
flag = arcade.Sprite(":resources:images/tiles/signExit.png", SPRITE_SCALING)
90
flag.center_x = 770
91
flag.center_y = 96
92
room.victory_sprite.append(flag)
93
94
# Load the background image for this level.
95
room.background = arcade.load_texture(":resources:images/backgrounds/abstract_1.jpg")
96
97
return room
98
99
100
def setup_room_2():
101
room = Room()
102
room.wall_list = arcade.SpriteList(use_spatial_hash=True)
103
room.enemy_list = arcade.SpriteList()
104
room.goal_list = arcade.SpriteList(use_spatial_hash=True)
105
room.victory_sprite = arcade.SpriteList(use_spatial_hash=True)
106
107
# Set up walls
108
for y in range(0, 800, 200):
109
for x in range(100, 700, 64):
110
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING)
111
wall.center_x = x
112
wall.center_y = y
113
room.wall_list.append(wall)
114
115
for pos in [[35, 40], [765, 80], [35, 280], [765, 480]]:
116
wall = arcade.Sprite(":resources:images/tiles/grassHalf.png", SPRITE_SCALING)
117
wall.center_x = pos[0]
118
wall.center_y = pos[1]
119
room.wall_list.append(wall)
120
121
# Create the coins
122
for i in range(50):
123
124
# Create the coin instance
125
# Coin image from kenney.nl
126
goal = arcade.Sprite(":resources:images/items/coinGold.png", SPRITE_SCALING_COIN)
127
128
# Boolean variable if we successfully placed the coin
129
coin_placed_successfully = False
130
131
# Keep trying until success
132
while not coin_placed_successfully:
133
# Position the coin
134
goal.center_x = random.randrange(100, 700)
135
goal.center_y = random.randrange(SCREEN_HEIGHT)
136
137
# See if the coin is hitting a wall
138
wall_hit_list = arcade.check_for_collision_with_list(goal, room.wall_list)
139
140
# See if the coin is hitting another coin
141
coin_hit_list = arcade.check_for_collision_with_list(goal, room.goal_list)
142
143
if len(wall_hit_list) == 0 and len(coin_hit_list) == 0:
144
coin_placed_successfully = True
145
146
# Add the coin to the lists
147
room.goal_list.append(goal)
148
room.numCoins += 1
149
150
# Draw an enemy1
151
enemy = arcade.Sprite(":resources:images/enemies/fly.png", SPRITE_SCALING_COIN)
152
153
enemy.bottom = SPRITE_SIZE
154
enemy.left = SPRITE_SIZE * 2
155
156
enemy.boundary_right = SPRITE_SIZE * 8 + 60
157
enemy.boundary_left = SPRITE_SIZE * 1 + 60
158
enemy.change_x = 3
159
room.enemy_list.append(enemy)
160
161
# Draw a enemy2
162
enemy = arcade.Sprite(":resources:images/enemies/fly.png", SPRITE_SCALING_COIN)
163
164
enemy.bottom = SPRITE_SIZE * 4
165
enemy.left = SPRITE_SIZE * 4
166
167
enemy.boundary_right = SPRITE_SIZE * 8
168
enemy.boundary_left = SPRITE_SIZE * 3
169
enemy.change_x = 4
170
room.enemy_list.append(enemy)
171
172
# Draw a enemy3
173
enemy = arcade.Sprite(":resources:images/enemies/fly.png", SPRITE_SCALING_COIN)
174
175
enemy.bottom = SPRITE_SIZE * 7.2
176
enemy.left = SPRITE_SIZE * 4
177
178
enemy.boundary_right = SPRITE_SIZE * 8 + 80
179
enemy.boundary_left = SPRITE_SIZE * 3
180
enemy.change_x = 4.8
181
room.enemy_list.append(enemy)
182
183
# Draw victory point
184
flag = arcade.Sprite(":resources:images/tiles/signExit.png", SPRITE_SCALING)
185
flag.center_x = 765
186
flag.center_y = 545
187
room.victory_sprite.append(flag)
188
189
# Load the background image for this level.
190
room.background = arcade.load_texture(":resources:images/backgrounds/abstract_1.jpg")
191
192
return room
193
194
195
class MainGame(arcade.Window):
196
197
def __init__(self):
198
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
199
200
file_path = os.path.dirname(os.path.abspath(__file__))
201
os.chdir(file_path)
202
203
# Sprites and set up player
204
self.player_list = self.rooms = self.player_sprite = self.physics_engine = None
205
self.current_room = self.view_left = self.view_bottom = self.collectedCoins = 0
206
self.game_over = False
207
208
# Load sounds
209
self.collect_goal_sound = arcade.load_sound(":resources:sounds/coin1.wav")
210
self.jump_sound = arcade.load_sound(":resources:sounds/jump1.wav")
211
212
# Starting room number
213
self.current_room = 0
214
215
# list of rooms
216
self.rooms = []
217
218
# Create the rooms
219
room = setup_room_1()
220
self.rooms.append(room)
221
222
room = setup_room_2()
223
self.rooms.append(room)
224
225
def setup(self):
226
""" Set up the game and initialize the variables. """
227
228
# -- Set up the player
229
self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING)
230
231
# Player start position according to room number
232
if self.current_room == 0:
233
self.player_sprite.center_x = 64
234
self.player_sprite.center_y = 270
235
elif self.current_room == 1:
236
self.player_sprite.center_x = 35
237
self.player_sprite.center_y = 55
238
self.player_list = arcade.SpriteList()
239
self.player_list.append(self.player_sprite)
240
241
# Create a physics engine
242
self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite, self.rooms[self.current_room].wall_list)
243
244
# Set the background color
245
arcade.set_background_color(arcade.color.AMAZON)
246
247
def on_draw(self):
248
249
arcade.start_render()
250
251
self.rooms[self.current_room].wall_list.draw()
252
self.rooms[self.current_room].goal_list.draw()
253
self.rooms[self.current_room].enemy_list.draw()
254
self.rooms[self.current_room].victory_sprite.draw()
255
256
# Draw all the sprites.
257
self.player_list.draw()
258
259
def on_key_press(self, key, modifiers):
260
if key == arcade.key.UP:
261
if self.physics_engine.can_jump():
262
self.player_sprite.change_y = JUMP_SPEED
263
elif key == arcade.key.LEFT:
264
self.player_sprite.change_x = -MOVEMENT_SPEED
265
elif key == arcade.key.RIGHT:
266
self.player_sprite.change_x = MOVEMENT_SPEED
267
268
def on_key_release(self, key, modifiers):
269
if key == arcade.key.LEFT or key == arcade.key.RIGHT:
270
self.player_sprite.change_x = 0
271
272
def on_update(self, delta_time):
273
274
if not self.game_over:
275
# Move the enemies
276
self.rooms[self.current_room].enemy_list.update()
277
278
# Check each enemy
279
for enemy in self.rooms[self.current_room].enemy_list:
280
# If the enemy hit a wall, reverse
281
if len(arcade.check_for_collision_with_list(enemy, self.rooms[self.current_room].wall_list)) > 0:
282
enemy.change_x *= -1
283
# If the enemy hit the left boundary, reverse
284
elif enemy.boundary_left is not None and enemy.left < enemy.boundary_left:
285
enemy.change_x *= -1
286
# If the enemy hit the right boundary, reverse
287
elif enemy.boundary_right is not None and enemy.right > enemy.boundary_right:
288
enemy.change_x *= -1
289
290
# Update the player using the physics engine
291
self.physics_engine.update()
292
293
# See if we hit any coins
294
goal_hit_list = arcade.check_for_collision_with_list(self.player_sprite, self.rooms[self.current_room].goal_list)
295
296
# Loop through each coin we hit (if any) and remove it
297
for goal in goal_hit_list:
298
# Remove the coin
299
goal.remove_from_sprite_lists()
300
# Play a sound
301
arcade.play_sound(self.collect_goal_sound)
302
# Count number of coins collected
303
self.collectedCoins += 1
304
305
if self.player_sprite.center_x <= -10 or self.player_sprite.center_x >= 800:
306
self.player_sprite.change_x = 0
307
self.player_sprite.change_y = 0
308
self.player_sprite.center_x = 64
309
self.player_sprite.center_y = 270
310
311
# See if the player hit a worm
312
if len(arcade.check_for_collision_with_list(self.player_sprite, self.rooms[self.current_room].enemy_list)) > 0:
313
self.game_over = True
314
315
# See if the player hit the flag. If so, progress to round 2 ??????
316
if arcade.check_for_collision_with_list(self.player_sprite, self.rooms[self.current_room].victory_sprite) and self.collectedCoins == self.rooms[self.current_room].numCoins:
317
# self.game_over = True
318
self.current_room += 1
319
self.setup()
320
321
322
def main():
323
window = MainGame()
324
window.setup()
325
arcade.run()
326
327
328
if __name__ == "__main__":
329
main()
330