Skip to content

Commit 0a54cc6

Browse files
committed
Updating comments and variable names
1 parent 02ed736 commit 0a54cc6

16 files changed

+705
-1006
lines changed

arcade-platformer/arcade_platformer/01_game_skeleton.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
#
2-
# Arcade Platformer
3-
#
4-
# Demonstrating the capbilities of arcade in a platformer game
5-
# Supporting the Arcade Platformer article on https://realpython.com
6-
#
7-
# All game artwork and sounds, except the tile map, from www.kenney.nl
8-
#
9-
10-
# Import libraries
1+
"""
2+
Arcade Platformer
3+
4+
Demonstrating the capbilities of arcade in a platformer game
5+
Supporting the Arcade Platformer article on https://realpython.com
6+
7+
All game artwork from www.kenney.nl
8+
Game sounds and tile maps by author
9+
"""
10+
1111
import arcade
1212

1313

14-
# Classes
1514
class Platformer(arcade.Window):
16-
"""Platformer class. Derived from arcade.Window,
17-
manages different aspects of the game.
18-
"""
19-
2015
def __init__(self):
2116
pass
2217

@@ -41,19 +36,17 @@ def on_key_release(self, key: int, modifiers: int):
4136
"""
4237

4338
def on_update(self, delta_time: float):
44-
"""Updates the position of all screen objects
39+
"""Updates the position of all game objects
4540
4641
Arguments:
4742
delta_time {float} -- How much time since the last call
4843
"""
4944
pass
5045

5146
def on_draw(self):
52-
"""Draws everything"""
5347
pass
5448

5549

56-
# Main
5750
if __name__ == "__main__":
5851
window = Platformer()
5952
window.setup()

arcade-platformer/arcade_platformer/02_open_game_window.py

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
#
2-
# Arcade Platformer
3-
#
4-
# Demonstrating the capbilities of arcade in a platformer game
5-
# Supporting the Arcade Platformer article on https://realpython.com
6-
#
7-
# All game artwork and sounds, except the tile map and victory sound,
8-
# from www.kenney.nl
1+
"""
2+
Arcade Platformer
93
4+
Demonstrating the capbilities of arcade in a platformer game
5+
Supporting the Arcade Platformer article on https://realpython.com
6+
7+
All game artwork from www.kenney.nl
8+
Game sounds and tile maps by author
9+
"""
1010

11-
# Import libraries
1211
import arcade
1312
import pathlib
1413

@@ -22,24 +21,17 @@
2221
ASSETS_PATH = pathlib.Path(__file__).resolve().parent.parent / "assets"
2322

2423

25-
# Classes
2624
class Platformer(arcade.Window):
27-
"""Platformer class. Derived from arcade.Window,
28-
manages different aspects of the game.
29-
"""
30-
3125
def __init__(self) -> None:
32-
"""Create the game view"""
33-
# First initialize the parent
3426
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
3527

3628
# These lists will hold different sets of sprites
37-
self.coins_list = None
38-
self.background_list = None
39-
self.walls_list = None
40-
self.ladders_list = None
41-
self.goals_list = None
42-
self.enemies_list = None
29+
self.coins = None
30+
self.background = None
31+
self.walls = None
32+
self.ladders = None
33+
self.goals = None
34+
self.enemies = None
4335

4436
# One sprite for the player, no more is needed
4537
self.player = None
@@ -69,36 +61,29 @@ def setup(self):
6961
pass
7062

7163
def on_key_press(self, key: int, modifiers: int):
72-
"""Processes key presses
73-
74-
Arguments:
75-
key {int} -- Which key was pressed
76-
modifiers {int} -- Which modifiers were down at the time
64+
"""Arguments:
65+
key {int} -- Which key was pressed
66+
modifiers {int} -- Which modifiers were down at the time
7767
"""
7868

7969
def on_key_release(self, key: int, modifiers: int):
80-
"""Processes key releases
81-
82-
Arguments:
83-
key {int} -- Which key was released
84-
modifiers {int} -- Which modifiers were down at the time
70+
"""Arguments:
71+
key {int} -- Which key was released
72+
modifiers {int} -- Which modifiers were down at the time
8573
"""
8674

8775
def on_update(self, delta_time: float):
88-
"""Updates the position of all screen objects
76+
"""Updates the position of all game objects
8977
9078
Arguments:
9179
delta_time {float} -- How much time since the last call
9280
"""
9381
pass
9482

9583
def on_draw(self):
96-
"""Draws everything"""
9784
pass
9885

9986

100-
# Main
101-
# Main
10287
if __name__ == "__main__":
10388
window = Platformer()
10489
window.setup()

arcade-platformer/arcade_platformer/03_read_level_one.py

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
#
2-
# Arcade Platformer
3-
#
4-
# Demonstrating the capbilities of arcade in a platformer game
5-
# Supporting the Arcade Platformer article on https://realpython.com
6-
#
7-
# All game artwork and sounds, except the tile map and victory sound,
8-
# from www.kenney.nl
1+
"""
2+
Arcade Platformer
93
4+
Demonstrating the capbilities of arcade in a platformer game
5+
Supporting the Arcade Platformer article on https://realpython.com
6+
7+
All game artwork from www.kenney.nl
8+
Game sounds and tile maps by author
9+
"""
1010

11-
# Import libraries
1211
import arcade
1312
import pathlib
1413

@@ -30,24 +29,17 @@
3029
ASSETS_PATH = pathlib.Path(__file__).resolve().parent.parent / "assets"
3130

3231

33-
# Classes
3432
class Platformer(arcade.Window):
35-
"""Platformer class. Derived from arcade.Window,
36-
manages different aspects of the game.
37-
"""
38-
3933
def __init__(self) -> None:
40-
"""Create the game view"""
41-
# First initialize the parent
4234
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
4335

4436
# These lists will hold different sets of sprites
45-
self.coins_list = None
46-
self.background_list = None
47-
self.walls_list = None
48-
self.ladders_list = None
49-
self.goals_list = None
50-
self.enemies_list = None
37+
self.coins = None
38+
self.background = None
39+
self.walls = None
40+
self.ladders = None
41+
self.goals = None
42+
self.enemies = None
5143

5244
# One sprite for the player, no more is needed
5345
self.player = None
@@ -87,29 +79,29 @@ def setup(self) -> None:
8779
ladders_layer = "ladders"
8880

8981
# Load the current map
90-
map = arcade.tilemap.read_tmx(str(map_path))
82+
game_map = arcade.tilemap.read_tmx(str(map_path))
9183

9284
# Load the layers
93-
self.background_list = arcade.tilemap.process_layer(
94-
map, layer_name=background_layer, scaling=MAP_SCALING
85+
self.background = arcade.tilemap.process_layer(
86+
game_map, layer_name=background_layer, scaling=MAP_SCALING
9587
)
96-
self.goals_list = arcade.tilemap.process_layer(
97-
map, layer_name=goal_layer, scaling=MAP_SCALING
88+
self.goals = arcade.tilemap.process_layer(
89+
game_map, layer_name=goal_layer, scaling=MAP_SCALING
9890
)
99-
self.walls_list = arcade.tilemap.process_layer(
100-
map, layer_name=wall_layer, scaling=MAP_SCALING
91+
self.walls = arcade.tilemap.process_layer(
92+
game_map, layer_name=wall_layer, scaling=MAP_SCALING
10193
)
102-
self.ladders_list = arcade.tilemap.process_layer(
103-
map, layer_name=ladders_layer, scaling=MAP_SCALING
94+
self.ladders = arcade.tilemap.process_layer(
95+
game_map, layer_name=ladders_layer, scaling=MAP_SCALING
10496
)
105-
self.coins_list = arcade.tilemap.process_layer(
106-
map, layer_name=coin_layer, scaling=MAP_SCALING
97+
self.coins = arcade.tilemap.process_layer(
98+
game_map, layer_name=coin_layer, scaling=MAP_SCALING
10799
)
108100

109101
# Set the background color
110102
background_color = arcade.color.FRESH_AIR
111-
if map.background_color:
112-
background_color = map.background_color
103+
if game_map.background_color:
104+
background_color = game_map.background_color
113105
arcade.set_background_color(background_color)
114106

115107
# Create the player sprite, if they're not already setup
@@ -125,42 +117,35 @@ def setup(self) -> None:
125117
# Load the physics engine for this map
126118
self.physics_engine = arcade.PhysicsEnginePlatformer(
127119
player_sprite=self.player,
128-
platforms=self.walls_list,
120+
platforms=self.walls,
129121
gravity_constant=GRAVITY,
130-
ladders=self.ladders_list,
122+
ladders=self.ladders,
131123
)
132124

133125
def on_key_press(self, key: int, modifiers: int):
134-
"""Processes key presses
135-
136-
Arguments:
137-
key {int} -- Which key was pressed
138-
modifiers {int} -- Which modifiers were down at the time
126+
"""Arguments:
127+
key {int} -- Which key was pressed
128+
modifiers {int} -- Which modifiers were down at the time
139129
"""
140130

141131
def on_key_release(self, key: int, modifiers: int):
142-
"""Processes key releases
143-
144-
Arguments:
145-
key {int} -- Which key was released
146-
modifiers {int} -- Which modifiers were down at the time
132+
"""Arguments:
133+
key {int} -- Which key was released
134+
modifiers {int} -- Which modifiers were down at the time
147135
"""
148136

149137
def on_update(self, delta_time: float):
150-
"""Updates the position of all screen objects
138+
"""Updates the position of all game objects
151139
152140
Arguments:
153141
delta_time {float} -- How much time since the last call
154142
"""
155143
pass
156144

157145
def on_draw(self):
158-
"""Draws everything"""
159146
pass
160147

161148

162-
# Main
163-
# Main
164149
if __name__ == "__main__":
165150
window = Platformer()
166151
window.setup()

0 commit comments

Comments
 (0)