2424# Classes
2525# Enemy class
2626class Enemy (arcade .AnimatedWalkingSprite ):
27- """An enemy sprite with basic walking movement
28- """
27+ """An enemy sprite with basic walking movement"""
2928
3029 def __init__ (self , pos_x : int , pos_y : int ) -> None :
30+ """Create enemy"""
3131 super ().__init__ (
3232 game .CHARACTER_SCALING , center_x = pos_x , center_y = pos_y
3333 )
@@ -74,10 +74,11 @@ class TitleView(arcade.View):
7474 """
7575
7676 def __init__ (self ) -> None :
77+ """Create title screen"""
7778 # Initialize the parent
7879 super ().__init__ ()
7980
80- # Find the folder contain our images
81+ # Find the title image in the images folder
8182 title_image_path = ASSETS_PATH / "images" / "title_image.png"
8283
8384 # Load our title image
@@ -109,8 +110,7 @@ def on_update(self, delta_time: float) -> None:
109110 self .display_timer = 1.0
110111
111112 def on_draw (self ) -> None :
112- """Draws everything to the screen
113- """
113+ """Draws everything to the screen"""
114114
115115 # Start the rendering loop
116116 arcade .start_render ()
@@ -152,10 +152,13 @@ def on_key_press(self, key: int, modifiers: int) -> None:
152152
153153# Instructions view
154154class InstructionsView (arcade .View ):
155+ """Show instructions to the player"""
156+
155157 def __init__ (self ) -> None :
158+ """Create instructions screen"""
156159 super ().__init__ ()
157160
158- # Find the folder contain our images
161+ # Find the instructions image in the image folder
159162 instructions_image_path = (
160163 ASSETS_PATH / "images" / "instructions_image.png"
161164 )
@@ -164,13 +167,12 @@ def __init__(self) -> None:
164167 self .instructions_image = arcade .load_texture (instructions_image_path )
165168
166169 def on_draw (self ) -> None :
167- """Draws everything to the screen
168- """
170+ """Draws everything to the screen"""
169171
170172 # Start the rendering loop
171173 arcade .start_render ()
172174
173- # Draw a rectangle filled with our title image
175+ # Draw a rectangle filled with the instructions image
174176 arcade .draw_texture_rectangle (
175177 center_x = game .SCREEN_WIDTH / 2 ,
176178 center_y = game .SCREEN_HEIGHT / 2 ,
@@ -180,7 +182,7 @@ def on_draw(self) -> None:
180182 )
181183
182184 def on_key_press (self , key : int , modifiers : int ) -> None :
183- """Resume the game when the user presses ESC again
185+ """Start the game when the user presses Enter
184186
185187 Arguments:
186188 key -- Which key was pressed
@@ -198,10 +200,10 @@ def on_key_press(self, key: int, modifiers: int) -> None:
198200
199201# Pause view, used when the player pauses the game
200202class PauseView (arcade .View ):
201- """Shown when the game is paused
202- """
203+ """Shown when the game is paused"""
203204
204205 def __init__ (self , game_view : arcade .View ) -> None :
206+ """Create the pause screen"""
205207 # Initialize the parent
206208 super ().__init__ ()
207209
@@ -214,8 +216,7 @@ def __init__(self, game_view: arcade.View) -> None:
214216 )
215217
216218 def on_draw (self ) -> None :
217- """Draw the underlying screen, blurred, then the Paused text
218- """
219+ """Draw the underlying screen, blurred, then the Paused text"""
219220
220221 # First, draw the underlying view
221222 # This also calls start_render(), so no need to do it again
@@ -253,12 +254,12 @@ def on_key_press(self, key: int, modifiers: int) -> None:
253254
254255# Victory View, shown when the player completes a level successfully
255256class VictoryView (arcade .View ):
256- """Shown when a level is completed
257- """
257+ """Shown when a level is completed"""
258258
259259 def __init__ (
260260 self , game_view : arcade .View , victory_sound : arcade .Sound
261261 ) -> None :
262+ """Create the victory screen"""
262263 # Initialize the parent
263264 super ().__init__ ()
264265
@@ -274,8 +275,7 @@ def __init__(
274275 )
275276
276277 def on_draw (self ) -> None :
277- """Draw the underlying screen, blurred, then the victory text
278- """
278+ """Draw the underlying screen, blurred, then the victory text"""
279279
280280 # First, draw the underlying view
281281 # This also calls start_render(), so no need to do it again
@@ -315,10 +315,10 @@ def on_key_press(self, key: int, modifiers: int) -> None:
315315
316316# Game Over View, shown when the game is over
317317class GameOverView (arcade .View ):
318- """Shown when a level is completed
319- """
318+ """Shown when the player loses the game"""
320319
321320 def __init__ (self , game_view : arcade .View ) -> None :
321+ """Create the game over screen"""
322322 # Initialize the parent
323323 super ().__init__ ()
324324
@@ -331,8 +331,7 @@ def __init__(self, game_view: arcade.View) -> None:
331331 )
332332
333333 def on_draw (self ) -> None :
334- """Draw the underlying screen, blurred, then the victory text
335- """
334+ """Draw the underlying screen, blurred, then the game over text"""
336335
337336 # First, draw the underlying view
338337 # This also calls start_render(), so no need to do it again
@@ -365,7 +364,7 @@ def on_draw(self) -> None:
365364 )
366365
367366 def on_key_press (self , key : int , modifiers : int ) -> None :
368- """Start the next level when the user presses Enter
367+ """Restart the current level when the user presses Enter
369368
370369 Arguments:
371370 key -- Which key was pressed
@@ -386,6 +385,7 @@ class PlatformerView(arcade.View):
386385 """
387386
388387 def __init__ (self ) -> None :
388+ """Create the game view"""
389389 # First initialize the parent
390390 super ().__init__ ()
391391
@@ -440,8 +440,7 @@ def __init__(self) -> None:
440440 self .view_mode = False
441441
442442 def setup (self ) -> None :
443- """Sets up the game for the current level
444- """
443+ """Sets up the game for the current level"""
445444
446445 # Get the current map based on the level
447446 map_name = f"platform_level_{ self .level :02} .tmx"
@@ -531,8 +530,7 @@ def setup(self) -> None:
531530 )
532531
533532 def create_enemy_sprites (self ) -> arcade .SpriteList :
534- """Creates enemy sprites appropriate for the current level
535- """
533+ """Creates enemy sprites appropriate for the current level"""
536534 enemies_list = arcade .SpriteList ()
537535
538536 # Only enemies on level 2
@@ -545,7 +543,7 @@ def create_player_sprite(self) -> arcade.AnimatedWalkingSprite:
545543 """Creates the animated player sprite
546544
547545 Returns:
548- arcade.AnimatedWalkingSprite -- The properly setup player sprite
546+ The properly setup player sprite
549547 """
550548 # Where are the player images stored?
551549 texture_path = ASSETS_PATH / "images" / "player"
@@ -802,8 +800,7 @@ def on_update(self, delta_time: float) -> None:
802800 self .scroll_viewport ()
803801
804802 def scroll_viewport (self ) -> None :
805- """Scrolls the viewport when the player gets close to the edges
806- """
803+ """Scrolls the viewport when the player gets close to the edges"""
807804 # Scroll left
808805 # Find the current left boundary
809806 left_boundary = self .view_left + game .LEFT_VIEWPORT_MARGIN
@@ -854,8 +851,7 @@ def scroll_viewport(self) -> None:
854851 )
855852
856853 def on_draw (self ) -> None :
857- """Draws everything
858- """
854+ """Draws everything"""
859855
860856 arcade .start_render ()
861857
0 commit comments