From 70c83295ca3b2c31f977ed0130882b54b9c052ac Mon Sep 17 00:00:00 2001 From: yuni Date: Mon, 18 Nov 2024 04:14:17 +0100 Subject: [PATCH] time travel: add random offsets to target that increase with difficulty --- src/game.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/game.rs b/src/game.rs index 612e0ba..9ec7c5b 100644 --- a/src/game.rs +++ b/src/game.rs @@ -17,6 +17,7 @@ use bevy::prelude::*; use bevy::scene::SceneInstance; use bevy::window::{PrimaryWindow, Window, WindowMode}; use bevy_xpbd_3d::prelude::*; +use fastrand; use std::collections::HashMap; pub const CHEAT_WARP_1: &str = "pizzeria"; @@ -770,8 +771,14 @@ fn handle_race( if spawn_target { 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); 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_v = *player_v; *target_vis = Visibility::Inherited;