From bc529ac8962e205bb0dca6074f4913c1b1a69500 Mon Sep 17 00:00:00 2001 From: Paul V Craven Date: Thu, 8 Oct 2026 10:16:21 -0500 Subject: [PATCH] Fix code excerpts in the docs that point at the wrong lines Example code changed after the docs set their line numbers, so many :emphasize-lines: and :lines: options highlighted or showed the wrong code. Each one is remapped from the commit that set its numbers to where that code is now. Where the code was rewritten, the excerpt highlights the code that does the same job now. The pymunk ladder on_update excerpt uses :pyobject: so it can't drift again. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + doc/example_code/camera2d_splitscreen.rst | 2 +- doc/example_code/performance_statistics.rst | 2 +- doc/example_code/sprite_bullets_periodic.rst | 2 +- .../sprite_collect_coins_background.rst | 2 +- .../sprite_explosion_bitmapped.rst | 2 +- .../sprite_face_left_or_right.rst | 2 +- doc/example_code/sprite_move_keyboard.rst | 2 +- .../sprite_move_keyboard_accel.rst | 2 +- .../sprite_move_keyboard_better.rst | 2 +- doc/example_code/sprite_move_scrolling.rst | 2 +- .../sprite_move_scrolling_shake.rst | 2 +- doc/example_code/sprite_no_coins_on_walls.rst | 2 +- .../sprite_rotate_around_point.rst | 2 +- .../sprite_rotate_around_tank.rst | 2 +- doc/tutorials/card_game/index.rst | 2 +- doc/tutorials/compute_shader/index.rst | 4 +- doc/tutorials/menu/index.rst | 24 +++++----- doc/tutorials/platform_tutorial/step_04.rst | 2 +- doc/tutorials/platform_tutorial/step_05.rst | 2 +- doc/tutorials/platform_tutorial/step_06.rst | 2 +- doc/tutorials/platform_tutorial/step_08.rst | 2 +- doc/tutorials/platform_tutorial/step_09.rst | 2 +- doc/tutorials/platform_tutorial/step_10.rst | 2 +- doc/tutorials/platform_tutorial/step_11.rst | 2 +- doc/tutorials/platform_tutorial/step_13.rst | 2 +- doc/tutorials/platform_tutorial/step_14.rst | 2 +- doc/tutorials/pymunk_platformer/index.rst | 45 ++++++++++--------- doc/tutorials/raycasting/index.rst | 4 +- doc/tutorials/shader_toy_glow/index.rst | 2 +- 30 files changed, 65 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1f8b288b6..d57acde16c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page. - Sped up removing many sprites from a large `SpriteList`, such as every bullet that hit something this frame. `SpriteList.remove()`, and so `Sprite.remove_from_sprite_lists()` and `kill()`, used to search the whole list for each sprite. Removals now wait until the list is next used, and many are applied in one pass: removing 100 sprites from 41,000 went from 19 ms to 3.3 ms, and 500 from 166,000 went from 630 ms to 17 ms. Drawing order is kept, and a few removals cost the same as before. - Documented choosing a spatial hash cell size (`spatial_hash_cell_size`) in the performance tips and the `SpriteList` docs: about the size of the sprites in the list. With 4 pixel sprites, collision checks were 16 times faster with 8 pixel cells than with the default of 128. - Type checking with mypy and pyright now fails the CI check, like formatting and linting. Their existing errors are fixed. +- Fixed code excerpts in the docs that highlighted or showed the wrong lines, because the example code had changed since their line numbers were set. This covers 62 excerpts: 48 in the platformer, pymunk platformer, menu, card game, compute shader, raycasting and shader toy glow tutorials, and 14 on example pages. Most now highlight the same code they were written for. Where the code was rewritten, they highlight the code that does the same job now. ## 4.0.0.dev8 diff --git a/doc/example_code/camera2d_splitscreen.rst b/doc/example_code/camera2d_splitscreen.rst index cedfd15fc7..cc3e20e5bc 100644 --- a/doc/example_code/camera2d_splitscreen.rst +++ b/doc/example_code/camera2d_splitscreen.rst @@ -13,4 +13,4 @@ Two Player Split Screen .. literalinclude:: ../../arcade/examples/camera2d_splitscreen.py :caption: camera2d_splitscreen.py :linenos: - :emphasize-lines: 145-149, 206-228, 251-253, 256-260, 263-292 + :emphasize-lines: 144-150, 217-239, 245-248, 254-264, 269-271, 273-303, 305-314 diff --git a/doc/example_code/performance_statistics.rst b/doc/example_code/performance_statistics.rst index 7cbd3d6013..83ce2341d6 100644 --- a/doc/example_code/performance_statistics.rst +++ b/doc/example_code/performance_statistics.rst @@ -38,4 +38,4 @@ See :ref:`perf_info_api` for more information about the performance api. .. literalinclude:: ../../arcade/examples/performance_statistics.py :caption: performance_statistics.py :linenos: - :emphasize-lines: 43-45, 114-141, 152-157, 164-166 + :emphasize-lines: 42-44, 120-147, 158-164, 171-173 diff --git a/doc/example_code/sprite_bullets_periodic.rst b/doc/example_code/sprite_bullets_periodic.rst index 47f161d75a..bc4d2b792a 100644 --- a/doc/example_code/sprite_bullets_periodic.rst +++ b/doc/example_code/sprite_bullets_periodic.rst @@ -21,4 +21,4 @@ to this example. .. literalinclude:: ../../arcade/examples/sprite_bullets_periodic.py :caption: sprite_bullets_periodic.py :linenos: - :emphasize-lines: 14-48, 76-79, 86-89, 107-108 + :emphasize-lines: 14-48, 79-84, 91-94, 112-113 diff --git a/doc/example_code/sprite_collect_coins_background.rst b/doc/example_code/sprite_collect_coins_background.rst index 6d43892952..06f779d1d6 100644 --- a/doc/example_code/sprite_collect_coins_background.rst +++ b/doc/example_code/sprite_collect_coins_background.rst @@ -13,4 +13,4 @@ Using a Background Image .. literalinclude:: ../../arcade/examples/sprite_collect_coins_background.py :caption: sprite_collect_coins_background.py :linenos: - :emphasize-lines: 41-42, 62-65, 99-102 + :emphasize-lines: 33-34, 84-88 diff --git a/doc/example_code/sprite_explosion_bitmapped.rst b/doc/example_code/sprite_explosion_bitmapped.rst index da63c2b398..2a1a7185fe 100644 --- a/doc/example_code/sprite_explosion_bitmapped.rst +++ b/doc/example_code/sprite_explosion_bitmapped.rst @@ -13,4 +13,4 @@ Sprite Explosions Bitmapped .. literalinclude:: ../../arcade/examples/sprite_explosion_bitmapped.py :caption: sprite_explosion_bitmapped.py :linenos: - :emphasize-lines: 26, 29-47, 62, 71-87, 99, 140, 181, 192-203 + :emphasize-lines: 26, 29-49, 64, 82-104, 115, 145, 195, 206-217 diff --git a/doc/example_code/sprite_face_left_or_right.rst b/doc/example_code/sprite_face_left_or_right.rst index 8b15463860..78b2a907b9 100644 --- a/doc/example_code/sprite_face_left_or_right.rst +++ b/doc/example_code/sprite_face_left_or_right.rst @@ -11,4 +11,4 @@ Sprite: Face Left or Right .. literalinclude:: ../../arcade/examples/sprite_face_left_or_right.py :caption: sprite_face_left_or_right.py :linenos: - :emphasize-lines: 23-25, 33-45, 51-55 + :emphasize-lines: 23-25, 30-32, 38-42, 67-69, 78 diff --git a/doc/example_code/sprite_move_keyboard.rst b/doc/example_code/sprite_move_keyboard.rst index 91772d97f2..19c767163f 100644 --- a/doc/example_code/sprite_move_keyboard.rst +++ b/doc/example_code/sprite_move_keyboard.rst @@ -13,4 +13,4 @@ Move By Keyboard .. literalinclude:: ../../arcade/examples/sprite_move_keyboard.py :caption: sprite_move_keyboard.py :linenos: - :emphasize-lines: 25-44, 96-97, 99-110, 112-122 + :emphasize-lines: 25-44, 98-99, 101-112, 114-124 diff --git a/doc/example_code/sprite_move_keyboard_accel.rst b/doc/example_code/sprite_move_keyboard_accel.rst index 64969a1d73..3fed5c3199 100644 --- a/doc/example_code/sprite_move_keyboard_accel.rst +++ b/doc/example_code/sprite_move_keyboard_accel.rst @@ -13,4 +13,4 @@ Acceleration and Friction .. literalinclude:: ../../arcade/examples/sprite_move_keyboard_accel.py :caption: sprite_move_keyboard_accel.py :linenos: - :emphasize-lines: 24-31, 43, 46, 50, 53, 128-160 + :emphasize-lines: 24-31, 43, 46, 50, 53, 132-164 diff --git a/doc/example_code/sprite_move_keyboard_better.rst b/doc/example_code/sprite_move_keyboard_better.rst index 302460d6eb..3fa9b18621 100644 --- a/doc/example_code/sprite_move_keyboard_better.rst +++ b/doc/example_code/sprite_move_keyboard_better.rst @@ -22,4 +22,4 @@ See the highlighted sections. .. literalinclude:: ../../arcade/examples/sprite_move_keyboard_better.py :caption: sprite_move_keyboard_better.py :linenos: - :emphasize-lines: 65-69, 96-109, 119-133, 135-149 + :emphasize-lines: 65-69, 98-111, 121-135, 137-151 diff --git a/doc/example_code/sprite_move_scrolling.rst b/doc/example_code/sprite_move_scrolling.rst index 327a4bbd29..06e4960ff7 100644 --- a/doc/example_code/sprite_move_scrolling.rst +++ b/doc/example_code/sprite_move_scrolling.rst @@ -22,4 +22,4 @@ See also :ref:`sprite_move_scrolling_box`. .. literalinclude:: ../../arcade/examples/sprite_move_scrolling.py :caption: sprite_move_scrolling.py :linenos: - :emphasize-lines: 56-59, 96-97, 103-104, 160-161, 163-174, 176-182 + :emphasize-lines: 55-58, 100-101, 107-108, 161-162, 164-176, 178-184 diff --git a/doc/example_code/sprite_move_scrolling_shake.rst b/doc/example_code/sprite_move_scrolling_shake.rst index b4d5d1e80f..8245e98304 100644 --- a/doc/example_code/sprite_move_scrolling_shake.rst +++ b/doc/example_code/sprite_move_scrolling_shake.rst @@ -16,4 +16,4 @@ See the highlighted lines below. .. literalinclude:: ../../arcade/examples/sprite_move_scrolling_shake.py :caption: sprite_move_scrolling_shake.py :linenos: - :emphasize-lines: 154-171 + :emphasize-lines: 58-64, 122, 130-131, 159, 170 diff --git a/doc/example_code/sprite_no_coins_on_walls.rst b/doc/example_code/sprite_no_coins_on_walls.rst index 30340d8d4f..eb94759189 100644 --- a/doc/example_code/sprite_no_coins_on_walls.rst +++ b/doc/example_code/sprite_no_coins_on_walls.rst @@ -13,4 +13,4 @@ Randomly Place Coins, But Away From Walls And Other Coins .. literalinclude:: ../../arcade/examples/sprite_no_coins_on_walls.py :caption: sprite_no_coins_on_walls.py :linenos: - :emphasize-lines: 83-107 + :emphasize-lines: 85-109 diff --git a/doc/example_code/sprite_rotate_around_point.rst b/doc/example_code/sprite_rotate_around_point.rst index 3fe51f5d7b..d07c8fcdf6 100644 --- a/doc/example_code/sprite_rotate_around_point.rst +++ b/doc/example_code/sprite_rotate_around_point.rst @@ -28,4 +28,4 @@ with user input, see :ref:`sprite_rotate_around_tank`. .. literalinclude:: ../../arcade/examples/sprite_rotate_around_point.py :caption: sprite_rotate_around_point.py :linenos: - :emphasize-lines: 30-48, 91-98 + :emphasize-lines: 29-52, 97-106 diff --git a/doc/example_code/sprite_rotate_around_tank.rst b/doc/example_code/sprite_rotate_around_tank.rst index b50616ccf8..ac7d86f679 100644 --- a/doc/example_code/sprite_rotate_around_tank.rst +++ b/doc/example_code/sprite_rotate_around_tank.rst @@ -20,4 +20,4 @@ See the docstring, comments, and on screen instructions for further info. .. literalinclude:: ../../arcade/examples/sprite_rotate_around_tank.py :caption: sprite_rotation_around_tank.py :linenos: - :emphasize-lines: 58-72, 135-160 + :emphasize-lines: 60-75, 143-167 diff --git a/doc/tutorials/card_game/index.rst b/doc/tutorials/card_game/index.rst index 71157e4df4..d4acd835b1 100644 --- a/doc/tutorials/card_game/index.rst +++ b/doc/tutorials/card_game/index.rst @@ -513,7 +513,7 @@ it over: :caption: Flip Up Cards :linenos: :pyobject: MyGame.on_mouse_press - :emphasize-lines: 15-18 + :emphasize-lines: 17-20 Test ~~~~ diff --git a/doc/tutorials/compute_shader/index.rst b/doc/tutorials/compute_shader/index.rst index 92931ba16b..d645673585 100644 --- a/doc/tutorials/compute_shader/index.rst +++ b/doc/tutorials/compute_shader/index.rst @@ -48,7 +48,7 @@ docstrings & comments explain why in greater detail: .. literalinclude:: main.py :language: python :caption: Generating Well-Aligned Data to Load onto the GPU - :lines: 25-70 + :lines: 25-72 Allocating the Buffers ^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ Allocating the Buffers .. literalinclude:: main.py :language: python :caption: Allocating the Buffers & Loading the Data onto the GPU - :lines: 88-116 + :lines: 90-118 Visualization Shaders diff --git a/doc/tutorials/menu/index.rst b/doc/tutorials/menu/index.rst index b8a36a64cc..61dbc1aca1 100644 --- a/doc/tutorials/menu/index.rst +++ b/doc/tutorials/menu/index.rst @@ -204,7 +204,7 @@ later why are those parameters needed. .. literalinclude:: menu_05.py :caption: Editing parameters - :lines: 161-168 + :lines: 187-194 We also need to change accordingly the places where we have used this class i.e options and volume ``on_click`` event listener. The layer parameter being set @@ -212,7 +212,7 @@ options and volume ``on_click`` event listener. The layer parameter being set .. literalinclude:: menu_05.py :caption: Editing arguments - :lines: 115-136 + :lines: 115-162 Now you might be getting a little idea why we have edited the parameters but follow on to actually know the reason. @@ -227,13 +227,13 @@ background color so it appears invisible. .. literalinclude:: menu_05.py :caption: Adding title label - :lines: 193-195 + :lines: 219-221 Adding it to the widget layout. .. literalinclude:: menu_05.py :caption: Adding title label to the layout - :lines: 238-239 + :lines: 269-270 Adding an Input Field @@ -246,13 +246,13 @@ the title label. .. literalinclude:: menu_05.py :caption: Adding input field - :lines: 197 + :lines: 223 Adding it to the widget layout. .. literalinclude:: menu_05.py :caption: Adding input field to the layout - :lines: 240 + :lines: 271 If you paid attention when we defined the ``input_text`` variable we passed the ``text`` parameter with our ``input_text_default`` argument. We basically added @@ -271,14 +271,14 @@ toggle label. .. literalinclude:: menu_05.py :caption: Adding toggle button - :lines: 199-216 + :lines: 225-242 Adding it to the widget layout. Add this line after you have added the input field. .. literalinclude:: menu_05.py :caption: Adding toggle button to the layout - :lines: 241 + :lines: 272 Adding a Dropdown ~~~~~~~~~~~~~~~~~ @@ -287,13 +287,13 @@ We add a dropdown by using :py:class:`~arcade.gui.UIDropdown`. .. literalinclude:: menu_05.py :caption: Adding dropdown - :lines: 219-221 + :lines: 246-252 Adding it to the widget layout. .. literalinclude:: menu_05.py :caption: Adding dropdown to the layout - :lines: 242 + :lines: 273 If a dropdown has many options, it will automatically scroll when the list exceeds the ``max_height`` (default 200px). You can also enable a visible @@ -309,13 +309,13 @@ Theres a functionality to style the slider, this is also present for .. literalinclude:: menu_05.py :caption: Adding slider - :lines: 223-235 + :lines: 254-266 Adding it to the widget layout. .. literalinclude:: menu_05.py :caption: Adding slider to the layout - :lines: 243-244 + :lines: 274-275 Finishing touches ~~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_04.rst b/doc/tutorials/platform_tutorial/step_04.rst index 29fd8d8597..3f7b931956 100644 --- a/doc/tutorials/platform_tutorial/step_04.rst +++ b/doc/tutorials/platform_tutorial/step_04.rst @@ -114,7 +114,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/04_user_control.py :caption: 04_user_control.py - User Control :linenos: - :emphasize-lines: 13-17, 53, 65, 93-121 + :emphasize-lines: 13-17, 55, 67, 95-123 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_05.rst b/doc/tutorials/platform_tutorial/step_05.rst index 25da1727ad..d89e49c520 100644 --- a/doc/tutorials/platform_tutorial/step_05.rst +++ b/doc/tutorials/platform_tutorial/step_05.rst @@ -64,7 +64,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/05_add_gravity.py :caption: 05_add_gravity.py - Add Gravity :linenos: - :emphasize-lines: 18-19, 72-81, 105-123 + :emphasize-lines: 18-19, 74-83, 107-125 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_06.rst b/doc/tutorials/platform_tutorial/step_06.rst index 22d2671912..6ede4a8ce3 100644 --- a/doc/tutorials/platform_tutorial/step_06.rst +++ b/doc/tutorials/platform_tutorial/step_06.rst @@ -52,7 +52,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/06_reset.py :caption: Resetting :linenos: - :emphasize-lines: 33, 36, 39, 47, 49-93, 114-115 + :emphasize-lines: 33, 36, 39, 47, 49-95, 116-117 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_08.rst b/doc/tutorials/platform_tutorial/step_08.rst index e5e3ea0d42..a3132d85c3 100644 --- a/doc/tutorials/platform_tutorial/step_08.rst +++ b/doc/tutorials/platform_tutorial/step_08.rst @@ -63,7 +63,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/08_coins.py :caption: Collecting Coins :linenos: - :emphasize-lines: 15, 50-51, 68, 90-95, 125, 133-141 + :emphasize-lines: 15, 50-51, 70, 92-97, 127, 135-143 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_09.rst b/doc/tutorials/platform_tutorial/step_09.rst index 6f32f32e55..dfd3e797dd 100644 --- a/doc/tutorials/platform_tutorial/step_09.rst +++ b/doc/tutorials/platform_tutorial/step_09.rst @@ -57,7 +57,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/09_sound.py :caption: Load the Map :linenos: - :emphasize-lines: 56-58, 146, 160 + :emphasize-lines: 56-58, 148, 162 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_10.rst b/doc/tutorials/platform_tutorial/step_10.rst index bcd7ee5a89..610644b1f9 100644 --- a/doc/tutorials/platform_tutorial/step_10.rst +++ b/doc/tutorials/platform_tutorial/step_10.rst @@ -101,7 +101,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/10_score.py :caption: Multiple Levels :linenos: - :emphasize-lines: 56-63, 124-131, 149-153, 171-172 + :emphasize-lines: 56-63, 126-133, 151-155, 173-174 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_11.rst b/doc/tutorials/platform_tutorial/step_11.rst index 923eba2cb6..54a39e1ed4 100644 --- a/doc/tutorials/platform_tutorial/step_11.rst +++ b/doc/tutorials/platform_tutorial/step_11.rst @@ -139,7 +139,7 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/11_scene.py :caption: Using a Scene :linenos: - :emphasize-lines: 39-40, 60, 67, 69-70, 78, 90, 97, 106-108, 149-151 + :emphasize-lines: 39-40, 60, 69, 71-72, 80, 92, 99, 108-110, 151-153 Run This Chapter ~~~~~~~~~~~~~~~~ diff --git a/doc/tutorials/platform_tutorial/step_13.rst b/doc/tutorials/platform_tutorial/step_13.rst index cb160c456a..6b2327d068 100644 --- a/doc/tutorials/platform_tutorial/step_13.rst +++ b/doc/tutorials/platform_tutorial/step_13.rst @@ -60,4 +60,4 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/13_more_layers.py :caption: More Layers :linenos: - :emphasize-lines: 70-71, 78-83, 152-156 + :emphasize-lines: 70-75, 84-89, 158-162 diff --git a/doc/tutorials/platform_tutorial/step_14.rst b/doc/tutorials/platform_tutorial/step_14.rst index 5f298ed67f..17cd11f219 100644 --- a/doc/tutorials/platform_tutorial/step_14.rst +++ b/doc/tutorials/platform_tutorial/step_14.rst @@ -90,4 +90,4 @@ Source Code .. literalinclude:: ../../../arcade/examples/platform_tutorial/14_multiple_levels.py :caption: Moving the enemies :linenos: - :emphasize-lines: 57-64, 79-80, 116-119, 173-182 + :emphasize-lines: 57-64, 79-84, 122-125, 180-189 diff --git a/doc/tutorials/pymunk_platformer/index.rst b/doc/tutorials/pymunk_platformer/index.rst index 1a83438565..9d9c62f6c6 100644 --- a/doc/tutorials/pymunk_platformer/index.rst +++ b/doc/tutorials/pymunk_platformer/index.rst @@ -100,7 +100,7 @@ Running this program should show the same window, but with a green background. .. literalinclude:: pymunk_demo_platformer_03.py :caption: Create instance variables :linenos: - :lines: 29-52 + :lines: 30-53 :emphasize-lines: 10-24 * :ref:`pymunk_demo_platformer_03` @@ -179,7 +179,7 @@ First, add some constants for our physics. Here we are setting: .. literalinclude:: pymunk_demo_platformer_05.py :caption: Add Constants for Physics :linenos: - :lines: 27-46 + :lines: 28-47 Second, add the following attributer in the ``__init__`` method to hold our physics engine: @@ -187,7 +187,7 @@ physics engine: .. literalinclude:: pymunk_demo_platformer_05.py :caption: Add Physics Engine Attribute :linenos: - :lines: 71-72 + :lines: 72-73 Third, in the ``setup`` method we create the physics engine and add the sprites. The player, walls, and dynamic items all have different properties so they are @@ -196,14 +196,14 @@ added individually. .. literalinclude:: pymunk_demo_platformer_05.py :caption: Add Sprites to Physics Engine in 'setup' Method :linenos: - :lines: 102-152 + :lines: 105-158 Fourth, in the ``on_update`` method we call the physics engine's ``step`` method. .. literalinclude:: pymunk_demo_platformer_05.py :caption: Add Sprites to Physics Engine in 'setup' Method :linenos: - :lines: 165-167 + :lines: 171-173 If you run the program, and you have dynamic items that are up in the air, you should see them fall when the game starts. @@ -316,7 +316,7 @@ animation, so that the feet appear in-sync with the ground. .. literalinclude:: pymunk_demo_platformer_08.py :caption: Add Player Animation - Constants :linenos: - :lines: 58-66 + :lines: 57-66 Next, we create a ``Player`` class that is a child to :py:class:`~arcade.Sprite`. This class will update the player animation. @@ -350,7 +350,7 @@ replace the line that creates the ``player`` instance with: .. literalinclude:: pymunk_demo_platformer_08.py :caption: Add Player Animation - Creating the Player Class - :lines: 195-196 + :lines: 196-197 A really common mistake I've seen programmers make (and made myself) is to forget that last part. Then you can spend a lot of time looking at the player class when @@ -361,7 +361,7 @@ in our ``__init__`` method: .. literalinclude:: pymunk_demo_platformer_08.py :caption: Add Player Animation - Creating the Player Class - :lines: 159-160 + :lines: 160-161 @@ -381,7 +381,7 @@ too fast. We could set this to zero if we wanted it to not drop at all. .. literalinclude:: pymunk_demo_platformer_09.py :caption: Shoot Bullets - Constants :linenos: - :lines: 68-75 + :lines: 69-76 Next, we'll put in a mouse press handler to put in the bullet shooting code. @@ -439,7 +439,7 @@ it instead of the plain :py:class:`~arcade.Sprite` class. .. literalinclude:: pymunk_demo_platformer_10.py :caption: Destroy Bullets - Bullet Sprite :linenos: - :lines: 315-320 + :lines: 316-321 :emphasize-lines: 1 Handle Collisions @@ -458,7 +458,7 @@ the texture depending on its health. .. literalinclude:: pymunk_demo_platformer_10.py :caption: Destroy Bullets - Collision Handlers :linenos: - :lines: 242-253 + :lines: 243-254 * :ref:`pymunk_demo_platformer_10` @@ -500,13 +500,13 @@ an attribute for ``moving_sprites_list``: .. literalinclude:: pymunk_demo_platformer_11.py :caption: Moving Platforms - Adding the sprite list - :lines: 186 + :lines: 188 In the ``setup`` method, load in the sprite list from the tmx layer. .. literalinclude:: pymunk_demo_platformer_11.py :caption: Moving Platforms - Adding the sprite list - :lines: 230-231 + :lines: 228-229 Also in the ``setup`` method, we need to add these sprites to the physics engine. In this case we'll add the sprites as ``KINEMATIC``. Static sprites don't move. @@ -515,7 +515,7 @@ Kinematic sprites do move, but aren't affected by other objects. .. literalinclude:: pymunk_demo_platformer_11.py :caption: Moving Platforms - Loading the sprites - :lines: 294-296 + :lines: 296-298 We need to draw the moving platform sprites. After adding this line, you should be able to run the program and see the sprites from this layer, even if they don't @@ -547,7 +547,7 @@ so we'll convert. .. literalinclude:: pymunk_demo_platformer_11.py :caption: Moving Platforms - Moving the sprites - :lines: 404-428 + :lines: 406-430 * :ref:`pymunk_demo_platformer_11` * :ref:`pymunk_demo_platformer_11_diff` @@ -567,7 +567,7 @@ to track some more items: :caption: Add Ladders - PlayerSprite class :linenos: :pyobject: PlayerSprite.__init__ - :emphasize-lines: 2, 33-36, 51-52 + :emphasize-lines: 2, 35-38, 53-54 Next, in our ``pymunk_moved`` method we need to change physics when we are on a ladder, and to update our player texture. @@ -582,7 +582,7 @@ climbing textures. :caption: Add Ladders - PlayerSprite class :linenos: :pyobject: PlayerSprite.pymunk_moved - :emphasize-lines: 12-24, 28-43 + :emphasize-lines: 12-24, 28-42 Then we just need to add a few variables to the ``__init__`` to track ladders: @@ -596,14 +596,14 @@ Then load the ladder layer in ``setup``: .. literalinclude:: pymunk_demo_platformer_12.py :caption: Add Ladders - Game Window Setup - :lines: 256-260 + :lines: 261-265 :emphasize-lines: 4 Also, pass the ladder list to the player class: .. literalinclude:: pymunk_demo_platformer_12.py :caption: Add Ladders - Game Window Setup - :lines: 262-263 + :lines: 267-270 Then change the jump button so that we don't jump if we are on a ladder. Also, we want to track if the up key, or down key are pressed. @@ -612,7 +612,7 @@ we want to track if the up key, or down key are pressed. :caption: Add Ladders - Game Window Key Down :linenos: :pyobject: GameWindow.on_key_press - :emphasize-lines: 8-17 + :emphasize-lines: 8-19 Add to the key up handler tracking for which key is pressed. @@ -627,8 +627,9 @@ Next, change our update with new updates for the ladder. .. literalinclude:: pymunk_demo_platformer_12.py :caption: Add Ladders - Game Window On Update :linenos: - :lines: 426-462 - :emphasize-lines: 7, 16, 23-36 + :pyobject: GameWindow.on_update + :lines: 1-41 + :emphasize-lines: 8, 17, 24-37 And, of course, don't forget to draw the ladders: diff --git a/doc/tutorials/raycasting/index.rst b/doc/tutorials/raycasting/index.rst index 9f742f7902..536384a168 100644 --- a/doc/tutorials/raycasting/index.rst +++ b/doc/tutorials/raycasting/index.rst @@ -420,7 +420,7 @@ screen as something for the GUI. :caption: MyGame.__init__ :pyobject: MyGame.__init__ :linenos: - :emphasize-lines: 17-19, 23-24 + :emphasize-lines: 22-24, 28-29 Next up, we need to draw and use the cameras. This complicates our shader as it doesn't care about the scrolling, so we have to pass it a position not affected by the camera position. @@ -430,7 +430,7 @@ Therefore, we subtract it out. :caption: MyGame.on_draw :pyobject: MyGame.on_draw :linenos: - :emphasize-lines: 2-3, 21-27, 39-42 + :emphasize-lines: 2-3, 21-28, 40-43 When we update, we need to scroll the camera to where the user is: diff --git a/doc/tutorials/shader_toy_glow/index.rst b/doc/tutorials/shader_toy_glow/index.rst index baa5fc4029..da10f8c441 100644 --- a/doc/tutorials/shader_toy_glow/index.rst +++ b/doc/tutorials/shader_toy_glow/index.rst @@ -191,7 +191,7 @@ Python program: .. literalinclude:: shadertoy_demo_3.py :caption: Run a shader :linenos: - :emphasize-lines: 17-20 + :emphasize-lines: 16-18 Then we can use those uniforms in our shader: