From 0f366ae64a17e0dd283d14c478a17a7091c76fdd Mon Sep 17 00:00:00 2001 From: Dejvino Date: Fri, 9 Aug 2024 22:05:42 +0200 Subject: [PATCH] moonbus: looping map --- moonbus.p8 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/moonbus.p8 b/moonbus.p8 index 0ec1a16..a1e1da5 100644 --- a/moonbus.p8 +++ b/moonbus.p8 @@ -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)