feat: stone cannon sprite and rework

This commit is contained in:
Muhammad Nauman Raza 2024-03-19 21:04:44 +00:00
parent d2c5e0944c
commit 65d2d997b1
Signed by: devraza
GPG key ID: 91EAD6081011574B

View file

@ -75,14 +75,17 @@ pub fn attack(
mut commands: Commands,
asset_server: Res<AssetServer>,
) {
for player_transform in set.p1().iter_mut() {
let attack_position = player_transform.translation + ((player_transform.rotation * Vec3::Y) * 50.);
if keys.just_pressed(KeyCode::Enter) {
commands
.spawn(SpriteBundle {
texture: asset_server.load("player/player-4x.png"),
texture: asset_server.load("attacks/stone_cannon.png"),
transform: Transform {
scale: Vec3::splat(0.1),
translation: player_transform.translation,
scale: Vec3::splat(0.2),
translation: attack_position,
rotation: player_transform.rotation,
},
..default()
@ -96,7 +99,7 @@ pub fn attack(
for mut attack_transform in set.p0().iter_mut() {
let direction = attack_transform.rotation * Vec3::Y;
attack_transform.translation += direction * 10.;
attack_transform.translation += direction * 20.;
}
}