@@ -9,6 +9,8 @@ local symbols = require("dsda.symbols")
99
1010local FRACBITS <const> = 16
1111local FRACUNIT <const> = 1 << FRACBITS
12+ local ANGLE_90 <const> = 0x40000000
13+ local ANGLES <const> = 64 -- byte type for now
1214local MINIMAL_ZOOM <const> = 0.0001 -- ???
1315local ZOOM_FACTOR <const> = 0.01
1416local WHEEL_ZOOM_FACTOR <const> = 10
@@ -21,7 +23,7 @@ local MAP_CLICK_BLOCK <const> = "P1 Fire" -- prevent this input while clicking
2123
2224-- Map colors (0xAARRGGBB or "name")
2325local MapPrefs = {
24- player = { color = 0xff60a0ff , radius_min_zoom = 0.00 , text_min_zoom = 0.20 , },
26+ player = { color = 0xff60d0ff , radius_min_zoom = 0.00 , text_min_zoom = 0.20 , },
2527 enemy = { color = 0xffff0000 , radius_min_zoom = 0.00 , text_min_zoom = 0.25 , },
2628 enemy_idle = { color = 0xffaa0000 , radius_min_zoom = 0.00 , text_min_zoom = 0.25 , },
2729-- corpse = { color = 0xaaaaaaaa, radius_min_zoom = 0.00, text_min_zoom = 0.75, },
@@ -433,9 +435,33 @@ local function iterate_players()
433435 --]] --
434436 for i , player in Globals :iterate_players () do
435437 Players [i ] = {
436- x = player .mo .x ,
437- y = player .mo .y
438+ x = player .mo .x / FRACUNIT ,
439+ y = player .mo .y / FRACUNIT ,
440+ z = player .mo .z / FRACUNIT ,
441+ prevx = player .mo .PrevX / FRACUNIT ,
442+ prevy = player .mo .PrevY / FRACUNIT ,
443+ prevz = player .mo .PrevZ / FRACUNIT ,
444+ momx = player .mo .momx / FRACUNIT ,
445+ momy = player .mo .momy / FRACUNIT ,
446+ angle = math.floor (player .mo .angle * (ANGLES / ANGLE_90 ))
438447 }
448+
449+ Players [i ].distx = Players [i ].x - Players [i ].prevx
450+ Players [i ].disty = Players [i ].y - Players [i ].prevy
451+ Players [i ].distz = Players [i ].z - Players [i ].prevz
452+ Players [i ].distmoved = math.sqrt (
453+ Players [i ].distx * Players [i ].distx +
454+ Players [i ].disty * Players [i ].disty )
455+
456+ if Players [i ].distx == 0 and Players [i ].disty == 0 then
457+ Players [i ].dirmoved = 0
458+ else
459+ local angle = math.atan (Players [i ].distx / Players [i ].disty ) * 180 / math.pi - 90
460+ if Players [i ].disty >= 0
461+ then Players [i ].dirmoved = - angle
462+ else Players [i ].dirmoved = - angle + 180
463+ end
464+ end
439465 --[[ --
440466 playercount = playercount + 1
441467 local killcount = player.killcount
@@ -466,11 +492,30 @@ local function iterate()
466492 local closest_line
467493 local selected_sector
468494 local texts = {}
495+ local player = select (2 , next (Players )) -- first present player only for now
469496 local mousePos = client .transformPoint (Mouse .X , Mouse .Y )
470497 local gameMousePos = screen_to_game (mousePos )
471498 local screenwidth = client .screenwidth ()
472499 local screenheight = client .screenheight ()
473500 local shortest_dist = math.maxinteger
501+
502+ texts .player = string.format (
503+ " X: %.5f\n Y: %.5f\n Z: %.2f\n " ..
504+ " distX: %.5f\n distY: %.5f\n distZ: %.2f\n " ..
505+ " momX: %.5f\n momY: %.5f\n " ..
506+ " distM: %f\n dirM: %f\n angle: %d" ,
507+ player .x ,
508+ player .y ,
509+ player .z ,
510+ player .distx ,
511+ player .disty ,
512+ player .distz ,
513+ player .momx ,
514+ player .momy ,
515+ player .distmoved ,
516+ player .dirmoved ,
517+ player .angle
518+ )
474519
475520 for i , line in ipairs (Lines ) do
476521 local color = 0xffffffff
@@ -527,11 +572,10 @@ local function iterate()
527572
528573 if closest_line then
529574 local x1 , y1 , x2 , y2 = cached_line_coords (closest_line )
530- local pos = select (2 , next (Players ))
531575 local distance = distance_from_line (
532- { x = pos .x / FRACUNIT , y = pos .y / FRACUNIT },
533- { x = x1 / FRACUNIT , y = y1 / FRACUNIT },
534- { x = x2 / FRACUNIT , y = y2 / FRACUNIT }
576+ { x = player .x / FRACUNIT , y = player .y / FRACUNIT },
577+ { x = x1 / FRACUNIT , y = y1 / FRACUNIT },
578+ { x = x2 / FRACUNIT , y = y2 / FRACUNIT }
535579 )
536580
537581 x1 , y1 , x2 , y2 = game_to_screen (x1 , y1 , x2 , y2 )
@@ -593,16 +637,18 @@ local function iterate()
593637 text (
594638 pos .x - screen_radius + 1 ,
595639 pos .y - screen_radius ,
596- string.format (" %d" , index ), text_color )
640+ string.format (" %d" , index ),
641+ text_color )
597642 end
598643 end
599644 end
600645 end
601646
602- box (0 , 0 , PADDING_WIDTH , screenheight , 0xb0000000 , 0xb0000000 )
647+ box (0 , 0 , PADDING_WIDTH , screenheight , 0xb0000000 , 0xb0000000 )
648+ text (10 , 42 , texts .player , MapPrefs .player .color )
603649
604- if texts .thing then text (10 , 208 , texts .thing ) end
605- if texts .line then text (10 , 314 , texts .line , 0xffff8800 ) end
650+ if texts .thing then text (10 , 222 , texts .thing ) end
651+ if texts .line then text (10 , 320 , texts .line , 0xffff8800 ) end
606652 if texts .sector then text (10 , 370 , texts .sector , 0xff00ffff ) end
607653
608654-- text(50,10,shortest_dist/FRACUNIT)
0 commit comments