moonbus: looping map

This commit is contained in:
Dejvino 2024-08-09 22:05:42 +02:00
parent d3e22bf35a
commit 0f366ae64a

View File

@ -83,6 +83,7 @@ function _update()
-- move objects
move(plr_pos,plr_speed,0.1)
plr_pos.x=plr_pos.x%128
-- gravity pull
if not plr_static then
@ -139,6 +140,8 @@ function _draw()
camera(cam.x,cam.y)
map(0, 0, 0, 128-maph*8)
map(0, 0, -128*8, 128-maph*8)
map(0, 0, 128*8, 128-maph*8)
local px,py=to_scrn(plr_pos)
local img=0
@ -164,8 +167,14 @@ function _draw()
-- target
if plr_alive then
local tx,ty=to_scrn(plr_target)
local dst=dist(plr_pos,plr_target)
local tg={x=plr_target.x,y=plr_target.y}
if plr_target.x-plr_pos.x>64 then
tg.x-=128
elseif plr_target.x-plr_pos.x<-64 then
tg.x+=128
end
local tx,ty=to_scrn(tg)
local dst=dist(plr_pos,tg)
local c=flr(t())%2==0 and 3 or 11
if dst > 8 then
local dir=atan2(tx-px,ty-py)