This commit is contained in:
James Turk 2023-04-23 03:26:42 -05:00
parent 71871bb700
commit b52ddbcdbc

View File

@ -70,68 +70,70 @@ function draw_ocean()
end
map(player_x-8, player_y-8, 0, 0, 16, 16)
-- DEBUG
print("player: "..player_x..", "..player_y.." heading: "..player_heading)
print("player: "..player_x..", "..player_y.." heading: "..headings[player_heading].name)
print("wind: "..ocean_wind_x..", "..ocean_wind_y)
draw_ship(player_ship, player_heading, 64, 64)
-- hud
rectfill(0, 110, 128, 128, 15)
--pal(4, 132) -- leather
rect(0, 110, 127, 127, 4)
for x=0,128,16 do
line(x, 110, x, 127, 4)
end
palt(1, true)
-- compass
print(headings[player_heading].name, 6, 112, 4)
spr(73, 5, 118)
palt()
--spr_r(9, 4, 120, 120, 1, 1, false, false, 4, 4, headings[player_heading].angle, 1)
--function spr_r(i, j, x, y, w, h, flip_x, flip_y, pivot_x, pivot_y, angle, transparent_color)
end
function update_ocean()
if btn(0) then
player_vx = -1
player_heading = "W"
elseif btn(1) then
player_vx = 1
player_heading = "E"
else
player_vx = 0
end
if btn(2) then
player_vy = -1
player_heading = "N"
elseif btn(3) then
player_vy = 1
player_heading = "S"
else
player_vy = 0
if btnp(0) then
player_heading = (player_heading - 1) % 8
elseif btnp(1) then
player_heading = (player_heading + 1) % 8
end
if t() - last_move_time > 1 and (player_vy or player_vx) then
if t() - last_move_time > 1 then
last_move_time = t()
player_x += player_vx
player_y += player_vy
player_x += headings[player_heading].dx
player_y += headings[player_heading].dy
end
end
_scenes.ocean = {start=start_ocean, draw=draw_ocean, update=update_ocean}
function draw_ship(ship, heading, x, y)
local angle = false
if heading == "N" then
angle = 0
elseif heading == "S" then
angle = 180
end
spr_r(ship.i, ship.j, x-ship.w/2, y-ship.h/2, ship.w*8, ship.h*8, false, false, ship.w*4, ship.h*4, angle, 0)
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)
if ship.w > 1 then
spr(ship.n, x-ship.w*4+8, y-ship.h*4, 1, ship.h, true, flipy)
end
--function spr_r(i, j, x, y, w, h, flip_x, flip_y, pivot_x, pivot_y, angle, transparent_color)
end
-- globals
headings = {
[0]={angle=0, dx=0, dy=-1, name="n"},
{angle=0.825, 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"},
{angle=0.375, dx=-1, dy=1, name="sw"},
{angle=0.25, dx=-1, dy=0, name="w"},
{angle=0.125, dx=-1, dy=-1, name="nw"},
}
ship_type = {
small={i=0, j=32, w=8, h=8, speed=1},
medium={i=8, j=32, w=8, h=16, speed=0.6},
large={i=16, j=32, w=16, h=16, speed=0.4},
ghost={i=24, j=32, w=126, h=24}
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}
}
player_ship = ship_type.small
player_x = 20
player_y = 20
player_vx = 0
player_vy = 0
player_heading = "N"
player_heading = 0
last_move_time = 0
-- external utils
@ -219,14 +221,14 @@ cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
00000000000440000000000400000005000000000000000000000000000000000000000000000000000000001111119111149111111110010000000000000000
00000000004444000000004400000055000000000000000000000000000000000000000000000000000000001111144911149111111100000000000000000000
00044000004444000000044400000556000000000000000000000000000000000000000000000000000000001111994111999911111990000000000000000000
004ff400044ff440000044ff00000566000000000000000000000000000000000000000000000000000000001114491119149191110009010000000000000000
004ff40004f44f4000004fff00005566000000000000000000000000000000000000000000000000000000001999411191149991199009110000000000000000
004ff40004f44f400077777400005566000000000000000000000000000000000000000000000000000000009669111191149119004441110000000000000000
0044440004f44f400004466700005566000000000000000000000000000000000000000000000000000000009669111119149191004941110000000000000000
000000007777777700044ff507777775000000000000000000000000000000000000000000000000000000001991111111999911104441110000000000000000
00000000000440000000000400000005000000000000000000000000000000000000000011555511000000001111119111149111111110010000000000000000
00000000004444000000004400000055000000000000000000000000000000000000000015668651000000001111144911149111111100000000000000000000
00044000004444000000044400000556000000000000000000000000000000000000000056688665000000001111994111999911111990000000000000000000
004ff400044ff440000044ff00000566000000000000000000000000000000000000000056688665000000001114491119149191110009010000000000000000
004ff40004f44f4000004fff00005566000000000000000000000000000000000000000056677665000000001999411191149991199009110000000000000000
004ff40004f44f400077777400005566000000000000000000000000000000000000000056677665000000009669111191149119004441110000000000000000
0044440004f44f400004466700005566000000000000000000000000000000000000000015676651000000009669111119149191004941110000000000000000
000000007777777700044ff507777775000000000000000000000000000000000000000011555511000000001991111111999911104441110000000000000000
00000000077777700777777400077777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000046556400077777700055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f55f400004566500055565000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000