Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions source/chapters/25_sprites_and_walls/step_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@ def setup(self):
self.score = 0

# Create the player
self.player_sprite = arcade.Sprite("images/character.png", SPRITE_SCALING_PLAYER)
self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_adventurer/femaleAdventurer_idle.png", SPRITE_SCALING_PLAYER)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea for this example was to get students to practice downloading and using their own images, rather than the build-in resources.

self.player_sprite.center_x = 50
self.player_sprite.center_y = 64
self.player_list.append(self.player_sprite)

# --- Manually place walls

# Manually create and position a box at 300, 200
wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING_BOX)
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING_BOX)
wall.center_x = 300
wall.center_y = 200
self.wall_list.append(wall)

# Manually create and position a box at 364, 200
wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING_BOX)
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING_BOX)
wall.center_x = 364
wall.center_y = 200
self.wall_list.append(wall)

# --- Place boxes inside a loop
for x in range(173, 650, 64):
wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING_BOX)
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING_BOX)
wall.center_x = x
wall.center_y = 350
self.wall_list.append(wall)
Expand All @@ -82,7 +82,7 @@ def setup(self):

# Loop through coordinates
for coordinate in coordinate_list:
wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING_BOX)
wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING_BOX)
wall.center_x = coordinate[0]
wall.center_y = coordinate[1]
self.wall_list.append(wall)
Expand Down Expand Up @@ -113,14 +113,14 @@ def on_update(self, delta_time):
self.physics_engine.update()

# Scroll the screen to the player
self.scroll_to_player()
#self.scroll_to_player()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is missing. The linked example from the API has the definition.

With the new 3.0, if it ever gets released, has a reworked camera that will change this section again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something I can do to help you with version 3.0 ?


# Scroll the window to the player.
#
# If CAMERA_SPEED is 1, the camera will immediately move to the desired position.
# Anything between 0 and 1 will have the camera move to the location with a smoother
# pan.
CAMERA_SPEED = 1
CAMERA_SPEED = 0.1 # move camera slow
lower_left_corner = (self.player_sprite.center_x - self.width / 2,
self.player_sprite.center_y - self.height / 2)
self.camera_for_sprites.move_to(lower_left_corner, CAMERA_SPEED)
Expand Down