Exercises
Don't forget to checkout the branch:
git checkout 06-basic-game
Let's review what was changed: https://github.com/vleue/bevy_workshop-rustweek-2025/compare/05-intro-to-bevy..06-basic-game
Displaying an Asteroid
File meteorBrown_big1.png has a sprite for an asteroid. Use it instead of the blue box.
Tips:
- Add a new field to the
GameAssetsresource for the asteroid
Player Sprite Animation
Display engine jets behind the ship when moving forward.
Tips:
- Load the new sprite in
GameAssets.fire07.pngis a good sprite for jets - Spawn the jets as children sprite of the player entity with the
children!macro- Make it invisible with the
Visibility::Hiddencomponent - A good starting position is
Vec3::new(0.0, -40.0, 0.0)
- Make it invisible with the
- Toggle sprite visibility when the ship moves forward, when the player presses the
Wkey- You can get children of an entity with the
Childrencomponent - Add a new query to the
control_playerthat can modify theVisibilitycomponent - When
Wis pressed, query theVisibilitycomponent of the first child of thePlayerentity
- You can get children of an entity with the
Player Acceleration
In space, there's no friction. Pressing W should make the ship accelerate in a direction, and movements should continue after the key is released.
Tips:
- Store the player velocity in a new component
- When the
Wkey is pressed, change the velocity - In a separate system, move the player according to its current velocity