Compare commits

..

4 Commits

Author SHA1 Message Date
d59b7f749d voila 2025-08-10 00:10:34 +02:00
eb77b4c0e3 voila 2025-08-10 00:08:29 +02:00
4183bb8ddb smb docs 2025-08-10 00:07:56 +02:00
a2d4f2d0db new stuff 2025-08-10 00:06:15 +02:00
12 changed files with 917 additions and 2 deletions

BIN
.DS_Store vendored

Binary file not shown.

44
16.p8l Normal file
View File

@@ -0,0 +1,44 @@
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48

12
24.p8l Normal file
View File

@@ -0,0 +1,12 @@
40
40
40
40
40
40
40
40
40
40
40
40

28
25.p8l Normal file
View File

@@ -0,0 +1,28 @@
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48

21
26.p8l Normal file
View File

@@ -0,0 +1,21 @@
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48

193
level_crawler/level_test.p8 Normal file
View File

@@ -0,0 +1,193 @@
pico-8 cartridge // http://www.pico-8.com
version 42
__lua__
entities={}
function _init()
maps[currentmap]:init()
end
function _update()
maps[currentmap]:update()
player:update()
for e in all(entities) do
e:update()
end
end
function _draw()
maps[currentmap]:draw()
player:draw()
for e in all(entities) do
e:draw()
end
end
-->8
--globals
--types
entity={
x=0,
y=0,
s=0,
w=8,
h=8,
ox=0,
oy=0,
draw=function(self)
spr(self.s,self.x*8,self.y*8)
end,
update=function(self)
end,
init=function(self)
end,
new=function(self,obj)
obj = obj or self
return setmetatable(obj, {__index=self})
end
}
maptype={
x=0,
y=0,
w=6,
h=8,
exits={
first={
x=3,
y=1,
s=3,
n="red",
px=3,
py=1
}
},
update=function(self)
for goal in all(self.exits) do
if player.x == goal.x and player.y ==goal.y then
player.x,player.y=goal.px,goal.py
currentmap=goal.n
maps[currentmap]:init()
end
end
end,
draw=function(self)
cls()
map(self.x,self.y,0,0,self.w,self.h)
camera(-64+self.w*8/2,-64+self.h*8/2)
printh("exits".. #self.exits)
for goal in all(self.exits) do
printh(goal)
spr(goal.s,goal.x*8,goal.y*8)
end
end,
init=function(self)
end,
new=function(self,obj)
local obj = obj or self
return setmetatable(obj, {__index=self})
end
}
--functions
function hit(obj, x, y)
return fget(mget(obj.x+x,obj.y+y),1)
end
-->8
--player
player=entity:new({
x=1,
y=1,
update=function(self)
if btnp(⬆️) then
if not (hit(self,0,-1)) then
self.y-=1
end
end
if btnp(⬇️) then
if not (hit(self,0,1)) then
self.y+=1
end
end
if btnp(⬅️) then
if not (hit(self,-1,0)) then
self.x-=1
end
end
if btnp(➡️) then
if not (hit(self,1,0)) then
self.x+=1
end
end
end,
})
-->8
--maps
currentmap="red"
maps={
red=maptype:new({
exits={
{
x=3,
y=1,
s=3,
n="green",
px=3,
py=1
}
},
}),
green=maptype:new({
x=7,
y=0,
w=6,
h=8,
exits={
{
x=4,
y=4,
s=3,
n="red",
px=4,
py=4
}
},
})
}
__gfx__
00000000444444443333333300111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000488888853bbbbbbd01100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700488888853bbbbbbd01000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000488888853bbbbbbd01000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000488888853bbbbbbd01000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700488888853bbbbbbd01000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000488888853bbbbbbd01101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000055555555dddddddd00110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000088d8888dbbdbbbbd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000088d8888dbbdbbbbd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000dd8dddd8ddbddddb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000d888d888dbbbdbbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000d888d888dbbbdbbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000dddddddddddddddd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000008d888d88bdbbbdbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000008d888d88bdbbbdbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__gff__
0002020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
0101010101010002020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0111111111010002121212120200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0111111111010002121212120200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0111111111010002121212120200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0111111111010002121212120200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0111111111010002121212120200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0101010101010002020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

12
level_crawler/readme.md Normal file
View File

@@ -0,0 +1,12 @@
# levelcrawler
tldr it's a poc to move from level to level only drawing partial data from the map
This is kindof like a test to make a dungeon crawler type thing with a map?
Basically i wanted to only draw parts of the map and have level transitions, so that's what i did so far :p
next up 2 things:
- i wanna do enemies
- map uses col pallette fuckery. I did this once with a little swimming poc i made for alain but it'd be actually really usefull to do it for levels instead. The difficulty being that i'd have to update the player col pal seperately. so run pal in the map shit, then on draw for the player ignore it (i think that's what i'm goign to do) and then in the enemy shit use it again. Gonna be complex but also cool

View File

@@ -32,8 +32,8 @@ function _update()
-- wsong()
async(function()
while true do
poke(rnd(0x6000),rnd(0x00ff))
poke(rnd(0x6000),rnd(0x00ff))
poke(rnd(0x6000),rnd(0xf))
-- poke(rnd(0x6000),rnd(0xf))
yield()
end
end)

View File

@@ -1,3 +1,6 @@
# some games
just a collection of everything i made on pico8 so far :p also contains code from friends and stuff
most of this root is unstructured, but the subfolders usually have some readme in there :p that explains at least something

6
smbreplay/readme.md Normal file
View File

@@ -0,0 +1,6 @@
# smbreplay
wanted to remake super meat boys replay system.
Basically what i did was every frame the game ran i would querry the btn input bit thing (like if you have btn() with no args)
and then i would save those in an array for whatever entity is playing. Then when i die i would save that array to a 2d array saving all the replays. and then at the end i'd create entities that just play those inputs every update frame. cool right?

449
smbreplay/smbreplay.p8 Normal file
View File

@@ -0,0 +1,449 @@
pico-8 cartridge // http://www.pico-8.com
version 42
__lua__
function _init()
for i=0,20 do
printh("")
end
printh("init")
end
function _update60()
if statechange then
statechange=false
states[state]:init()
end
states[state]:update()
end
function _draw()
states[state]:draw()
for r in all(states[state].routines) do
if costatus(r) == "dead" then
del(states[state].routines,r)
else
assert(coresume(r))
end
end
end
-->8
--globals
--global environment
global=_ENV
--timer
tim=0
--class
class=setmetatable({
new=function(_ENV,tbl)
tbl=setmetatable(tbl or {},{
__index=_ENV
})
tbl:init()
return tbl
end,
init=function()end
},{__index=_ENV})
--states
state="intro"
statechange=true
states={
--state.intro
intro={
init=function(self)
self.x=45
self.y=128
self.intro=cocreate(function()
for i=80,30,-1 do
self.y=i
yield()
end
end)
end,
update=function(self)
if btnp(🅾️) then
statechange=true
state="gameplay"
end
if costatus(self.intro)!="dead" then
coresume(self.intro)
end
end,
draw=function(self)
cls()
cursor(self.x,self.y)
print("welcome!")
print("⬅️ left")
print("➡️ right")
print("❎ jump")
print("🅾️ reset")
print("press 🅾️ to continue")
end
},
--state.gameplay
gameplay={
routines={}, --todo add death anims
init=function()
pl = player:new()
tim=time()
pl.x,pl.y=maps[currentmap]:init()
add(entities,pl)
end,
update=function()
buttons=btn()
for entity in all(entities) do
entity:update()
end
end,
draw=function()
cls()
maps[currentmap]:draw()
for e in all(entities) do
e:draw()
end
cursor(0,100)
color(7)
print("time:"..time()-tim)
print("attempts:"..count(replays))
end
},
--state.replay
replay={
routines={},
init=function(self)
printh(#replays)
end,
update=function(self)
for entity in all(entities) do
entity:update()
end
if #entities==0 then
entities={}
printh("replays:"..#replays)
for a in all(replays) do
t={}
for item in all(a) do
add(t,item)
end
rep=replayer:new({actions=t,c=rnd(16)})
rep.x,rep.y=maps[currentmap]:init()
add(entities,rep)
end
end
end,
draw=function(self)
cls()
maps[currentmap]:draw()
for e in all(entities) do
e:draw()
end
cursor(10,100)
print("you won! in only "..#replays.." attempts!")
print("press 🅾️ to go to next level")
end,
}
}
--entity
entity=class:new({
x=1,
y=1,
w=8,
h=8,
routines={},
actions={},
})
entities={}
--btn
buttons=0
--replays
replays={}
--gravity
gravity=.2
--helper functions
function hitx(e)
fl=0
for x=0,e.w do
x1,y1,y2=(e.x+x)/8,e.y-1/8,(e.y+e.h-1)/8
fl=fl|fget(mget(x1,y1))|fget(mget(x1,y2))
end
return fl
end
function hity(e)
fl=0
for y=0,e.h do
x1,x2,y1=e.x/8,(e.x+e.w)/8,(e.y+y)/8
fl=fl|fget(mget(x1,y1))|fget(mget(x2,y1))
end
return fl
end
function hitbottom(obj)
fl=0
for x=0,obj.w,obj.w do
x1,y1=(obj.x+x)/8,(obj.y+obj.h+1)/8 --1 below
fl=fl|fget(mget(x1,y1))
end
return (fl==1)
end
--restart(win?,actions)
function restart(w,obj)
add(replays,obj.actions)
if w then
sfx(10,1)
entities={}
tim=time()
for a in all(replays) do
t={}--this is necessary because it otherwise stores a ref, not a clone
for item in all(a) do
add(t,item)
end
rep=replayer:new({actions=t,c=rnd(16)})
rep.x,rep.y=maps[currentmap]:init()
add(entities,rep)
end
state="replay"
statechange=true
else
sfx(9)
add(states[state].routines,cocreate(function()
a={16,16,32,32,48,48,48}
bx,by=obj.x,obj.y
for x in all(a) do
printh(bx)
spr(x,bx,by)
yield()
end
end))
entities,tim={},time()
sx,sy=maps[currentmap]:init()
add(entities,player:new({actions={},x=sx,y=sy}))
end
end
-->8
--characters
--npc
npc=entity:new({
spd=.5,
s=0,--sprite
v=.5,
c=8,
f=false,
update=function(_ENV)
end,
draw=function(_ENV)
pal(8,c)
spr(s,x-(8-w)/2,y-(8-h)/2,1,1,f)
pal()
end
})
player=npc:new({
x=6,
y=6,
s=0,
yv=0,
xv=0,
-- w=6,
-- h=6,
j=3, --jump height
friction=.5,
actions={},
update=function(self)
-- self.xv,self.yv=0,0 --l,r,u,d
self.xv*=self.friction
self:grav()
self:move()
self.x+=self.xv
self.y+=self.yv
if (self.xv>0) self.f=false
if (self.xv<0) self.f=true
end,
grav=function(self)
self.yv+=gravity
end,
jump=function(self)
if (hitbottom(self)) then
sfx(8,-1,0,rnd(16))
self.yv-=self.j
end
end,
move=function(self)
local b=global.buttons
if ((b&0b0001)!=0) self.xv-=self.v
if ((b&0b0010)!=0) self.xv+=self.v
if ((b&0x10)!=0) self:jump()
if (btnp(❎)) restart(false,self)
t=player:new({x=self.x+self.xv,y=self.y+self.yv})
fx,fy=hitx(t),hity(t)
if (((fx|fy)&0x4)!=0) restart(false,self)
if (((fx|fy)&0x2)!=0) restart(true,self)
-- if ((fx&0x1)!=0) self.xv=0
if ((fy&0x1)!=0) self.yv=0
add(self.actions,b)
end
})
replayer=player:new({
i=1,
alive=true,
c=8,
move=function(self)
local b = self.actions[1] or 0x0
if ((b&0x1)!=0) self.xv-=self.v
if ((b&0x2)!=0) self.xv+=self.v
if ((b&0x10)!=0) self:jump()
t=player:new({x=self.x+self.xv,y=self.y+self.yv})
fx,fy=hitx(t),hity(t)
if ((fx&0x1)!=0) self.xv=0
if ((fy&0x1)!=0) self.yv=0
deli(self.actions,1)
if (#self.actions==0) then
del(entities,self)
sfx(9)
end
end
})
-->8
--maps
maps={
forrest={
x=0,
y=0,
pl={},
init=function(self)
map(self.x,self.y)
for x=0,15 do
for y=0,15 do
if (mget(x,y)==0) then
px,py=x*8,y*8
end
end
end
return px,py
end,
draw=function(self)
pal(pl)
map(self.x,self.y)
for x=0,128,8 do
for y=0,128,8 do
if fget(mget(x/8,y/8),0x0) then
if (not fget(mget(x/8,y/8-1),0x0)) then
sspr(16,8,8,2,x,y)
end
end
end
end
end,
}
}
currentmap="forrest"
__gfx__
000000008888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000008888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
088888808888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
088080808888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
088080808888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
088888808888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
088888808888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
008008008888888855555555eeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000b3bb33bb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000075503b00000b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000005c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00080000000005500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000800000000bb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000008b800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000080800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00888080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00800800000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00808000000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00088800000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00808000000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00008800000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000009999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__gff__
0004010200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222220222222222032222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222220222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222020222220222222222222222220222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222220222220222022222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222202220222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222220222222222222202222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0222222222220222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0022220222220222022222022222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222220222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0022022222220222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0202020202020201010101010101010102222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0001000029050340502f0502505016050090500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0004000017750097500c750157502c750147501475014750057500a75005750057500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000500001a2501e2501f2502325000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

147
untitled.p8 Normal file
View File

@@ -0,0 +1,147 @@
pico-8 cartridge // http://www.pico-8.com
version 42
__lua__
function _init()
add(entities,player:new())
for i=0,20 do
printh("")
end
end
function _update60()
b=btn()
for e in all(entities) do
e:update()
end
end
function _draw()
cls()
map()
for e in all(entities) do
e:draw()
end
end
-->8
--globals
--global environment
global=_ENV
--class
class=setmetatable({
new=function(_ENV,tbl)
tbl=setmetatable(tbl or {},{
__index=_ENV
})
tbl:init()
return tbl
end,
init=function()end
},{__index=_ENV})
--entity
entity=class:new({
x=1,
y=1,
w=8,
h=8
})
entities={}
--btn
b=0
--helper functions
function hitx(e)
fl=0
for x=0,e.w do
x1,y1,y2=(e.x+x)/8,e.y/8,(e.y+e.h)/8
fl=fl|fget(mget(x1,y1))|fget(mget(x1,y2))
end
return fl
end
function hity(e)
fl=0
for y=0,e.h do
x1,x2,y1=e.x/8,(e.x+e.w)/8,(e.y+y)/8
fl=fl|fget(mget(x1,y1))|fget(mget(x2,y1))
end
return fl
end
-->8
--npc
npc=entity:new({
spd=.5,
s=0,--sprite
update=function(_ENV)
end,
draw=function(_ENV)
spr(s,x,y)
end
})
player=npc:new({
x=6,
y=6,
s=0,
update=function(self)
-- hit(self)
b=global.b
xv,yv=0,0
--left,right,up,down
if ((b & 0x1)!=0) xv-=1
if ((b&0x2)!=0) xv+=1
if ((b&0x4)!=0) yv-=1
if ((b&0x8)!=0) yv+=1
if xv!=0 or yv!=0 then
-- if (hity(player:new({y=self.y+yv}))) self.y+=yv
-- if hit(player:new({
-- x=self.x+xv,
-- y=self.y+yv
-- })) then
-- printh("hit")
-- else
-- if (hitx(player:new({x=self.x+xv}))) printh("x?")
t=player:new({x=self.x+xv,y=self.y+yv})
fx=hitx(t) --flags x
fy=hity(t) --flags y
if ((fx&0x1)==0) self.x+=xv
if ((fy&0x1)==0) self.y+=yv
end
end
})
__gfx__
0000000088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0070070088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0007700088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0007700088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0070070088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000088888888cccccccceeeeeeee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__gff__
0000010200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000200000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000