Skip to content

Commit a25f2de

Browse files
committed
fix combat arrow
1 parent c2dd409 commit a25f2de

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: client/src/map_ui.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use itertools::Itertools;
22
use macroquad::math::vec2;
33
use macroquad::prelude::*;
44
use macroquad::ui::Ui;
5+
use std::ops::{Add, Mul, Sub};
56

67
use server::action::Action;
78
use server::combat::Combat;
@@ -94,11 +95,15 @@ fn alpha(game: &Game, state: &State, pos: Position) -> f32 {
9495
fn draw_combat_arrow(c: &Combat) {
9596
let from = hex_ui::center(c.attacker_position);
9697
let to = hex_ui::center(c.defender_position);
97-
draw_line(from.x, from.y, to.x, to.y, 10., BLACK);
98+
let t = vec2(to.x, to.y);
99+
let f = vec2(from.x, from.y);
100+
let e = f.add(t.sub(f).mul(0.7));
101+
draw_line(from.x, from.y, e.x, e.y, 10., BLACK);
102+
let d = f.sub(t).normalize();
98103
draw_triangle(
99-
vec2(to.x, to.y),
100-
vec2(to.x + 30., to.y + 30.),
101-
vec2(to.x - 30., to.y + 30.),
104+
t.add(d.rotate(vec2(10., 0.))),
105+
t.add(d.rotate(vec2(30., 30.))),
106+
t.add(d.rotate(vec2(30., -30.))),
102107
BLACK,
103108
);
104109
}

0 commit comments

Comments
 (0)