Fixed radar arrow

master
Mark 2024-01-14 11:10:04 -08:00
parent 129b134114
commit 7e41383ea9
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
1 changed files with 4 additions and 6 deletions

View File

@ -294,11 +294,9 @@ impl Radar {
let q = Point2::new(0.0, 0.0) - self.last_player_position; let q = Point2::new(0.0, 0.0) - self.last_player_position;
let m = q.magnitude(); let m = q.magnitude();
if m > 200.0 { if m > 200.0 {
let player_angle = q.angle(&Vector2::new(0.0, 1.0)); let angle = clockwise_angle(&Vector2::new(1.0, 0.0), &q);
let position = Point2::new(10.0 + (radar_size / 2.0), -10.0 - (radar_size / 2.0))
let position: Point2<f32> = + Rotation2::new(angle) * Vector2::new(0.915 * (radar_size / 2.0), 0.0);
Point2::new(radar_size / 2.0 + 10.0, radar_size / -2.0 - 10.0)
+ ((q.normalize() * 0.865) * (radar_size / 2.0));
if state.vertex_buffers.ui_counter as u64 > UI_SPRITE_INSTANCE_LIMIT { if state.vertex_buffers.ui_counter as u64 > UI_SPRITE_INSTANCE_LIMIT {
// TODO: no panic, handle this better. // TODO: no panic, handle this better.
@ -311,7 +309,7 @@ impl Radar {
bytemuck::cast_slice(&[UiInstance { bytemuck::cast_slice(&[UiInstance {
anchor: PositionAnchor::NwC.to_int(), anchor: PositionAnchor::NwC.to_int(),
position: position.into(), position: position.into(),
angle: -player_angle, angle,
size: 10.0, size: 10.0,
color: [1.0, 1.0, 1.0, 1f32.min((m - 200.0) / 400.0)], color: [1.0, 1.0, 1.0, 1f32.min((m - 200.0) / 400.0)],
sprite_index: arrow_sprite.get_index(), sprite_index: arrow_sprite.get_index(),