moonbus: terrain crashing and landing pad winning
This commit is contained in:
parent
0de6755c22
commit
f6b0f717ea
155
moonbus.p8
155
moonbus.p8
@ -4,16 +4,22 @@ __lua__
|
||||
-- MoonBus
|
||||
-- by Dejvino
|
||||
|
||||
plr_alive=1
|
||||
plr_pos={x=5,y=20}
|
||||
plr_alive=true
|
||||
plr_win=false
|
||||
plr_pos={x=5,y=8}
|
||||
plr_speed={x=0.5,y=0}
|
||||
plr_static=false
|
||||
plr_engine=-1
|
||||
|
||||
gravity=0.02
|
||||
engine_power=0.2
|
||||
land_speed_limit=1
|
||||
maph=8
|
||||
cam={}
|
||||
|
||||
function _update()
|
||||
debug_points={}
|
||||
|
||||
-- controlls
|
||||
plr_engine=-1
|
||||
if plr_alive then
|
||||
@ -41,31 +47,47 @@ function _update()
|
||||
end
|
||||
|
||||
-- crash detection
|
||||
local pmaps=mget(plr_pos.x,plr_pos.y-1)
|
||||
local pc=plus(plr_pos,{x=0.5,y=-0.5})
|
||||
if pc.y <= maph then
|
||||
for p in all({plus(pc,clearx(unit(plr_speed,0.4))), plus(pc,cleary(unit(plr_speed,0.4)))}) do
|
||||
local pmaps=mget(p.x,maph-p.y)
|
||||
local target=fget(pmaps,7)
|
||||
local solid=fget(pmaps,0)
|
||||
if solid or plr_pos.y<=0 then
|
||||
add(debug_points,p)
|
||||
if target and dist(plr_speed) < land_speed_limit then
|
||||
plr_win=true
|
||||
plr_speed={x=0,y=0}
|
||||
plr_pos={x=flr(plr_pos.x+0.5),y=flr(plr_pos.y+0.5)}
|
||||
break
|
||||
elseif solid or plr_pos.y<=0 then
|
||||
plr_speed.y*=-0.75
|
||||
plr_alive=0
|
||||
plr_alive=false
|
||||
if (dist(plr_speed) > 1) then
|
||||
sfx(0)
|
||||
--sfx(0)
|
||||
else
|
||||
plr_speed.x=0
|
||||
plr_speed.x=0
|
||||
plr_speed.y=0
|
||||
plr_static=true
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
camera(plr_pos.x*8-60,-56)
|
||||
cam={x=plr_pos.x*8-60, y=0}
|
||||
camera(cam.x,cam.y)
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls()
|
||||
|
||||
map()
|
||||
map(0, 0, 0, 128-maph*8)
|
||||
|
||||
local px,py=to_scrn(plr_pos)
|
||||
local img=0
|
||||
if plr_alive==0 then
|
||||
if plr_win then
|
||||
img=5
|
||||
elseif not plr_alive then
|
||||
img=4
|
||||
elseif plr_engine==⬆️ then
|
||||
img=2
|
||||
@ -75,6 +97,14 @@ function _draw()
|
||||
img=1
|
||||
end
|
||||
spr(img,px,py)
|
||||
|
||||
for p in all(debug_points) do
|
||||
local px,py=to_scrn(p)
|
||||
pset(px,py,8)
|
||||
end
|
||||
|
||||
local p=plr_pos
|
||||
print(p.x.." "..p.y, cam.x, cam.y)
|
||||
end
|
||||
|
||||
function to_scrn(p)
|
||||
@ -84,44 +114,99 @@ function to_scrn(p)
|
||||
end
|
||||
|
||||
function move(p,d,a)
|
||||
a=a or 1
|
||||
p.x+=d.x*a
|
||||
p.y+=d.y*a
|
||||
end
|
||||
function plus(p,d,a)
|
||||
a=a or 1
|
||||
return {
|
||||
x=p.x+d.x*a,
|
||||
y=p.y+d.y*a
|
||||
}
|
||||
end
|
||||
function clearx(p)
|
||||
return {
|
||||
x=0,
|
||||
y=p.y
|
||||
}
|
||||
end
|
||||
function cleary(p)
|
||||
return {
|
||||
x=p.x,
|
||||
y=0
|
||||
}
|
||||
end
|
||||
function mul(p,a)
|
||||
return {
|
||||
x=p.x*a,
|
||||
y=p.y*a
|
||||
}
|
||||
end
|
||||
function neg(p)
|
||||
return mul(p,-1)
|
||||
end
|
||||
|
||||
function dist(p)
|
||||
return abs(p.x) + abs(p.y)
|
||||
end
|
||||
|
||||
function unit(p,u)
|
||||
u=u or 1
|
||||
local x = 0
|
||||
local y = 0
|
||||
if p.x>0 then x=u end
|
||||
if p.x<0 then x=-u end
|
||||
if p.y>0 then y=u end
|
||||
if p.y<0 then y=-u end
|
||||
return {x=x,y=y}
|
||||
end
|
||||
__gfx__
|
||||
000000000000000000000000000000000000aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00a9a90000a9a90000a9a90000a9a90000a9000000a9a90000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00111100001111000011110000111100000100000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
01111110011111100111111001111110010010100111111000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0a9999400a9999400a9999400a9999400a9990400a77654000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
5a9999458a9999455a9999455a999948000909555a7c564500000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
59494445894944455949444559494448594904405967154500000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0055550000555500008888000055550050555500007c560000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66566665000000000000000560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66666666000000000000000666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
56666657000000000000005756600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66756666000000000000066666750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66666666000000000000666666666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66666665006600000006666566666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
65666657076567600066665765666650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
67656666666666566765666667656666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000000000000000000000000000000aa00000000000000b000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00a9a90000a9a90000a9a90000a9a90000a9000000a9a9000000b000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001111000011110000111100001111000001000000111100008bb800000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
01111110011111100111111001111110010010100111111000b00bbb000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0a9999400a9999400a9999400a9999400a9990400a776540bbb00b00000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
5a9999458a9999455a9999455a999948000909555a7c5645008bb800000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
594944458949444559494445594944485949044059671545000b0000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0055550000555500008888000055550050555500007c5600000b0000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66566665000000000000000560000000d8ddddbd0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
666666660000000000000006660000005d7c56d50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
56666657000000000000005756600000566715570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66756666000000000000066666750000667c56660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66666666000000000000666666666000666715660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
66666665006600000006666566666600667c55650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
65666657076567600066665765666650656556570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
67656666666666566765666667656666666566660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000007777777777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000076767676766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000077666666666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000076611161165500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000776d161dd66500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000076666666665500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000076656565656500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000005555555555000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
6460000677c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
545646666611cc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
6555456661d111500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
5455556661dd15650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
65554566666656550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
54555566666565550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
55511166565655500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
11100006555555000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__gff__
|
||||
0000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000001000000810000000000000000000000000100000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__map__
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000111100000000000000001210101300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0012101013000000000000001010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
1210101010130000000000111010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
1010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
1010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000003021213100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000011001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000011110000000000000000000000000000000000001210141000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000111100000000000000001210101300000000000000000000000000000000121010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0012101013000000000000121010101000000000000000000000000000000012101010101013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
1210101010130000000012101010101011001100000000110000000000000010101010101010130011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
1010101010101014141010101010101010101010101010101013110000111210101010101010101010101013110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
1010101010101010101010101010101010101010101010101010101414101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__sfx__
|
||||
000400003665038650396503965039650396503765035650316502f6502c6502965027650226501d65019650166501465012650116500e6500c6500a650076500465001650006500000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
|
Loading…
Reference in New Issue
Block a user