new stuff
This commit is contained in:
193
level_crawler/level_test.p8
Normal file
193
level_crawler/level_test.p8
Normal 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
|
8
level_crawler/readme.md
Normal file
8
level_crawler/readme.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 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
|
||||
|
||||
|
Reference in New Issue
Block a user