Adds a player lives system with respawning and temporary invincibility. - Introduces resource (starts at 3). - Modifies player-enemy collision to decrement lives and despawn player. - Implements for delayed respawn. - Adds component with a timer for post-respawn protection, including a blinking visual effect. - Updates window title dynamically to show remaining lives. Reverted collision detection from (due to build errors) back to using . Fixed several borrow checker (E0499, E0596) and type mismatch (E0308) errors encountered during implementation, primarily within the system. Added conditions for systems like shooting, collision checking, and respawning. Updates README.md to reflect the current state and completed TODO item.
4.8 KiB
4.8 KiB
bglga
This project is a simple Galaga-like space shooter game built using the Bevy engine.
Current State
The game features:
- A player ship at the bottom of the screen that can move left and right
- Shooting bullets upward using the spacebar or up arrow key
- Enemy ships that spawn at the top and move downward
- Collision detection between bullets and enemies
Controls
- Move Left: A key or Left Arrow
- Move Right: D key or Right Arrow
- Shoot: Spacebar or Up Arrow
How to Compile
nix develop --command bash -c "cargo build"
How to Run
- Make sure you have Rust and Nix installed.
- Clone the repository.
- Navigate to the project directory.
- Run the game using the command:
nix develop --command bash -c "cargo run"
TODO
1. Core Gameplay Loop & State Management:
- Player Lives:
- Add a
PlayerLives
resource (e.g., starting with 3). - Modify
check_player_enemy_collisions
: Instead of just printing, decrement the lives count. - Implement player destruction (despawn the player sprite) and respawn logic (maybe after a short delay, with temporary invincibility).
- Add a
- Game Over State:
- Use Bevy's
States
(e.g.,Playing
,GameOver
). - Transition to
GameOver
whenPlayerLives
reaches zero. - In the
GameOver
state: stop enemy spawning, stop player controls, display a "Game Over" message (usingbevy_ui
), potentially offer a restart option.
- Use Bevy's
- Scoring:
- Add a
Score
resource. - Increment the score in
check_bullet_collisions
when an enemy is hit. - Consider different point values for different enemy types or hitting enemies during dives later.
- Add a
- Levels/Stages:
- Add a
CurrentStage
resource. - Define criteria for clearing a stage (e.g., destroying all enemies in a wave/formation).
- Implement logic to advance to the next stage, potentially increasing difficulty (enemy speed, firing rate, different formations).
- Add a
2. Enemy Behavior - Formations & Attack Patterns:
- Enemy Formations: This is a core Galaga feature.
- Define target positions for the enemy formation on screen.
- Give enemies an
Entering
state/component: They fly onto the screen following predefined paths (curves, waypoints). - Give enemies a
Formation
state/component: Once they reach their target position, they stop and hold formation.
- Enemy Attack Dives:
- Give enemies an
Attacking
state/component. - Periodically trigger enemies in the formation to switch to the
Attacking
state. - Define attack paths (swooping dives towards the player area).
- Make enemies fire bullets (downwards or towards the player) during their dives.
- After an attack dive, enemies could return to their formation position or fly off-screen.
- Give enemies an
- Enemy Variety:
- Introduce different types of enemies (e.g., using different components or an enum).
- Assign different behaviors, point values, and maybe sprites to each type.
3. Advanced Galaga Mechanics:
- Boss Galaga & Capture Beam:
- Create a "Boss" enemy type.
- Implement the tractor beam attack (visual effect, player capture logic).
- Player needs a
Captured
state. - Logic for the Boss to return captured ships to the formation.
- Dual Fighter (Rescuing Captured Ship):
- Allow the player to shoot a Boss Galaga attempting to capture or one holding a captured ship.
- Implement the logic to free the captured ship.
- Implement the dual fighter mode (controlling two ships, firing two bullets). This involves significant changes to player control and shooting systems.
- Challenging Stages:
- Implement a special stage type (e.g., every few levels).
- Enemies fly in intricate patterns without shooting.
- Award bonus points for destroying all enemies in the stage.
4. Polish and User Interface:
- Visuals:
- Replace placeholder shapes with actual sprites using
SpriteBundle
orSpriteSheetBundle
. Create distinct looks for the player, different enemy types, bullets. - Add explosion effects/animations when enemies or the player are destroyed.
- Implement a scrolling starfield background for a more classic space feel.
- Replace placeholder shapes with actual sprites using
- Audio:
- Integrate
bevy_audio
. - Add sound effects for player shooting, enemy firing, explosions, player death, capturing, etc.
- Add background music that might change per stage or state (e.g., main gameplay vs. challenging stage).
- Integrate
- UI:
- Use
bevy_ui
to display the current Score, Lives remaining, and Stage number on screen during gameplay. - Display High Score?
- Create a Start Menu state.
- Use
Starting with the Core Gameplay Loop (Lives, Game Over, Score, basic Stages) and then moving onto Enemy Formations and Attack Patterns would likely provide the biggest steps towards a Galaga feel.