Click to spawn statues to learn mouse positioning stuff, prep for UI work in order to implement networking

This commit is contained in:
Daniel Flanagan 2024-02-02 10:07:14 -06:00
parent df3c3e989f
commit 458bd994d6
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
3 changed files with 19 additions and 1 deletions

Binary file not shown.

View file

@ -29,6 +29,8 @@ the heavy-lifting for me _plus_ it's a fun excuse to write more Rust.
- In-game editing?
- [ ] Enemies
- [ ] "Position delta" pathfinding
- [ ] Profiling
- Seems to use a lot of resources doing hardly anything
- [ ] Something to slice a tile map into a navigation mesh
- Repeatedly?
- Navmesh may be super overkill and astar may be sufficient?

View file

@ -1,8 +1,9 @@
use bevy::prelude::*;
use bevy::{prelude::*, window::PrimaryWindow};
use crate::{
assets::AssetLoader,
movement::{Heading, Mover, Speed, Velocity},
statue::Statue,
};
const PLAYER_SPEED: f32 = 100.;
@ -44,6 +45,7 @@ fn controls(
mut query: Query<(&mut TextureAtlasSprite, &mut Heading, Entity), With<Player>>,
input: Res<Input<KeyCode>>,
assets: Res<AssetLoader>,
q_windows: Query<&Window, With<PrimaryWindow>>,
) {
let (mut sprite, mut heading, player_entity) = query.single_mut();
**heading = Vec2::ZERO;
@ -58,6 +60,20 @@ fn controls(
.id();
commands.entity(player_entity).push_children(&[child]);
}
KeyCode::Key1 => {
if let Some(position) = q_windows.single().cursor_position() {
let spos = position.extend(0.);
commands.spawn((
Statue,
SpriteSheetBundle {
texture_atlas: assets.images.statue.clone(),
sprite: TextureAtlasSprite::new(0),
transform: Transform::from_translation(spos),
..Default::default()
},
));
}
}
_ => {}
}
}