escape from play
This commit is contained in:
parent
3217fbdfbe
commit
ba17c16042
|
@ -1,5 +1,4 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use std::f64::consts::PI;
|
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
|
|
||||||
|
@ -172,18 +171,18 @@ pub fn setup(
|
||||||
|
|
||||||
pub fn player_interact(
|
pub fn player_interact(
|
||||||
keys: Res<ButtonInput<KeyCode>>,
|
keys: Res<ButtonInput<KeyCode>>,
|
||||||
mut player_query: Query<(&mut Player, &mut Transform)>,
|
mut player_query: Query<&mut Player>,
|
||||||
mut game_data: ResMut<GameData>,
|
mut game_data: ResMut<GameData>,
|
||||||
sky: Res<Sky>,
|
sky: Res<Sky>,
|
||||||
text_query: Query<&mut Text, With<AnswerButton>>,
|
text_query: Query<&mut Text, With<AnswerButton>>,
|
||||||
button_query: Query<(&mut BackgroundColor, &mut BorderColor), With<Button>>,
|
button_query: Query<(&mut BackgroundColor, &mut BorderColor), With<Button>>,
|
||||||
constellation_line_query : Query<(Entity, &ConstellationLine)>,
|
constellation_line_query : Query<(Entity, &ConstellationLine)>,
|
||||||
commands: Commands,
|
commands: Commands,
|
||||||
game_state: ResMut<NextState<GameState>>,
|
mut game_state: ResMut<NextState<GameState>>,
|
||||||
meshes: ResMut<Assets<Mesh>>,
|
meshes: ResMut<Assets<Mesh>>,
|
||||||
materials: ResMut<Assets<StandardMaterial>>,
|
materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
let Ok((mut player, mut transform)) = player_query.get_single_mut() else {
|
let Ok(mut player) = player_query.get_single_mut() else {
|
||||||
return
|
return
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -191,16 +190,10 @@ pub fn player_interact(
|
||||||
choose_constellation(&mut player, sky, text_query, button_query, constellation_line_query, commands, game_state, game_data);
|
choose_constellation(&mut player, sky, text_query, button_query, constellation_line_query, commands, game_state, game_data);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut rotation = Quat::IDENTITY;
|
|
||||||
|
|
||||||
if keys.pressed(KeyCode::KeyA) {
|
if keys.just_pressed(KeyCode::Escape) {
|
||||||
rotation *= Quat::from_rotation_y((PI / 60.0) as f32);
|
game_state.set(GameState::Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if keys.pressed(KeyCode::KeyD) {
|
|
||||||
rotation *= Quat::from_rotation_y((-PI / 60.0) as f32);
|
|
||||||
}
|
|
||||||
|
|
||||||
if keys.pressed(KeyCode::KeyI) && game_data.state == PlayerState::Playing {
|
if keys.pressed(KeyCode::KeyI) && game_data.state == PlayerState::Playing {
|
||||||
if let Some(target_cons) = game_data.target_cons_name.clone() {
|
if let Some(target_cons) = game_data.target_cons_name.clone() {
|
||||||
|
@ -210,11 +203,6 @@ pub fn player_interact(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rotation != Quat::IDENTITY {
|
|
||||||
transform.rotation *= rotation;
|
|
||||||
player.target_rotation = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if keys.pressed(KeyCode::KeyR) {
|
if keys.pressed(KeyCode::KeyR) {
|
||||||
if let Some(target_constellation_name) = game_data.target_cons_name.clone() {
|
if let Some(target_constellation_name) = game_data.target_cons_name.clone() {
|
||||||
let mut target_constellation = sky.content[0].clone();
|
let mut target_constellation = sky.content[0].clone();
|
||||||
|
|
Loading…
Reference in a new issue