time travel: add random offsets to target that increase with difficulty

This commit is contained in:
yuni 2024-11-18 04:14:17 +01:00
parent d856c8487a
commit 70c83295ca

View file

@ -17,6 +17,7 @@ use bevy::prelude::*;
use bevy::scene::SceneInstance; use bevy::scene::SceneInstance;
use bevy::window::{PrimaryWindow, Window, WindowMode}; use bevy::window::{PrimaryWindow, Window, WindowMode};
use bevy_xpbd_3d::prelude::*; use bevy_xpbd_3d::prelude::*;
use fastrand;
use std::collections::HashMap; use std::collections::HashMap;
pub const CHEAT_WARP_1: &str = "pizzeria"; pub const CHEAT_WARP_1: &str = "pizzeria";
@ -770,8 +771,14 @@ fn handle_race(
if spawn_target { if spawn_target {
race.timeout = time.elapsed_seconds_f64() + 5.0; race.timeout = time.elapsed_seconds_f64() + 5.0;
let difficulty = 2.0 * race.score as f64;
let mut delta = DVec3::new(0.0, 0.0, 100.0); let mut delta = DVec3::new(0.0, 0.0, 100.0);
delta = (player_trans.rotation * delta.as_vec3()).as_dvec3(); delta = (player_trans.rotation * delta.as_vec3()).as_dvec3();
delta += DVec3::new(
(fastrand::f64() - 0.5) * difficulty,
(fastrand::f64() - 0.5) * difficulty,
(fastrand::f64() - 0.5) * difficulty,
);
*target_pos = Position(player_pos.0 + delta); *target_pos = Position(player_pos.0 + delta);
*target_v = *player_v; *target_v = *player_v;
*target_vis = Visibility::Inherited; *target_vis = Visibility::Inherited;