From b17d324c0505fced6542f9a6c7bde33f79fd3d8b Mon Sep 17 00:00:00 2001 From: Christian Engen Date: Sat, 22 Jul 2023 08:21:04 +0200 Subject: [PATCH] add finite ammo --- assets/textures/icons.png | Bin 0 -> 96 bytes src/game/components.rs | 2 ++ src/game/mod.rs | 3 ++- src/game/systems.rs | 37 +++++++++++++++++++++++++++++++++---- src/main.rs | 2 ++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 assets/textures/icons.png diff --git a/assets/textures/icons.png b/assets/textures/icons.png new file mode 100644 index 0000000000000000000000000000000000000000..1e0d10e042f2965827752752873f81709b31f6e2 GIT binary patch literal 96 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|q&!_5LnNjq qCn&K0X=h>s0<}#gm!l^MFfiOo5r2KQ`Oq$)Dh5wiKbLh*2~7aOr5JJm literal 0 HcmV?d00001 diff --git a/src/game/components.rs b/src/game/components.rs index e4cf242..88fcf0b 100644 --- a/src/game/components.rs +++ b/src/game/components.rs @@ -188,3 +188,5 @@ pub struct Foreground; pub struct TextColor; #[derive(Component)] pub struct DropBombTimer(pub Timer); +#[derive(Component)] +pub struct MissileReserve(pub usize); diff --git a/src/game/mod.rs b/src/game/mod.rs index 87a9c7f..db91998 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -8,7 +8,7 @@ use self::{ effects::{flick_system, timed_removal_system}, prelude::stage_colors, systems::{ - animate_sprite_indices, animate_sprite_steps, change_colors, drop_bombs, + ammo_ui, animate_sprite_indices, animate_sprite_steps, change_colors, drop_bombs, explosion_event_listener_system, explosion_system, flame_engulf_system, game_keys, game_over_ui, gizmo_missile_trails, health_ui, missile_arrival_event_listner, move_cursor, move_missile, move_ufo, reset_game_listener, rotate_player, score_ui, setup_player, @@ -39,6 +39,7 @@ impl Plugin for GamePlugin { animate_sprite_steps, animate_sprite_indices, score_ui, + ammo_ui, ) .run_if(in_state(GameState::InGame).or_else(in_state(GameState::GameOver))), // run these systems if we are in the InGame state diff --git a/src/game/systems.rs b/src/game/systems.rs index 6dfb8ea..44e8034 100644 --- a/src/game/systems.rs +++ b/src/game/systems.rs @@ -14,8 +14,8 @@ use super::{ AnimationIndices, AnimationStep, AnimeRemoveOnFinish, Cannon, CannonBase, ChainedMeta, Cursor, DropBombTimer, Enemy, EnemySpawn, Engulfable, Explodable, Explosion, ExplosionEvent, ExplosionMode, FlameRadius, Foreground, Health, IdCounter, Missile, - MissileArrivalEvent, Player, Score, Scoring, SpawnPoint, SplitTimer, Stepper, TargetLock, - Ufo, DROP_BOMB_CHANCE, MAX_SPLIT, PLAYER_MISSILE_SPEED, SPLIT_CHANCE, + MissileArrivalEvent, MissileReserve, Player, Score, Scoring, SpawnPoint, SplitTimer, + Stepper, TargetLock, Ufo, DROP_BOMB_CHANCE, MAX_SPLIT, PLAYER_MISSILE_SPEED, SPLIT_CHANCE, }, effects::{Flick, TimedRemoval}, prelude::{color_from_vec, Stage, StageHandle}, @@ -28,7 +28,7 @@ pub fn game_keys( mut id_counter: ResMut, mut commands: Commands, images: Res, - player: Query<(Entity, With)>, + mut player: Query<((Entity, &mut MissileReserve), With)>, mut cannon_base: Query< (Entity, &mut Transform, Has), (With, Without), @@ -36,7 +36,7 @@ pub fn game_keys( time: Res