ok
This commit is contained in:
141
creature.p8
141
creature.p8
@@ -24,7 +24,7 @@ function _init()
|
||||
cartdata("savedgame")
|
||||
timeset = dget(0)
|
||||
stime=dt:new()
|
||||
|
||||
dc=time()
|
||||
if (timeset==0) then
|
||||
stime:from(currenttime())
|
||||
-- printh("save:"..stime:tostring())
|
||||
@@ -37,12 +37,16 @@ function _init()
|
||||
|
||||
cls()
|
||||
-- printh("goaltime"..goaltime)
|
||||
m:ctmap()
|
||||
|
||||
m:draw()
|
||||
ui:draw()
|
||||
|
||||
end
|
||||
|
||||
function _update60()
|
||||
function _update()
|
||||
dc=time()
|
||||
delta=dc-dp
|
||||
dp=dc
|
||||
ctime=dt:new()
|
||||
m:update()
|
||||
ctime:from(currenttime())
|
||||
@@ -125,41 +129,55 @@ k={ --him
|
||||
y=64,
|
||||
m=1, --modifier
|
||||
t = 0,
|
||||
speed=.1,
|
||||
speed=3,
|
||||
target={x=-1,y=-1},
|
||||
mv=function(self)--move
|
||||
|
||||
--bro what the fuck am i doing
|
||||
if (self.target.x ==-1) then
|
||||
self:tget()
|
||||
else
|
||||
printh(self.target.x)
|
||||
|
||||
self.x=self.target.x
|
||||
self.y=self.target.y
|
||||
printh(self.target.x)
|
||||
printh(self.target.y)
|
||||
tx=self.x-self.target.x
|
||||
ty=self.target.y-self.y
|
||||
if (abs(tx)>0) or (abs(ty)>0) then
|
||||
--hit detection neede
|
||||
self.x+=sgn(tx)*self.speed
|
||||
self.y+=sgn(ty)*self.speed
|
||||
printh(self.x)
|
||||
printh(self.y)
|
||||
end
|
||||
end
|
||||
end,
|
||||
tget=function(self)--find target
|
||||
if onscreen(self) then
|
||||
|
||||
sx,sy=flr(self.x/8),flr(self.y/8)
|
||||
|
||||
lowest,tx,ty=32000,0,0
|
||||
if (m.dmap[sx][sy+1]<lowest) lowest,tx,ty=m.dmap[sx][sy+1],sx,sy+1
|
||||
if (m.dmap[sx][sy-1]<lowest) lowest,tx,ty=m.dmap[sx][sy-1],sx,sy-1
|
||||
if (m.dmap[sx+1][sy]<lowest) lowest,tx,ty=m.dmap[sx+1][sy],sx+1,sy
|
||||
if (m.dmap[sx-1][sy]<lowest) lowest,tx,ty=m.dmap[sx-1][sy],sx-1,sy
|
||||
if (lowest<m.dmap[sx][sy]) then
|
||||
printh(lowest)
|
||||
self.target.x,self.target.y=tx,ty
|
||||
self.target.x*=8
|
||||
self.target.y*=8
|
||||
else
|
||||
printh(lowest)
|
||||
end
|
||||
|
||||
|
||||
if onscreen(self) then
|
||||
sx,sy=flr(self.x/8),flr(self.y/8)
|
||||
lowest,tx,ty=m.dmap[sx][sy],0,0
|
||||
if (m.dmap[sx][sy+1]<lowest) then
|
||||
-- printh("lowest n:".. m.dmap[sx][sy+1])
|
||||
-- printh("sx sy" .. sx .. " " .. sy+1)
|
||||
lowest,tx,ty=m.dmap[sx][sy+1],sx,sy+1
|
||||
end
|
||||
end,
|
||||
if (m.dmap[sx][sy-1]<lowest) then
|
||||
-- printh("lowest s:".. m.dmap[sx][sy-1])
|
||||
-- printh("sx sy" .. sx .. " " .. sy-1)
|
||||
lowest,tx,ty=m.dmap[sx][sy-1],sx,sy-1
|
||||
end
|
||||
if (m.dmap[sx+1][sy]<lowest) then
|
||||
-- printh("lowest e:".. m.dmap[sx+1][sy])
|
||||
-- printh("sx sy" .. sx+1 .. " " .. sy)
|
||||
lowest,tx,ty=m.dmap[sx+1][sy],sx+1,sy
|
||||
end
|
||||
if (m.dmap[sx-1][sy]<lowest) then
|
||||
lowest,tx,ty=m.dmap[sx-1][sy],sx-1,sy
|
||||
-- printh("lowest w:".. m.dmap[sx-1][sy])
|
||||
-- printh("sx sy" .. sx-1 .. " " .. sy)
|
||||
end
|
||||
self.target.x,self.target.y=tx,ty
|
||||
self.target.x*=8
|
||||
self.target.y*=8
|
||||
end
|
||||
end,
|
||||
growtime=3.600,
|
||||
update = function(self,start,current)
|
||||
self.m = dget(10) --get last m
|
||||
@@ -217,51 +235,50 @@ m = { --map
|
||||
ty=0,
|
||||
t=false,--transition
|
||||
dmap={{}},--dijkstra map
|
||||
calcmap=function(self)
|
||||
local dmap={{}}
|
||||
tmap={{}},
|
||||
cmap={{}},
|
||||
skx={},
|
||||
sky={},
|
||||
ctmap=function(self)
|
||||
for x=0,self.bounds[3] do
|
||||
ty={}
|
||||
cy={}
|
||||
for y=0,self.bounds[4] do
|
||||
ty[y]=30000
|
||||
cy[y]=not fget(mget(x,y),0)
|
||||
end
|
||||
dmap[x]=ty
|
||||
self.cmap[x]=cy
|
||||
self.tmap[x]=ty
|
||||
end
|
||||
end,
|
||||
calcmap=function(self)
|
||||
local dmap=self.tmap
|
||||
dmap[flr(p.x/8)][flr(p.y/7)]=0
|
||||
nochange=false
|
||||
repeat
|
||||
ccount=0
|
||||
for x=self.cx/8,(self.cx+127)/8 do
|
||||
for y=self.cy/8,(self.cy+127)/8 do
|
||||
if not fget(mget(x,y),0)
|
||||
and dmap[x][y]>0 then
|
||||
--not wall nor player
|
||||
c=dmap[x][y]
|
||||
u=dmap[x][y+1]
|
||||
d=dmap[x][y-1]
|
||||
r=dmap[x+1][y]
|
||||
l=dmap[x-1][y]
|
||||
lowest=c
|
||||
printh("lets start, c:"..lowest)
|
||||
lowest=min(lowest,u)
|
||||
printh(lowest)
|
||||
lowest=min(lowest,d)
|
||||
printh(lowest)
|
||||
lowest=min(lowest,l)
|
||||
printh(lowest)
|
||||
lowest=min(lowest,r)
|
||||
printh(lowest)
|
||||
--skip if change set
|
||||
--set current to +1 lowest if true
|
||||
lowest+=1
|
||||
if (c>lowest) then
|
||||
ccount+=1
|
||||
dmap[x][y]=lowest
|
||||
printh("final:"..dmap[x][y])
|
||||
end
|
||||
if self.cmap[x][y] then
|
||||
if dmap[x][y]>0 then
|
||||
--not wall nor player
|
||||
c=dmap[x][y]
|
||||
|
||||
lowest=c
|
||||
lowest=min(lowest,dmap[x][y+1])
|
||||
lowest=min(lowest,dmap[x][y-1])
|
||||
lowest=min(lowest,dmap[x+1][y])
|
||||
lowest=min(lowest,dmap[x-1][y])
|
||||
--skip if change set
|
||||
--set current to +1 lowest if true
|
||||
lowest+=1
|
||||
if (c>lowest) then
|
||||
ccount+=1
|
||||
dmap[x][y]=lowest
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
printh(ccount)
|
||||
until ccount==0
|
||||
self.dmap=dmap
|
||||
end,
|
||||
@@ -288,6 +305,7 @@ m = { --map
|
||||
self.cx-=128
|
||||
p.x-=16
|
||||
end
|
||||
self:ctmap()
|
||||
else
|
||||
self.t=false
|
||||
|
||||
@@ -604,6 +622,9 @@ timescale=1
|
||||
stime={}
|
||||
ctime={}
|
||||
timeset=0
|
||||
delta=0
|
||||
dp=0
|
||||
dc=0
|
||||
mapbounds={
|
||||
x1=0,
|
||||
y1=0,
|
||||
|
81
lou.p8
Normal file
81
lou.p8
Normal file
@@ -0,0 +1,81 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
__lua__
|
||||
--main
|
||||
|
||||
function _init()
|
||||
printh("lou is initializing")
|
||||
cartdata("lou")
|
||||
lou:init()
|
||||
printh("lou has arrived :)")
|
||||
end
|
||||
|
||||
function _update()
|
||||
lou.age+=sincelast()
|
||||
savedate()
|
||||
printh("lou's current age: "..lou.age)
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls()
|
||||
end
|
||||
-->8
|
||||
--globals
|
||||
|
||||
-->8
|
||||
--functions
|
||||
|
||||
function savedate()
|
||||
|
||||
dset(0,stat(90))--year
|
||||
dset(1,stat(91))--month
|
||||
dset(2,stat(92))--day
|
||||
dset(3,stat(93))--hour
|
||||
dset(4,stat(94))--minute
|
||||
dset(5,stat(95))--second
|
||||
end
|
||||
|
||||
function sincelast()
|
||||
y=stat(90)-dget(0)*311.040 --yeras
|
||||
mo=stat(91)-dget(1)*25.920 --30 days in a month
|
||||
d=stat(92)-dget(2)*864
|
||||
h=stat(93)-dget(3)*36
|
||||
m=stat(94)-dget(4)*.6
|
||||
s=stat(95)-dget(5)*.01
|
||||
return s+m+h+d+mo+y
|
||||
end
|
||||
|
||||
|
||||
-->8
|
||||
--state
|
||||
-->8
|
||||
--lou
|
||||
lou={
|
||||
new=1,
|
||||
age=0,
|
||||
|
||||
init=function(self)
|
||||
self.new=dget(10)
|
||||
if self.new == 0 then --new lou
|
||||
self.new=1
|
||||
self.age=0
|
||||
--overwrite date for first time
|
||||
savedate()
|
||||
self:save()
|
||||
else
|
||||
self.age=dget(11)
|
||||
self:save()
|
||||
end
|
||||
end,
|
||||
save=function(self)
|
||||
dset(0,self.new)
|
||||
dset(1,self.age)
|
||||
end
|
||||
}
|
||||
__gfx__
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
277
pushbox-2.p8
Normal file
277
pushbox-2.p8
Normal file
@@ -0,0 +1,277 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
__lua__
|
||||
function _init()
|
||||
initmap()
|
||||
win=false
|
||||
hint=false
|
||||
timer=60
|
||||
end
|
||||
|
||||
function _update()
|
||||
updateplayer()
|
||||
check_win()
|
||||
if btnp(❎) then
|
||||
reload()
|
||||
_init()
|
||||
end
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls()
|
||||
camera(-20,-20)
|
||||
map()
|
||||
drawboxes()
|
||||
drawplayer()
|
||||
if hint==true and timer>0 then
|
||||
timer-=1
|
||||
print("can you hear it",10,25,7)
|
||||
end
|
||||
|
||||
if win==true then
|
||||
rectfill(24,19,55,25,10)
|
||||
print("you win!",25,20,8)
|
||||
end
|
||||
end
|
||||
-->8
|
||||
function initmap()
|
||||
m={
|
||||
w=9,
|
||||
h=8,
|
||||
wallmap={},
|
||||
boxmap={}
|
||||
}
|
||||
|
||||
boxes={}
|
||||
box_i=1
|
||||
box_words={
|
||||
[5]="s",[6]="i",
|
||||
[21]="l",[22]="e",
|
||||
[37]="n",[38]="t"
|
||||
} --number on box
|
||||
box_target={"l","i","s","t","e","n"}
|
||||
|
||||
player={
|
||||
x=0, --position
|
||||
y=0,
|
||||
dir=1,
|
||||
--1 right 2 left 3 down 4 up
|
||||
image={3,4,19,35}
|
||||
}
|
||||
last_move={
|
||||
x=0,
|
||||
y=0,
|
||||
b=0
|
||||
}
|
||||
|
||||
---map
|
||||
for i=0,m.w do
|
||||
m.wallmap[i]={}
|
||||
m.boxmap[i]={}
|
||||
|
||||
for j=0,m.h do
|
||||
|
||||
m.boxmap[i][j]=0
|
||||
local f=fget(mget(i,j))
|
||||
if f==2 then
|
||||
m.wallmap[i][j]=1 --wall
|
||||
else
|
||||
m.wallmap[i][j]=0 --void
|
||||
|
||||
---player
|
||||
if f==4 then
|
||||
player.x=i
|
||||
player.y=j
|
||||
mset(i,j,17)
|
||||
|
||||
---boxes
|
||||
elseif f==8 then
|
||||
local box={
|
||||
x0=i,
|
||||
y0=j,
|
||||
x=i, --position
|
||||
y=j,
|
||||
image=mget(i,j),
|
||||
letter=0
|
||||
}
|
||||
box.letter=box_words[box.image]
|
||||
|
||||
boxes[box_i]=box
|
||||
m.boxmap[i][j]=box_i
|
||||
|
||||
box_i+=1
|
||||
mset(i,j,17)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--new word order
|
||||
function check_win()
|
||||
local this_letter,next_letter
|
||||
local this_x,this_y=-1,-1
|
||||
local next_x,next_y=-2,-2
|
||||
local success=true
|
||||
|
||||
for i=1,5 do
|
||||
this_letter=box_target[i]
|
||||
next_letter=box_target[i+1]
|
||||
|
||||
for b in all(boxes) do
|
||||
if b.letter==this_letter then
|
||||
this_x=b.x
|
||||
this_y=b.y
|
||||
elseif b.letter==next_letter then
|
||||
next_x=b.x
|
||||
next_y=b.y
|
||||
end
|
||||
end
|
||||
if not(this_x+1==next_x and this_y==next_y) then
|
||||
success=false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
win=success
|
||||
end
|
||||
|
||||
function drawboxes()
|
||||
for b in all(boxes) do
|
||||
spr(b.image,b.x*8,b.y*8)
|
||||
end
|
||||
end
|
||||
-->8
|
||||
function updateplayer()
|
||||
if hint==false then
|
||||
if btnp(➡️) or btnp(⬅️) or btnp(⬇️) or btnp(⬆️) then
|
||||
hint=true
|
||||
end
|
||||
else
|
||||
if btnp(➡️) then
|
||||
player.dir=1
|
||||
try_move(1,0)
|
||||
elseif btnp(⬅️) then
|
||||
player.dir=2
|
||||
try_move(-1,0)
|
||||
elseif btnp(⬇️) then
|
||||
player.dir=3
|
||||
try_move(0,1)
|
||||
elseif btnp(⬆️) then
|
||||
player.dir=4
|
||||
try_move(0,-1)
|
||||
elseif btnp(🅾️) then
|
||||
undo()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function try_move(dx,dy)
|
||||
--void + move
|
||||
if m.boxmap[player.x+dx][player.y+dy]==0 and
|
||||
m.wallmap[player.x+dx][player.y+dy]==0 then
|
||||
player.x+=dx
|
||||
player.y+=dy
|
||||
|
||||
last_move.x=dx
|
||||
last_move.y=dy
|
||||
last_move.b=0
|
||||
|
||||
--box + push
|
||||
elseif inbounds(player.x+dx*2,player.y+dy*2)==true then
|
||||
|
||||
if m.boxmap[player.x+dx][player.y+dy]!=0 and
|
||||
m.boxmap[player.x+dx*2][player.y+dy*2]==0 and
|
||||
m.wallmap[player.x+dx*2][player.y+dy*2]==0 then
|
||||
--box update
|
||||
local bi=m.boxmap[player.x+dx][player.y+dy]
|
||||
m.boxmap[player.x+dx][player.y+dy]=0
|
||||
m.boxmap[player.x+dx*2][player.y+dy*2]=bi
|
||||
boxes[bi].x+=dx
|
||||
boxes[bi].y+=dy
|
||||
|
||||
player.x+=dx
|
||||
player.y+=dy
|
||||
|
||||
last_move.x=dx
|
||||
last_move.y=dy
|
||||
last_move.b=bi
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function undo()
|
||||
local lx=last_move.x
|
||||
local ly=last_move.y
|
||||
local bi=last_move.b
|
||||
|
||||
player.x-=lx
|
||||
player.y-=ly
|
||||
|
||||
--box undo
|
||||
if bi>0 then
|
||||
m.boxmap[boxes[bi].x][boxes[bi].y]=0
|
||||
boxes[bi].x-=lx
|
||||
boxes[bi].y-=ly
|
||||
m.boxmap[boxes[bi].x][boxes[bi].y]=bi
|
||||
end
|
||||
|
||||
last_move={
|
||||
x=0,
|
||||
y=0,
|
||||
b=0
|
||||
}
|
||||
end
|
||||
|
||||
function inbounds(x,y)
|
||||
if x>=0 and x<m.w
|
||||
and y>=0 and y<m.h then
|
||||
return true
|
||||
else return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function drawplayer()
|
||||
spr(player.image[player.dir],player.x*8,player.y*8)
|
||||
end
|
||||
__gfx__
|
||||
0000000033333333554994550dddddd00dddddd00ee777700ee77770000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003b333333544494450ddfffd00dfffdd06f1111e26fe11ee200ccccc00ee0000000000000000000000000000000000000000000000000000000000000
|
||||
0070070033b33333349999430df1f1d00d1f1fd06f1eeef26ffe1ef200c000c00e00000000000000000000000000000000000000000000000000000000000000
|
||||
000770003333333354494445ddffef000dfeffdd6f1111f26fff1ff200c000c00e00000000000000000000000000000000000000000000000000000000000000
|
||||
0007700033333333549999450d999a9999a999d06ffef1f26ffe1ff200c000c00e00000000000000000000000000000000000000000000000000000000000000
|
||||
00700700333333b35444944300aaaa0000aaaa006feee1f26fee1ff200c000c00e00000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333b335499994500aaaa0000aaaa006e1111f26ee11ef20cc00cc00ee0000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333335549445500900900009009000ddddee00ddddee0000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333333535555550dddddd0000000000ee777700ee77770000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333333544444450dffffd0000000006f1eeee26f1111e2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333333494949440d1ff1d0000000006f1eeef26f1eeef2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333b399499949ddfeefdd000000006f1feff26f1111f2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003333333349994999009aa900000000006f1efff26f1efff2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003b33333349494944009aa900000000006f1eeff26f1eeff2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333335444444500aaaa00000000006e1111f26e1111f2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333335535535500900900000000000ddddee00ddddee0000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000555535555544945300dddd00000000000ee777700ee77770000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000034494445344994450dddddd0000000006f1eee12611111e2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000054994943449949440dddddd0000000006f11ee126ff1eef2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000005494999594499999dddddddd000000006f1f1f126ff1eff2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000599494459999494909dddd90000000006f1e1f126ff1fff2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000549999454494494409aaaa90000000006f1ee1126fe1eff2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000544494455449944500aaaa00000000006e1eee126ee1eef2000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000355355555349445500900900000000000ddddee00ddddee0000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__gff__
|
||||
0001020404080800000000000000000000010204000808000000000000000000000202040008080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__map__
|
||||
2212121212121212122200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0201011101010201010200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211210101111111010200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0201111111110111010200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211050615162526110200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0201011111110112110200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211112101030111110200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211010111111101110200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
2212121212121212122200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
178
pushbox.p8
Normal file
178
pushbox.p8
Normal file
@@ -0,0 +1,178 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
__lua__
|
||||
function _init()
|
||||
initmap()
|
||||
|
||||
end
|
||||
|
||||
function _update()
|
||||
updateplayer()
|
||||
|
||||
if btnp(❎) then
|
||||
reload()
|
||||
_init()
|
||||
end
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls()
|
||||
camera(-20,-20)
|
||||
map()
|
||||
drawboxes()
|
||||
drawplayer()
|
||||
|
||||
end
|
||||
-->8
|
||||
function initmap()
|
||||
m={
|
||||
w=8,
|
||||
h=8,
|
||||
wallmap={},
|
||||
boxmap={}
|
||||
}
|
||||
|
||||
boxes={}
|
||||
box_i=1
|
||||
box_number={[5]=1,[21]=2} --number on box
|
||||
|
||||
player={
|
||||
x=0, --position
|
||||
y=0,
|
||||
dir=1,
|
||||
--1 right 2 left 3 down 4 up
|
||||
image={3,4,19,35}
|
||||
}
|
||||
|
||||
---map
|
||||
for i=0,m.w-1 do
|
||||
m.wallmap[i]={}
|
||||
m.boxmap[i]={}
|
||||
|
||||
for j=0,m.h-1 do
|
||||
|
||||
m.boxmap[i][j]=0
|
||||
local f=fget(mget(i,j))
|
||||
if f==2 then
|
||||
m.wallmap[i][j]=1 --wall
|
||||
else
|
||||
m.wallmap[i][j]=0 --void
|
||||
|
||||
---player
|
||||
if f==4 then
|
||||
player.x=i
|
||||
player.y=j
|
||||
mset(i,j,17)
|
||||
|
||||
---boxes
|
||||
elseif f==8 then
|
||||
local box={
|
||||
x0=i,
|
||||
y0=j,
|
||||
x=i, --position
|
||||
y=j,
|
||||
image=mget(i,j),
|
||||
number=0
|
||||
}
|
||||
box.number=box_number[box.image]
|
||||
|
||||
boxes[box_i]=box
|
||||
m.boxmap[i][j]=box_i
|
||||
|
||||
box_i+=1
|
||||
mset(i,j,17)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function drawboxes()
|
||||
for b in all(boxes) do
|
||||
spr(b.image,b.x*8,b.y*8)
|
||||
end
|
||||
end
|
||||
-->8
|
||||
function updateplayer()
|
||||
if btnp(➡️) then
|
||||
player.dir=1
|
||||
try_move(1,0)
|
||||
elseif btnp(⬅️) then
|
||||
player.dir=2
|
||||
try_move(-1,0)
|
||||
elseif btnp(⬇️) then
|
||||
player.dir=3
|
||||
try_move(0,1)
|
||||
elseif btnp(⬆️) then
|
||||
player.dir=4
|
||||
try_move(0,-1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function try_move(dx,dy)
|
||||
--void + move
|
||||
if m.boxmap[player.x+dx][player.y+dy]==0 and
|
||||
m.wallmap[player.x+dx][player.y+dy]==0 then
|
||||
player.x+=dx
|
||||
player.y+=dy
|
||||
|
||||
--box + push
|
||||
elseif m.boxmap[player.x+dx][player.y+dy]!=0 and
|
||||
m.wallmap[player.x+dx*2][player.y+dy*2]==0 then
|
||||
--box update
|
||||
local bi=m.boxmap[player.x+dx][player.y+dy]
|
||||
m.boxmap[player.x+dx][player.y+dy]=0
|
||||
m.boxmap[player.x+dx*2][player.y+dy*2]=bi
|
||||
boxes[bi].x+=dx
|
||||
boxes[bi].y+=dy
|
||||
|
||||
player.x+=dx
|
||||
player.y+=dy
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function drawplayer()
|
||||
spr(player.image[player.dir],player.x*8,player.y*8)
|
||||
end
|
||||
__gfx__
|
||||
0000000033333333554994550111111001111110feeeeeee00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003b3333335444944501ffff1001ffff10ffe11eef00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0070070033b333333499994301f0f010010f0f10fffe1eff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000333333335449444511ffef0001feff11ffff1fff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000333333335499994501999a9999a99910fffe1fff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700333333b35444944300aaaa0000aaaa00ffee1fff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333b335499994500aaaa0000aaaa00fee111ff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333333554944550090090000900900eeeeeeef00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333333535555550111111000000000feeeeeee00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333335444444501ffff1000000000ff1111ef00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003333333349494944010ff01000000000fffee1ff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333b39949994911feef1100000000ffffe1ff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003333333349994999009aa90000000000ff1111ff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000003b33333349494944009aa90000000000ff1eefff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000333333335444444500aaaa0000000000fe1111ff00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000033333333553553550090090000000000eeeeeeef00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000555535555544945301111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000344944453449944501111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000549949434499494401111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000549499959449999911111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000599494459999494909111190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000549999454494494409aaaa90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000544494455449944500aaaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000355355555349445500900900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__gff__
|
||||
0001020404080000000000000000000000010204000800000000000000000000000202040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__map__
|
||||
2212121212121212220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0201011101011101020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211210101151111020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0201111111020111020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211050112220111020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0201011111110112220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211112101030111020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0211010111111101020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
2212121212121212220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
742
tetris.p8
Normal file
742
tetris.p8
Normal file
@@ -0,0 +1,742 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
__lua__
|
||||
function _init()
|
||||
mymap={
|
||||
w=68,
|
||||
h=11,
|
||||
}
|
||||
tetris_mode=false
|
||||
coins_collected=false
|
||||
chest_collected=false
|
||||
initcoins()
|
||||
initkey()
|
||||
initchest()
|
||||
inittetris()
|
||||
initplayer()
|
||||
initwater()
|
||||
poke(0x5f5c,255) --disable btnp repeat
|
||||
end
|
||||
|
||||
function _update()
|
||||
-- updatewater()
|
||||
if tetris_mode==false then
|
||||
updateplayer()
|
||||
end
|
||||
if btnp(❎) then
|
||||
reload()
|
||||
_init()
|
||||
end
|
||||
if tetris_mode==false and
|
||||
btnp(🅾️) then
|
||||
tetris_mode=true
|
||||
newtetris()
|
||||
end
|
||||
|
||||
if tetris_mode==true and
|
||||
current_t!=nil then
|
||||
if current_t.stopped==true then
|
||||
stoptetris()
|
||||
end
|
||||
updatetetris()
|
||||
end
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls()
|
||||
camera(player.x-20,-15)
|
||||
map(0,0,0,0,mymap.w,mymap.h)
|
||||
drawcoins()
|
||||
-- drawkey()
|
||||
-- drawchest()
|
||||
if tetris_mode==true and current_t!=nil then
|
||||
draw_t_falling()
|
||||
end
|
||||
-- drawwater()
|
||||
drawplayer()
|
||||
if coins_collected==true and chest_collected==true then
|
||||
print("you win!\npress x to restart",player.x-5,9,3)
|
||||
end
|
||||
print("x to restart",player.x+40,1,4)
|
||||
print("z to summon a tetris block",player.x-8,8,4)
|
||||
|
||||
end
|
||||
-->8
|
||||
function initplayer()
|
||||
player={
|
||||
x=8,
|
||||
y=mymap.h-8,
|
||||
dir=false,
|
||||
vv=0,
|
||||
vh=2,
|
||||
w=8,
|
||||
h=8,
|
||||
image=3,
|
||||
timer=0,
|
||||
walking=false,
|
||||
jumping=false,
|
||||
inwater=false
|
||||
}
|
||||
v0=-4.5
|
||||
gravity=0.5
|
||||
vf=-1 --float
|
||||
v1=-2.5 --jump in water
|
||||
end
|
||||
|
||||
|
||||
function updateplayer()
|
||||
local dx=0
|
||||
local dy=0
|
||||
|
||||
--walk
|
||||
if btn(⬅️) and player.x>=10 then
|
||||
dx=-player.vh
|
||||
player.dir=true
|
||||
for i=1,player.vh do
|
||||
local new_x,new_y,_,_=trymove(player.x,player.y,-1,0)
|
||||
player.x=new_x
|
||||
player.walking=true
|
||||
end
|
||||
|
||||
elseif btn(➡️) and player.x<=mymap.w*8-player.w-10 then
|
||||
dx=player.vh
|
||||
player.dir=false
|
||||
for i=1,player.vh do
|
||||
local new_x,new_y,_,_=trymove(player.x,player.y,1,0)
|
||||
player.x=new_x
|
||||
player.walking=true
|
||||
end
|
||||
|
||||
else player.walking=false
|
||||
end--if
|
||||
|
||||
--jump & fall
|
||||
player.inwater=isinwater(player.x+4,player.y+4)
|
||||
|
||||
if player.inwater==false then
|
||||
|
||||
if isonground() then
|
||||
player.vv=0
|
||||
if btnp(⬆️) then
|
||||
sfx(1)
|
||||
player.vv=v0
|
||||
player.walking=false
|
||||
end
|
||||
else
|
||||
player.vv+=gravity
|
||||
end
|
||||
|
||||
dy=player.vv --falling
|
||||
if dy>0 then
|
||||
dy=ceil(dy)
|
||||
for i=1,dy do
|
||||
local new_x,new_y,_,actual_dy=trymove(player.x,player.y,0,1)
|
||||
player.y=new_y
|
||||
if actual_dy==0 then
|
||||
player.vv=0
|
||||
break
|
||||
end --if
|
||||
end --for
|
||||
|
||||
elseif dy<0 then --jumping
|
||||
dy=flr(dy)
|
||||
for i=1,-dy do
|
||||
local new_x,new_y,_,actual_dy=trymove(player.x,player.y,0,-1)
|
||||
player.y=new_y
|
||||
if actual_dy==0 then
|
||||
player.vv=0
|
||||
end --if
|
||||
end --for
|
||||
end
|
||||
end
|
||||
|
||||
----in water
|
||||
|
||||
if player.inwater==true then
|
||||
|
||||
player.vv=vf
|
||||
dy=player.vv
|
||||
for i=1,-dy do
|
||||
local new_x,new_y,_,actual_dy=trymove(player.x,player.y,0,-1)
|
||||
player.y=new_y
|
||||
if actual_dy==0 then
|
||||
player.vv=0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if player.inwater==true or isinwater(player.x+4,player.y+14) then
|
||||
if btnp(⬆️) then --jump in water
|
||||
sfx(1)
|
||||
player.vv=v1
|
||||
end
|
||||
end
|
||||
|
||||
--image state
|
||||
if isonground()==false then
|
||||
player.walking=false
|
||||
player.jumping=true
|
||||
else player.jumping=false
|
||||
end
|
||||
|
||||
--eat coins
|
||||
if coins_collected==false then
|
||||
eatcoin()
|
||||
end
|
||||
-- getkey()
|
||||
-- if chest_collected==false then
|
||||
-- openchest()
|
||||
-- end
|
||||
|
||||
end
|
||||
|
||||
function drawplayer()
|
||||
if player.inwater==true then
|
||||
player.image=36
|
||||
elseif player.walking==true then
|
||||
player.timer+=1
|
||||
if player.timer%6==0 then
|
||||
sfx(2)
|
||||
if player.image==3 then
|
||||
player.image=19
|
||||
else
|
||||
player.image=3
|
||||
end
|
||||
end
|
||||
elseif player.jumping==true then
|
||||
player.image=35
|
||||
else player.image=3
|
||||
end
|
||||
spr(player.image,player.x,player.y,1,1,player.dir)
|
||||
end
|
||||
|
||||
------------
|
||||
|
||||
function issolid(x,y)
|
||||
local tile=mget(flr(x/8),flr(y/8))
|
||||
local f=fget(tile)
|
||||
if f==1 then
|
||||
return true
|
||||
else return false
|
||||
end--if
|
||||
end
|
||||
|
||||
function trymove(x,y,dx,dy)
|
||||
local new_x=x+dx
|
||||
local new_y=y+dy
|
||||
local collided_x=false
|
||||
local collided_y=false
|
||||
|
||||
if dx>0 then --right
|
||||
for i=0,player.h-1 do
|
||||
if issolid(new_x+player.w-1,new_y+i) then
|
||||
collided_x=true
|
||||
break
|
||||
end --if
|
||||
end --for
|
||||
end --if
|
||||
if dx<0 then --left
|
||||
for i=0,player.h-1 do
|
||||
if issolid(new_x,new_y+i) then
|
||||
collided_x=true
|
||||
break
|
||||
end --if
|
||||
end --for
|
||||
end --if
|
||||
if dy>0 then --down
|
||||
for i=0,player.w-1 do
|
||||
if issolid(new_x+i,new_y+player.h-1) then
|
||||
collided_y=true
|
||||
break
|
||||
end --if
|
||||
end --for
|
||||
end --if
|
||||
if dy<0 then --up
|
||||
for i=0,player.w-1 do
|
||||
if issolid(new_x+i,new_y) then
|
||||
collided_y=true
|
||||
break
|
||||
end --if
|
||||
end --for
|
||||
end --if
|
||||
|
||||
if new_y<0 then
|
||||
dy=0
|
||||
collided_y=true
|
||||
end
|
||||
|
||||
if collided_x==true then
|
||||
dx=0
|
||||
end
|
||||
if collided_y==true then
|
||||
dy=0
|
||||
end
|
||||
|
||||
return x+dx,y+dy,dx,dy
|
||||
end
|
||||
|
||||
function isonground()
|
||||
for i=0,player.w-1 do
|
||||
if issolid(player.x+i,player.y+player.h) then
|
||||
return true
|
||||
end --if
|
||||
end --for
|
||||
return false
|
||||
end
|
||||
|
||||
----------
|
||||
function isinwater(x,y)
|
||||
local x1=flr(x/8)
|
||||
local y1=flr(y/8)
|
||||
if water_state[x1][y1]==true then
|
||||
return true
|
||||
else return false
|
||||
end--if
|
||||
end
|
||||
|
||||
-->8
|
||||
function initwater()
|
||||
water_map={}
|
||||
water_state={}
|
||||
water_level=mymap.h-1
|
||||
rising=true
|
||||
maxtime=30
|
||||
water_timer=maxtime
|
||||
|
||||
for x=0,mymap.w-1 do
|
||||
water_map[x]={}
|
||||
water_state[x]={}
|
||||
for y=0,mymap.h-1 do
|
||||
local tile=mget(x,y)
|
||||
local f=fget(tile)
|
||||
if f!=1 and f!=4 then
|
||||
water_map[x][y]=true --not solid
|
||||
else water_map[x][y]=false --ground
|
||||
end--if
|
||||
water_state[x][y]=false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function water_rise()
|
||||
if water_level>0 then
|
||||
water_level-=1
|
||||
for i=0,mymap.w-1 do
|
||||
if water_map[i][water_level]==true then
|
||||
water_state[i][water_level]=true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function water_fall()
|
||||
if water_level<mymap.h-1 then
|
||||
for i=0,mymap.w-1 do
|
||||
if water_map[i][water_level]==true then
|
||||
water_state[i][water_level]=false
|
||||
end
|
||||
end
|
||||
water_level+=1
|
||||
end
|
||||
end
|
||||
|
||||
function updatewater()
|
||||
water_timer-=1
|
||||
if water_timer==0 then
|
||||
water_timer=maxtime
|
||||
|
||||
if rising==true then
|
||||
water_rise()
|
||||
else water_fall()
|
||||
end
|
||||
end
|
||||
|
||||
---schedule
|
||||
if water_level==3 and rising==true then
|
||||
rising=false
|
||||
elseif water_level==mymap.h-1 and rising==false then
|
||||
rising=true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function drawwater()
|
||||
for x=0,mymap.w-1 do
|
||||
for y=0,mymap.h-1 do
|
||||
if water_state[x][y]==true then
|
||||
if y==water_level then
|
||||
spr(20,x*8,y*8)
|
||||
elseif fget(mget(x,y-1))==4 then
|
||||
spr(20,x*8,y*8)
|
||||
else
|
||||
spr(4,x*8,y*8)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-->8
|
||||
function initcoins()
|
||||
score=0
|
||||
totalscore=3
|
||||
coins={}
|
||||
for x=0,mymap.w do
|
||||
for y=0,mymap.h do
|
||||
local tile=mget(x,y)
|
||||
if tile==5 then
|
||||
add(coins,{
|
||||
x=x*8,
|
||||
y=y*8,
|
||||
w=6,
|
||||
collected=false,
|
||||
timer=0
|
||||
})
|
||||
mset(x,y,2)
|
||||
end--if
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function eatcoin()
|
||||
for c in all(coins) do
|
||||
if c.collected==false and isoverlap(c.x,c.y,c.w)==true then
|
||||
c.collected=true
|
||||
sfx(0)
|
||||
score+=1
|
||||
c.timer=3
|
||||
end--if
|
||||
end--for
|
||||
end
|
||||
|
||||
function isoverlap(x0,y0,w0)
|
||||
local x=player.x
|
||||
local y=player.y
|
||||
if x+player.w<x0+(8-w0)/2 or x>x0+w0+(8-w0)/2 or y+player.h<y0+(8-w0)/2 or y>y0+w0+(8-w0)/2 then
|
||||
return false
|
||||
else return true
|
||||
end
|
||||
end
|
||||
|
||||
function drawcoins()
|
||||
for c in all(coins) do
|
||||
if c.collected==false then
|
||||
spr(5,c.x,c.y)
|
||||
elseif c.timer>0 then
|
||||
spr(21,player.x+8,player.y)
|
||||
spr(21,player.x-8,player.y,1,1,1)
|
||||
c.timer-=1
|
||||
end--if
|
||||
end
|
||||
print("score:"..score,player.x-8,1,4)
|
||||
print("/"..totalscore,player.x+20,1,4)
|
||||
if score==totalscore then
|
||||
coins_collected=true
|
||||
end
|
||||
end
|
||||
|
||||
------------
|
||||
|
||||
function initkey()
|
||||
for x=0,mymap.w do
|
||||
for y=0,mymap.h do
|
||||
local tile=mget(x,y)
|
||||
if tile==6 then
|
||||
key={
|
||||
x=x*8,
|
||||
y=y*8,
|
||||
w=6,
|
||||
collected=false
|
||||
}
|
||||
mset(x,y,34)
|
||||
break
|
||||
end--if
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function getkey()
|
||||
if key.collected==false and isoverlap(key.x,key.y,key.w)==true then
|
||||
key.collected=true
|
||||
sfx(0)
|
||||
end--if
|
||||
end
|
||||
|
||||
function drawkey()
|
||||
if key.collected==false then
|
||||
spr(6,key.x,key.y)
|
||||
elseif chest_collected==false then
|
||||
print("key:z to use",player.x+30,1,4)
|
||||
end
|
||||
end
|
||||
|
||||
function initchest()
|
||||
for x=0,mymap.w do
|
||||
for y=0,mymap.h do
|
||||
local tile=mget(x,y)
|
||||
if tile==7 then
|
||||
chest={
|
||||
x=x*8,
|
||||
y=y*8,
|
||||
w=8,
|
||||
collected=false,
|
||||
timer=0
|
||||
}
|
||||
mset(x,y,2)
|
||||
spr(7,key.x,key.y)
|
||||
break
|
||||
end--if
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function openchest()
|
||||
if btnp(🅾️) and key.collected==true and chest.collected==false and isoverlap(chest.x,chest.y,chest.w)==true then
|
||||
chest.collected=true
|
||||
chest_collected=true
|
||||
sfx(3)
|
||||
chest.timer=15
|
||||
end--if
|
||||
end
|
||||
|
||||
function drawchest()
|
||||
if chest.collected==false then
|
||||
spr(7,chest.x,chest.y)
|
||||
else
|
||||
if chest.timer>0 then
|
||||
chest.timer-=1
|
||||
spr(8,chest.x,chest.y-12+chest.timer/3)
|
||||
end
|
||||
spr(23,chest.x,chest.y)
|
||||
print("treasure found!",player.x+30,1,4)
|
||||
end
|
||||
end
|
||||
-->8
|
||||
function inittetris()
|
||||
alltetris={}
|
||||
current_t=nil
|
||||
speed=15
|
||||
t_type={
|
||||
--l
|
||||
[1]={{0,0},{0,1},{0,2},{1,2}},
|
||||
--l2
|
||||
[2]={{0,0},{1,0},{1,1},{1,2}},
|
||||
--j
|
||||
[3]={{1,0},{1,1},{1,2},{0,2}},
|
||||
--j2
|
||||
[4]={{0,0},{1,0},{0,1},{0,2}},
|
||||
--t
|
||||
[5]={{0,0},{1,0},{2,0},{1,1}},
|
||||
--t2
|
||||
[6]={{0,1},{1,0},{1,1},{1,2}},
|
||||
--z
|
||||
[7]={{0,0},{1,0},{1,1},{2,1}},
|
||||
--z2
|
||||
[8]={{0,1},{1,1},{1,0},{2,0}}
|
||||
}
|
||||
end
|
||||
|
||||
function newtetris()
|
||||
current_t={
|
||||
x=ceil(player.x/8)+2,
|
||||
y=0,
|
||||
x_min=ceil(player.x/8)+1,
|
||||
y_min=0,
|
||||
x_max=ceil(player.x/8)+8,
|
||||
y_max=mymap.h,
|
||||
type_id=flr(rnd(8))+1,
|
||||
blocks={},
|
||||
stopped=false,
|
||||
timer=0
|
||||
}
|
||||
for b in all(t_type[current_t.type_id]) do
|
||||
add(current_t.blocks,{b[1],b[2]})
|
||||
end
|
||||
end
|
||||
|
||||
function updatetetris()
|
||||
if current_t!=nil then
|
||||
current_t.timer+=1
|
||||
if current_t.timer==speed then
|
||||
trymove_t(0,1) --down
|
||||
|
||||
current_t.timer=0
|
||||
end
|
||||
|
||||
if btnp(⬅️) then
|
||||
trymove_t(-1,0)
|
||||
elseif btnp(➡️) then
|
||||
trymove_t(1,0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function trymove_t(dx,dy)
|
||||
for b in all(current_t.blocks) do
|
||||
local bx=current_t.x+b[1]+dx
|
||||
local by=current_t.y+b[2]+dy
|
||||
|
||||
if bx<current_t.x_min or
|
||||
bx>current_t.x_max then
|
||||
return
|
||||
elseif issolid(bx*8,by*8+8)==true then
|
||||
current_t.y+=dy
|
||||
current_t.stopped=true
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
current_t.x+=dx
|
||||
current_t.y+=dy
|
||||
return
|
||||
end
|
||||
|
||||
function stoptetris()
|
||||
draw_t_stopped()
|
||||
add(alltetris,current_t)
|
||||
tetris_mode=false
|
||||
current_t=nil
|
||||
end
|
||||
|
||||
function draw_t_stopped()
|
||||
if current_t!=nil then
|
||||
for b in all(current_t.blocks) do
|
||||
local bx=current_t.x+b[1]
|
||||
local by=current_t.y+b[2]
|
||||
mset(bx,by,10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function draw_t_falling()
|
||||
if current_t!=nil then
|
||||
for b in all(current_t.blocks) do
|
||||
local bx=current_t.x+b[1]
|
||||
local by=current_t.y+b[2]
|
||||
spr(10,bx*8,by*8)
|
||||
end
|
||||
end
|
||||
end
|
||||
__gfx__
|
||||
0000000033b3b3b377777777002eeee0cccccccc00000000000000000c1111c000000000000000007777777d0000000000000000000000000000000000000000
|
||||
000000003b333b3377777f7722222eeec11cc11c009a9a0000000cc0c111111c0100001000000000f999999d0000000000000000000000000000000000000000
|
||||
007007003333333377777777055797501cc11cc109a9a9a00000c880999889990100001000000000f999999d0000000000000000000000000000000000000000
|
||||
00077000444444447f77777755919195cccccccc09aaaa90000c8800c118811c0000000000000000f999999d0000000000000000000000000000000000000000
|
||||
00077000454445447777777705998990cccccccc09aaa9a00cc88000c118811c0eeeeee000000000f999999d0000000000000000000000000000000000000000
|
||||
00700700444544447777777700e2e2e0c11cc11c099aaa900c080000c111111c00eeee0000000000f999999d0000000000000000000000000000000000000000
|
||||
00000000444444547777f7770e02220e1cc11cc10099990008880000c111111c000ee00000000000f999999d0000000000000000000000000000000000000000
|
||||
00000000454444447777777700020200cccccccc0000000000000000c111111c0000000000000000111111110000000000000000000000000000000000000000
|
||||
000000004454444477777777002eeee000c100c10000000000000000c111111c0000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000544444547777777722222eeec11cc11c0009a000000000000c19a1c00000000000000000000000000000000000000000000000000000000000000000
|
||||
000000004445444477777777055797501cc11cc100900000000000000c9e9ac00000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000444444447777777755919195cccccccc0000000000000000c9a9e9ac0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000045444544b77777b705998990cccccccc00990a0000000000cccccccc0000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000444544447b777b7700e2e2e0c11cc11c0000000000000000c111111c0000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000444444547b77b777000e22e01cc11cc10090000000000000c111111c0000000000000000000000000000000000000000000000000000000000000000
|
||||
000000004544444477b7b77700022000cccccccc0009a00000000000c111111c0000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000000000077777777002eeee0002eeee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000007777777722222eee22222eee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000007777a77705519150055191500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000007777777755979795559797950000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000007a7777770e99899e009989900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000007777777700e2e2e00ee2e2ee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000777777a700022200700222070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000007777777700200020007202700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__gff__
|
||||
0001000002000000000001000000000000010000020000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__map__
|
||||
0202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020202020202020202020202020202020202020202020202020202020502020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020202020202020202020202020202050202020202020202020202010101010202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020205020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020201020202020202020202020202020101010102020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020211020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020111010202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020211020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020211020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202021102020202020202020202020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020202020202050202020202020202020202020202020202020202020202020202020202020202020202020205021102020202020202020202020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020101011102021212020212120205020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020201010101010102020202020202020202020202020205020212121202020202020202020202021202021102050202010101020201010101020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202020211222222221102020202020202020702020202020201010101010101010101020202020102010102021102020202110202020202020202020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202010111062222221102020202020202010101020202020211111111222222222211010202021102020202121102020101110202020202020202020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020205120202020211111102020202020212020202020202020202020211111111222222220511020202121102020202011102020202020202020202020202020202020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020201010102020202020202020202020101010202020202020202020211111111222201010111020202011102010102021102020202020202020202020202121212120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0202020202020202021202020202020201011105020202020202020202020211111111020202020202020202021102020202020202020202020202020202020201010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0212120202020202010101020212010111110202020202021202121202020211111111020202020202020202021102020202020202020202020202020101010111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0101010101010101111111010101111111111101010101010101010101010111111111010101010101010101011101010101010101010101010101011111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__sfx__
|
||||
000200001a0101d0201f0202002023020260202b02030020360103800037000360003400034000370003600036000340003400033000320003200022000220002200000000000000000000000000000000000000
|
||||
0101000013050130501106013060180601a0601c0501d000287002870028700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000100000c0510c0062eb0630b0732b0736b0700000080000c0000e8061cb05303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000800001850015560175601856015560185601c5601f5601f560255002c5002a0002b0002a000290002800027000250002300021000210002100022000220000000000000000000000000000000000000000000
|
||||
0010000000000000000000026050240502305022050200501d0501905015050120501105011050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0020000018a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
29
untitled_3.p8
Normal file
29
untitled_3.p8
Normal file
@@ -0,0 +1,29 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
__lua__
|
||||
--main
|
||||
|
||||
function _init()
|
||||
|
||||
end
|
||||
|
||||
function _update()
|
||||
|
||||
end
|
||||
|
||||
function _draw()
|
||||
|
||||
end
|
||||
-->8
|
||||
--globals
|
||||
|
||||
-->8
|
||||
--state
|
||||
|
||||
__gfx__
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
Reference in New Issue
Block a user