experiments-pico8/games/ocean.p8

157 lines
10 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-16 23:24:50 +00:00
function draw_ocean()
2023-04-17 01:33:33 +00:00
cls(0)
local ocean_anim = {[0]=0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0}
if ocean_wind_x == 0 and ocean_wind_y == 0 then
return
end
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-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-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
__gfx__
2023-04-16 23:51:01 +00:00
11111111111111111111111111111111111111111111111111111111111111111711111111111111111111111111111111111111000000000000000000000000
11111111171111111117111111111711111111171111111111111111111117111111111111111111111111111111111111111111000000000000000000000000
11111111111111111111111111111111111111111111111111111111171111111111711111111111111111111111111111111111000000000000000000000000
11111111111111111111111111111111111111111111111111111711111111111111111111111111111111111111111111111111000000000000000000000000
11111111117111111111171111111117111111111111111117111111111111111111111111111111111111111111111111111111000000000000000000000000
11111111111111111111111111111111111111111111171111111111111171111111111111111111111111111111111111111111000000000000000000000000
11111111171111111117111111111171111111111711111111171111111111111111111111111111111111111111111111111111000000000000000000000000
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000
ffffffffffffffff111111111111ffffffff1111ffff111111111111111111111111ffff00000000000000000000000000000000000000000000000000000000
ffffffffffffffff111111111111ffffffff1111fff11111111111111111111111111fff00000000000000000000000000000000000000000000000000000000
ffffffffffffffff111111111111ffffffff1111ff1111111111111111111111111111ff00000000000000000000000000000000000000000000000000000000
ffffffffffffffff111111111111ffffffff1111f111111111111111111111111111111f00000000000000000000000000000000000000000000000000000000
ffffffff11111111ffffffff1111ffffffff1111111111111111111ff11111111111111100000000000000000000000000000000000000000000000000000000
ffffffff11111111ffffffff1111ffffffff111111111111111111ffff1111111111111100000000000000000000000000000000000000000000000000000000
ffffffff11111111ffffffff1111ffffffff11111111111111111ffffff111111111111100000000000000000000000000000000000000000000000000000000
ffffffff11111111ffffffff1111ffffffff1111111111111111ffffffff11111111111100000000000000000000000000000000000000000000000000000000
3333333333333333ffffffffffff33333333ffff3333ffffffffffffffffffffffff333333333333333333333333333333333333000000000000000000000000
3333333333333333ffffffffffff33333333ffff333ffffffffffffffffffffffffff33333333a33333333333333333333333333000000000000000000000000
3333333333333333ffffffffffff33333333ffff33ffffffffffffffffffffffffffff333333333333a3333333a3338333333383000000000000000000000000
3333333333333333ffffffffffff33333333ffff3ffffffffffffffffffffffffffffff333333333333333333333333333333333000000000000000000000000
33333333ffffffff33333333ffff33333333fffffffffffffffffff33fffffffffffffff3a333a33333333333333333333333333000000000000000000000000
33333333ffffffff33333333ffff33333333ffffffffffffffffff3333ffffffffffffff3333333333a3333333a3383333833333000000000000000000000000
33333333ffffffff33333333ffff33333333fffffffffffffffff333333fffffffffffff33333333333333333333333333333333000000000000000000000000
33333333ffffffff33333333ffff33333333ffffffffffffffff33333333ffffffffffff33333333333333333333333333333333000000000000000000000000
5555555555555555ffffffffffff55555555ffff5555ffffffffffffffffffffffff555555555555555555555555555555555555000000000000000000000000
5555555555555555ffffffffffff55555555ffff555ffffffffffffffffffffffffff55555555555559555555555555555555555000000000000000000000000
5555555555555555ffffffffffff55555555ffff55ffffffffffffffffffffffffffff5555555555555555555555555559555555000000000000000000000000
5555555555555555ffffffffffff55555555ffff5ffffffffffffffffffffffffffffff555555555555955955555555555555555000000000000000000000000
55555555ffffffff55555555ffff55555555fffffffffffffffffff55fffffffffffffff55555555555555555555955555555555000000000000000000000000
55555555ffffffff55555555ffff55555555ffffffffffffffffff5555ffffffffffffff55555555555555555595555555555555000000000000000000000000
55555555ffffffff55555555ffff55555555fffffffffffffffff555955fffffffffffff55955555555555955555955555555595000000000000000000000000
55555555ffffffff55555555ffff55555555ffffffffffffffff55555555ffffffffffff55555555555555555555555555555555000000000000000000000000
2023-04-19 02:46:25 +00:00
00000000000440000000000400000005000000000000000000000000000000000000000000000000000000000000009000049000ccccc00c0000000000000000
00000000004444000000004400000055000000000000000000000000000000000000000000000000000000000000044900049000cccc00000000000000000000
00044000004444000000044400000556000000000000000000000000000000000000000000000000000000000000994000999900ccc990000000000000000000
004ff400044ff440000044ff00000566000000000000000000000000000000000000000000000000000000000004490009049090cc00090c0000000000000000
004ff40004f44f4000004fff00005566000000000000000000000000000000000000000000000000000000000999400090049990c99009cc0000000000000000
004ff40004f44f40007777740000556600000000000000000000000000000000000000000000000000000000966900009004900900444ccc0000000000000000
0044440004f44f40000446670000556600000000000000000000000000000000000000000000000000000000966900000904909000494ccc0000000000000000
000000007777777700044ff507777775000000000000000000000000000000000000000000000000000000000990000000999900c0444ccc0000000000000000
00000000077777700777777400077777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000046556400077777700055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f55f400004566500055565000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f44f4000044fff07777775000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000004f44f4000044fff00077777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000044ff440000044ff00055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000004444000000444f00055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000440000000044400055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000077777775000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000777777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000055566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000005566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000005566000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000555000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2023-04-16 23:51:01 +00:00
__map__
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0016121212121700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0013101010101400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0013101010101400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0018111111111500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000