collision
This commit is contained in:
parent
51d19fe4bf
commit
b9ed0866d6
@ -107,26 +107,33 @@ function update_ocean()
|
||||
player_heading = (player_heading + 1) % 8
|
||||
end
|
||||
|
||||
if t() - last_move_time > 1 then
|
||||
last_move_time = t()
|
||||
player_x += headings[player_heading].dx
|
||||
player_y += headings[player_heading].dy
|
||||
if t() - last_move_time > player_ship.speed then
|
||||
local new_x = player_x + headings[player_heading].dx
|
||||
local new_y = player_y + headings[player_heading].dy
|
||||
local blocked = false
|
||||
blocked = fget(mget(new_x, new_y), 0)
|
||||
if not blocked then
|
||||
player_x = new_x
|
||||
player_y = new_y
|
||||
last_move_time = t()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
_scenes.ocean = {start=start_ocean, draw=draw_ocean, update=update_ocean}
|
||||
|
||||
function draw_ship(ship, heading, x, y)
|
||||
spr_r(ship.i, ship.j, x-ship.w*4, y-ship.h*4, ship.w, ship.h, false, false, ship.w*4, ship.h*4, headings[heading].angle, 0)
|
||||
spr_r(ship.i, ship.j, x-ship.w*4, y-ship.h*4, 1, ship.h, false, false, ship.w*4, ship.h*4, headings[heading].angle, 0)
|
||||
if ship.w > 1 then
|
||||
spr(ship.n, x-ship.w*4+8, y-ship.h*4, 1, ship.h, true, flipy)
|
||||
spr_r(ship.i, ship.j, x-ship.w*4, y-ship.h*4, 1, ship.h, true, false, ship.w*4, ship.h*4, headings[heading].angle, 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- globals
|
||||
headings = {
|
||||
[0]={angle=0, dx=0, dy=-1, name="n"},
|
||||
{angle=0.825, dx=1, dy=-1, name="ne"},
|
||||
{angle=0.875, dx=1, dy=-1, name="ne"},
|
||||
{angle=0.75, dx=1, dy=0, name="e"},
|
||||
{angle=0.625, dx=1, dy=1, name="se"},
|
||||
{angle=0.5, dx=0, dy=1, name="s"},
|
||||
@ -138,9 +145,9 @@ ship_type = {
|
||||
small={i=0, j=4, w=1, h=1, speed=1},
|
||||
medium={i=1, j=4, w=1, h=2, speed=0.6},
|
||||
large={i=2, j=4, w=2, h=2, speed=0.4},
|
||||
ghost={i=3, j=4, w=3, h=3}
|
||||
ghost={i=3, j=4, w=2, h=3}
|
||||
}
|
||||
player_ship = ship_type.small
|
||||
player_ship = ship_type.large
|
||||
player_x = 20
|
||||
player_y = 20
|
||||
player_heading = 0
|
||||
@ -329,6 +336,9 @@ cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
71717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171
|
||||
71717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171
|
||||
__gff__
|
||||
0000000000000000000001010101010100010001010101010101010101010101000101000101020301010101010000000001000101010202010100000000000002020202000000000000000000000000020202020000000000000000000000000000020200000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__map__
|
||||
2727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727
|
||||
37373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737292727272727272727272727272a3737373737373737373737373737373737373737373737373737373737
|
||||
|
Loading…
Reference in New Issue
Block a user