combat system

This commit is contained in:
Jim 2025-08-24 19:45:33 -04:00
parent 928faf9570
commit f5d022d1d0
Signed by: jim
GPG key ID: 3236D2F059A7C0AC
8 changed files with 150 additions and 10 deletions

View file

@ -5,9 +5,11 @@ edition = "2024"
[dependencies]
bevy = { workspace = true }
avian3d = { workspace = true }
state = { path = "../state" }
camera = { path = "../camera" }
avian3d = { workspace = true }
combat = { path = "../combat" }
[lints]
workspace = true

View file

@ -10,6 +10,7 @@ use bevy::{
render::camera::Exposure,
};
use camera::ControlledCamera;
use combat::{Attacked, Defense, Health};
use state::AppState;
pub struct LevelPlugin;
@ -53,12 +54,20 @@ fn setup(
..default()
})),
Transform::from_xyz(0.0, y as f32 * 1.1, 0.0),
Health::new(5.0),
Defense::new(y as f32 - 5.0),
))
.observe(
|trigger: Trigger<Pointer<Click>>, mut query: Query<&mut LinearVelocity>| {
|trigger: Trigger<Pointer<Click>>,
mut query: Query<&mut LinearVelocity>,
mut commands: Commands| {
if let Ok(mut v) = query.get_mut(trigger.target()) {
v.y += 3.0;
v.y += 5.0;
}
commands.entity(trigger.target()).trigger(Attacked {
attacker: None,
amount: 8.,
});
},
);
}