moonbus: looping map
This commit is contained in:
parent
d3e22bf35a
commit
0f366ae64a
13
moonbus.p8
13
moonbus.p8
@ -83,6 +83,7 @@ function _update()
|
|||||||
|
|
||||||
-- move objects
|
-- move objects
|
||||||
move(plr_pos,plr_speed,0.1)
|
move(plr_pos,plr_speed,0.1)
|
||||||
|
plr_pos.x=plr_pos.x%128
|
||||||
|
|
||||||
-- gravity pull
|
-- gravity pull
|
||||||
if not plr_static then
|
if not plr_static then
|
||||||
@ -139,6 +140,8 @@ function _draw()
|
|||||||
|
|
||||||
camera(cam.x,cam.y)
|
camera(cam.x,cam.y)
|
||||||
map(0, 0, 0, 128-maph*8)
|
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 px,py=to_scrn(plr_pos)
|
||||||
local img=0
|
local img=0
|
||||||
@ -164,8 +167,14 @@ function _draw()
|
|||||||
|
|
||||||
-- target
|
-- target
|
||||||
if plr_alive then
|
if plr_alive then
|
||||||
local tx,ty=to_scrn(plr_target)
|
local tg={x=plr_target.x,y=plr_target.y}
|
||||||
local dst=dist(plr_pos,plr_target)
|
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
|
local c=flr(t())%2==0 and 3 or 11
|
||||||
if dst > 8 then
|
if dst > 8 then
|
||||||
local dir=atan2(tx-px,ty-py)
|
local dir=atan2(tx-px,ty-py)
|
||||||
|
Loading…
Reference in New Issue
Block a user