experiments-pico8/games/ocean.p8

174 lines
11 KiB
Plaintext
Raw Normal View History

2023-04-16 23:24:50 +00:00
pico-8 cartridge // http://www.pico-8.com
version 41
__lua__
--
function _init()
start_scene("title")
end
function _update()
if _scene and _scene.update then
_scene.update()
end
end
function _draw()
if _scene and _scene.draw then
_scene.draw()
end
end
function start_scene(name)
_scene = _scenes[name]
_scene_start = time()
if _scene.start then
_scene.start()
end
end
function scene_time()
return time() - _scene_start
end
_scene = nil
_scenes = {}
_scene_start = 0
function draw_title()
cls()
print("title " .. scene_time())
end
function update_title()
2023-04-16 23:51:01 +00:00
if scene_time() > 0 then
start_scene("ocean")
2023-04-16 23:24:50 +00:00
end
end
_scenes.title = {start=nil, draw=draw_title, update=update_title}
2023-04-16 23:51:01 +00:00
function start_ocean()
ocean_wind_x = 0
ocean_wind_y = 0
end
2023-04-23 04:02:53 +00:00
2023-04-16 23:24:50 +00:00
function draw_ocean()
2023-04-23 04:02:53 +00:00
cls(12)
2023-04-17 01:33:33 +00:00
local ocean_anim = {[0]=0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0}
2023-04-23 04:02:53 +00:00
if ocean_wind_x != 0 or ocean_wind_y != 0 then
for x=0,15 do
for y=0,15 do
local anim = ocean_anim[(flr(time()*4) - ocean_wind_y*y - ocean_wind_x*x) % #ocean_anim]
local base = 0
if ocean_wind_y != 0 then base = 5 end
if anim > 0 then
spr(base+anim, 8*x, 8*y, 1, 1, ocean_wind_x < 0, ocean_wind_y < 0)
end
2023-04-17 01:33:33 +00:00
end
2023-04-16 23:51:01 +00:00
end
end
2023-04-17 01:33:33 +00:00
print("wind: "..ocean_wind_x..", "..ocean_wind_y)
2023-04-23 04:02:53 +00:00
draw_ship(player_ship, 64, 64)
2023-04-16 23:24:50 +00:00
end
function update_ocean()
2023-04-16 23:51:01 +00:00
if btn(0) then
ocean_wind_x = -1
elseif btn(1) then
ocean_wind_x = 1
else
ocean_wind_x = 0
end
if btn(2) then
ocean_wind_y = -1
elseif btn(3) then
ocean_wind_y = 1
else
ocean_wind_y = 0
end
2023-04-16 23:24:50 +00:00
end
2023-04-17 01:33:33 +00:00
_scenes.ocean = {start=start_ocean, draw=draw_ocean, update=update_ocean}
2023-04-16 23:24:50 +00:00
2023-04-23 04:02:53 +00:00
function draw_ship(ship, x, y)
spr(ship.n, x-ship.w*4, y-ship.h*4, 1, ship.h)
if ship.w > 1 then
spr(ship.n, x-ship.w*4+8, y-ship.h*4, 1, ship.h, true)
end
end
ship_type = {
small={n=64, w=1, h=1},
medium={n=65, w=1, h=2},
large={n=66, w=2, h=2},
ghost={n=67, w=2, h=3}
}
player_ship = ship_type.ghost
2023-04-16 23:24:50 +00:00
__gfx__
2023-04-23 04:02:53 +00:00
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc7cccccccccccccccccccccccccccccccccccccc000000000000000000000000
ccccccccc7ccccccccc7ccccccccc7ccccccccc7ccccccccccccccccccccc7cccccccccccccccccccccccccccccccccccccccccc000000000000000000000000
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc7cccccccccc7ccccccccccccccccccccccccccccccccccc000000000000000000000000
ccccccccccccccccccccccccccccccccccccccccccccccccccccc7cccccccccccccccccccccccccccccccccccccccccccccccccc000000000000000000000000
cccccccccc7cccccccccc7ccccccccc7ccccccccccccccccc7cccccccccccccccccccccccccccccccccccccccccccccccccccccc000000000000000000000000
ccccccccccccccccccccccccccccccccccccccccccccc7cccccccccccccc7ccccccccccccccccccccccccccccccccccccccccccc000000000000000000000000
ccccccccc7ccccccccc7cccccccccc7cccccccccc7ccccccccc7cccccccccccccccccccccccccccccccccccccccccccccccccccc000000000000000000000000
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc000000000000000000000000
ffffffffffffffffccccccccccccffffffffccccffffccccccccccccccccccccccccffff00000000000000000000000000000000000000000000000000000000
ffffffffffffffffccccccccccccffffffffccccfffccccccccccccccccccccccccccfff00000000000000000000000000000000000000000000000000000000
ffffffffffffffffccccccccccccffffffffccccffccccccccccccccccccccccccccccff00000000000000000000000000000000000000000000000000000000
ffffffffffffffffccccccccccccffffffffccccfccccccccccccccccccccccccccccccf00000000000000000000000000000000000000000000000000000000
ffffffffccccccccffffffffccccffffffffcccccccccccccccccccffccccccccccccccc00000000000000000000000000000000000000000000000000000000
ffffffffccccccccffffffffccccffffffffccccccccccccccccccffffcccccccccccccc00000000000000000000000000000000000000000000000000000000
ffffffffccccccccffffffffccccffffffffcccccccccccccccccffffffccccccccccccc00000000000000000000000000000000000000000000000000000000
ffffffffccccccccffffffffccccffffffffccccccccccccccccffffffffcccccccccccc00000000000000000000000000000000000000000000000000000000
2023-04-16 23:51:01 +00:00
3333333333333333ffffffffffff33333333ffff3333ffffffffffffffffffffffff333333333333333333333333333333333333000000000000000000000000
3333333333333333ffffffffffff33333333ffff333ffffffffffffffffffffffffff33333333a33333333333333333333333333000000000000000000000000
3333333333333333ffffffffffff33333333ffff33ffffffffffffffffffffffffffff333333333333a3333333a3338333333383000000000000000000000000
3333333333333333ffffffffffff33333333ffff3ffffffffffffffffffffffffffffff333333333333333333333333333333333000000000000000000000000
33333333ffffffff33333333ffff33333333fffffffffffffffffff33fffffffffffffff3a333a33333333333333333333333333000000000000000000000000
33333333ffffffff33333333ffff33333333ffffffffffffffffff3333ffffffffffffff3333333333a3333333a3383333833333000000000000000000000000
33333333ffffffff33333333ffff33333333fffffffffffffffff333333fffffffffffff33333333333333333333333333333333000000000000000000000000
33333333ffffffff33333333ffff33333333ffffffffffffffff33333333ffffffffffff33333333333333333333333333333333000000000000000000000000
5555555555555555ffffffffffff55555555ffff5555ffffffffffffffffffffffff555555555555555555555555555555555555000000000000000000000000
5555555555555555ffffffffffff55555555ffff555ffffffffffffffffffffffffff55555555555559555555555555555555555000000000000000000000000
5555555555555555ffffffffffff55555555ffff55ffffffffffffffffffffffffffff5555555555555555555555555559555555000000000000000000000000
5555555555555555ffffffffffff55555555ffff5ffffffffffffffffffffffffffffff555555555555955955555555555555555000000000000000000000000
55555555ffffffff55555555ffff55555555fffffffffffffffffff55fffffffffffffff55555555555555555555955555555555000000000000000000000000
55555555ffffffff55555555ffff55555555ffffffffffffffffff5555ffffffffffffff55555555555555555595555555555555000000000000000000000000
55555555ffffffff55555555ffff55555555fffffffffffffffff555955fffffffffffff55955555555555955555955555555595000000000000000000000000
55555555ffffffff55555555ffff55555555ffffffffffffffff55555555ffffffffffff55555555555555555555555555555555000000000000000000000000
2023-04-23 04:02:53 +00:00
00000000000440000000000400000005000000000000000000000000000000000000000000000000000000001111119111149111111110010000000000000000
00000000004444000000004400000055000000000000000000000000000000000000000000000000000000001111144911149111111100000000000000000000
00044000004444000000044400000556000000000000000000000000000000000000000000000000000000001111994111999911111990000000000000000000
004ff400044ff440000044ff00000566000000000000000000000000000000000000000000000000000000001114491119149191110009010000000000000000
004ff40004f44f4000004fff00005566000000000000000000000000000000000000000000000000000000001999411191149991199009110000000000000000
004ff40004f44f400077777400005566000000000000000000000000000000000000000000000000000000009669111191149119004441110000000000000000
0044440004f44f400004466700005566000000000000000000000000000000000000000000000000000000009669111119149191004941110000000000000000
000000007777777700044ff507777775000000000000000000000000000000000000000000000000000000001991111111999911104441110000000000000000
2023-04-19 02:46:25 +00:00
00000000077777700777777400077777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000046556400077777700055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f55f400004566500055565000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f44f4000044fff07777775000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f44f4000044fff00077777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000044ff440000044ff00055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000004444000000444f00055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000440000000044400055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2023-04-23 04:02:53 +00:00
00000000000000000000000077777775000000000000000011111111111111111111111111111111111111110000000000000000000000000000000000000000
0000000000000000000000000077777700000000000000000077770077777777aaaaaaaa3333333322d22dd20000000000000000000000000000000000000000
0000000000000000000000000005556600000000000000000077770099999999aa8aa8aa333333332dd22d220000000000000000000000000000000000000000
0000000000000000000000000000556600000000000000000007700077977977aaa88aaacccccccc22d22dd20000000000000000000000000000000000000000
0000000000000000000000000000556600000000000000000070070077977977aaa88aaacccccccc2dd22d220000000000000000000000000000000000000000
0000000000000000000000000000055500000000000000000007700099999999aa8aa8aa3333333322d22dd20000000000000000000000000000000000000000
0000000000000000000000000000005500000000000000000070070077777777aaaaaaaa333333332dd22d220000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000011111111111111111111111111111111111111110000000000000000000000000000000000000000
2023-04-16 23:51:01 +00:00
__map__
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0016121212121700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0013101010101400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0013101010101400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0018111111111500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000