-
Notifications
You must be signed in to change notification settings - Fork 37
Update step_5.py make program work directly from the book #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
| 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) | ||
|
|
@@ -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) | ||
|
|
@@ -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() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
There was a problem hiding this comment.
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.