This commit is contained in:
2026-11-09 22:47:38 +01:00
parent 1fe09d44eb
commit 6c103a805a
+127
View File
@@ -0,0 +1,127 @@
pico-8 cartridge // http://www.pico-8.com
version 43
__lua__
-- game main loop
game_state={
state = 1 -- 1: title 2: game 3: over
}
function _init()
make_player(64,64,7)
end
function _update()
-- update game_objects
for object in all(game_objects) do
object:update()
end
end
function _draw()
cls()
-- draw background
map (0,0,0,0,16,16)
-- draw game_objects
for object in all(game_objects) do
object:draw()
end
end
-->8
-- game objects
game_objects={}
object_type={
player=1,
wall=2,
coin=3
}
-- player class:
function make_player(_x,_y,_sprite)
local object={
x=_x,
y=_y,
sprite=_sprite,
obj_type=object_type.player,
speed = 3
}
function object:update()
self.speed = self.speed -1
if self.speed>0 then return end
self.speed = 3
if btn(⬆️) then self.y -=8 end
if btn(⬇️) then self.y +=8 end
if btn(⬅️) then self.x -=8 end
if btn(➡️) then self.x +=8 end
if self.y>112 then self.y=112 end
if self.y<8 then self.y=8 end
if self.x>112 then self.x=112 end
if self.x<8 then self.x=8 end
end
function object:draw()
spr(self.sprite,self.x,self.y)
end
add(game_objects, object)
return object
end
--[[ template:
function make_object(_x,_y)
local object={
x=_x,
y=_y
}
function object:update()
end
function object:draw()
spr(1,x,y)
end
add(game_objects, object)
return object
end
--]]
__gfx__
00000000bb7777bbaaa0aaaa0aaaaaaabbbbbbbbbbbbbbbbbbb28bbb000aaa000000000000000000000000000000000000000000000000000000000000000000
00000000b7aaaa9b9940a9990a999994bbbbbbbbbbbbbbbbbb2222bb00af50000000000000000000000000000000000000000000000000000000000000000000
007007007aaaaaa99940a9990a999994bbbb3bbbbbbbbbb32282882b0aaff0000000000000000000000000000000000000000000000000000000000000000000
000770007aa55aa90000000000000000bbbbbbbbbbbbbbbbb22882220a0110f00000000000000000000000000000000000000000000000000000000000000000
000770007aa55aa9aaaaa0aaaa0aaaaabbbbbbbbb3bbbbbbbb2222bb011111000000000000000000000000000000000000000000000000000000000000000000
007007007aaaaaa9999940a9940a9999bbbbbbbbbbbbbbbbbb28222bf01110000000000000000000000000000000000000000000000000000000000000000000
00000000b7aaaa9b999940a9940a9999b3bbbbbbbbbb3bbbb22828bb00c0c0000000000000000000000000000000000000000000000000000000000000000000
00000000bb9999bb0000000000000000bbbbbbbbbbbbbbbbbb2222bb00f0f0000000000000000000000000000000000000000000000000000000000000000000
__gff__
0001040400000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
0203020302030203020302030203020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0300000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0200000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0302030203020302030203020302030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0204040404040504040404040404040200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0304050404040404040404050404040300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0204040504040405040404040404040200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0304040404040404040404040404040300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0204040404040405040404040504040200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0205040405050404040404050405040300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0204040404050404040504040404040200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0304040504040404040405040405040300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0205040404040504040504040404040200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0204050504040504040405040405040300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0204040404040404040404040404050200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0302020203030203020203020202030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000