| 1 |
// |
| 2 |
// Copyright(C) 2022 by Ryan Krafnick |
| 3 |
// |
| 4 |
// This program is free software; you can redistribute it and/or |
| 5 |
// modify it under the terms of the GNU General Public License |
| 6 |
// as published by the Free Software Foundation; either version 2 |
| 7 |
// of the License, or (at your option) any later version. |
| 8 |
// |
| 9 |
// This program is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
// |
| 14 |
// DESCRIPTION: |
| 15 |
// DSDA Line Distance Tracker HUD Component |
| 16 |
// |
| 17 |
|
| 18 |
#include "base.h" |
| 19 |
|
| 20 |
#include "line_distance_tracker.h" |
| 21 |
|
| 22 |
void dsda_LineDistanceTrackerHC(char* str, size_t max_size, int id) { |
| 23 |
line_t* line; |
| 24 |
mobj_t* mo; |
| 25 |
double distance; |
| 26 |
double radius; |
| 27 |
|
| 28 |
line = &lines[id]; |
| 29 |
mo = players[displayplayer].mo; |
| 30 |
radius = (double) mo->radius / FRACUNIT; |
| 31 |
distance = dsda_DistancePointToLine(line->v1->x, line->v1->y, line->v2->x, line->v2->y, |
| 32 |
mo->x, mo->y); |
| 33 |
|
| 34 |
snprintf( |
| 35 |
str, |
| 36 |
max_size, |
| 37 |
"%sld %d: %.03f", |
| 38 |
distance < radius ? dsda_TextColor(dsda_tc_exhud_line_close) : |
| 39 |
dsda_TextColor(dsda_tc_exhud_line_far), |
| 40 |
id, |
| 41 |
distance |
| 42 |
); |
| 43 |
} |