Compare commits
4 Commits
bcc1e7f60e
...
ce00e70c7b
| Author | SHA1 | Date | |
|---|---|---|---|
| ce00e70c7b | |||
| 3e608882c9 | |||
| 09bea06850 | |||
| 42d5c1f308 |
100
data/actors.lua
100
data/actors.lua
@@ -6,51 +6,87 @@ actors={
|
|||||||
table.insert(actors.list, actor)
|
table.insert(actors.list, actor)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
search=function(name)
|
||||||
|
for i,v in ipairs(actors.list) do
|
||||||
|
if v.name and v.name==name then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
draw=function()
|
draw=function()
|
||||||
for i,v in ipairs(actors.list) do
|
for i,v in ipairs(actors.list) do
|
||||||
sspr(v.gfx.x,v.gfx.y,16,16,v.x*8+v.dx,v.y*8+v.dy,16,16,v.o)
|
local frame=((v.dx+v.dy)%2)*16
|
||||||
|
--print(v.o)
|
||||||
|
if v.o=='u' then
|
||||||
|
sspr(v.gfx.x+frame,v.gfx.y+16,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16)
|
||||||
|
elseif v.o=='d' then
|
||||||
|
sspr(v.gfx.x+frame,v.gfx.y,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16)
|
||||||
|
elseif v.o=='l' then
|
||||||
|
sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16)
|
||||||
|
elseif v.o=='r' then
|
||||||
|
sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
local needs_sorting=false
|
||||||
for i,v in ipairs(actors.list) do
|
for i,v in ipairs(actors.list) do
|
||||||
if v.dx==0 and v.dy==0 then
|
if v.dx==0 and v.dy==0 then
|
||||||
if v.path then
|
if v.path then
|
||||||
v.path.pos=v.path.pos+1
|
v.path.pos=v.path.pos+1
|
||||||
if v.path.pos > #v.path.route then
|
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
||||||
v.path=nil
|
if v.path.pos == #v.path.route then v.path=nil end
|
||||||
else
|
if step=='u' then
|
||||||
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
--check collision!
|
||||||
if step=='u' then
|
v.y=v.y-1
|
||||||
--check collision!
|
v.dy=4
|
||||||
v.y=v.y-1
|
v.o='u'
|
||||||
v.dy=-8
|
needs_sorting=true
|
||||||
elseif step=='d' then
|
elseif step=='d' then
|
||||||
--check collision!
|
--check collision!
|
||||||
v.y=v.y+1
|
v.y=v.y+1
|
||||||
v.dy=8
|
v.dy=-4
|
||||||
elseif step=='l' then
|
v.o='d'
|
||||||
--check collision!
|
needs_sorting=true
|
||||||
v.x=v.x-1
|
elseif step=='l' then
|
||||||
v.dx=-8
|
--check collision!
|
||||||
elseif step=='r' then
|
v.x=v.x-1
|
||||||
--check collision!
|
v.dx=4
|
||||||
v.x=v.x+1
|
v.o='l'
|
||||||
v.dx=8
|
elseif step=='r' then
|
||||||
end
|
--check collision!
|
||||||
|
v.x=v.x+1
|
||||||
|
v.dx=-4
|
||||||
|
v.o='r'
|
||||||
|
elseif step=='q' then
|
||||||
|
v.o='u'
|
||||||
|
elseif step=='a' then
|
||||||
|
v.o='d'
|
||||||
|
elseif step=='o' then
|
||||||
|
v.o='l'
|
||||||
|
elseif step=='p' then
|
||||||
|
v.o='r'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
if v.dx > 0 then
|
if v.dx > 0 then
|
||||||
v.dx=v.dx-2
|
v.dx=v.dx-1
|
||||||
elseif v.dx < 0 then
|
elseif v.dx < 0 then
|
||||||
v.dx=v.dx+2
|
v.dx=v.dx+1
|
||||||
elseif v.dy > 0 then
|
elseif v.dy > 0 then
|
||||||
v.dy=v.dy-2
|
v.dy=v.dy-1
|
||||||
elseif v.dy < 0 then
|
elseif v.dy < 0 then
|
||||||
v.dy=v.dy+2
|
v.dy=v.dy+1
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if needs_sorting then
|
||||||
|
table.sort(actors.list, compare_actors)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function compare_actors(a,b)
|
||||||
|
return a.y < b.y
|
||||||
|
end
|
||||||
|
|||||||
48
data/balloon.lua
Normal file
48
data/balloon.lua
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
balloon={
|
||||||
|
text=nil,
|
||||||
|
height=0,
|
||||||
|
tail={pos=0,under=true},
|
||||||
|
pos=0,
|
||||||
|
cursor={x=0,y=0},
|
||||||
|
old_update=nil,
|
||||||
|
|
||||||
|
show=function(txt,height,tail)
|
||||||
|
balloon.text=txt
|
||||||
|
balloon.height=height
|
||||||
|
balloon.tail=tail
|
||||||
|
balloon.pos=0
|
||||||
|
balloon.cursor={x=0,y=0}
|
||||||
|
balloon.old_update=update
|
||||||
|
update=balloon.update
|
||||||
|
|
||||||
|
if balloon.tail.under then
|
||||||
|
rectfill(9,height-50,153,height-15,5)
|
||||||
|
rectfill(8,height-51,152,height-16,8)
|
||||||
|
rect(8,height-51,152,height-16,6)
|
||||||
|
|
||||||
|
local pos=balloon.tail.pos
|
||||||
|
if pos<80 then
|
||||||
|
for i=0,4 do rect(pos,height-16+(4-i),pos+i,height-16+(4-i),8) end
|
||||||
|
line(pos-1,height-15,pos-1,height-10,6)
|
||||||
|
line(pos+4,height-15,pos-1,height-10,6)
|
||||||
|
else
|
||||||
|
for i=0,4 do rect(pos+i,height-16+i,pos+4,height-16+i,8) end
|
||||||
|
line(pos+5,height-15,pos+5,height-10,6)
|
||||||
|
line(pos,height-15,pos+5,height-10,6)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
text("12345678901234567890123456789012\n3",16,height-44, 2)
|
||||||
|
text("UNO DOS TRES",16,height-35, 2)
|
||||||
|
text("UNO DOS TRES",16,height-26, 2)
|
||||||
|
end,
|
||||||
|
|
||||||
|
draw=function()
|
||||||
|
if ballon.text then
|
||||||
|
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
update=function()
|
||||||
|
end
|
||||||
|
}
|
||||||
@@ -3,4 +3,4 @@ config=ja2
|
|||||||
width=160
|
width=160
|
||||||
height=144
|
height=144
|
||||||
zoom=5
|
zoom=5
|
||||||
files=game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
files=balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
||||||
|
|||||||
@@ -3,12 +3,40 @@ game={
|
|||||||
|
|
||||||
init=function()
|
init=function()
|
||||||
mapa.load("test.map")
|
mapa.load("test.map")
|
||||||
|
actors.add({name="usufondo",x=11,y=9,o="r",gfx={x=0,y=0},path={pos=0,route='rrrruro'}})
|
||||||
|
actors.add({name="jailer",x=6,y=9,o="r",gfx={x=32,y=0}})
|
||||||
update=game.update
|
update=game.update
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
local hero = actors.search("jailer")
|
||||||
|
if hero then
|
||||||
|
game.cam.x = hero.x*8 + hero.dx*2 - 80
|
||||||
|
if game.cam.x < 0 then game.cam.x=0 end
|
||||||
|
game.cam.y = hero.y*8 + hero.dy*2 - 72
|
||||||
|
if game.cam.y < 0 then game.cam.y=0 end
|
||||||
|
end
|
||||||
camera(game.cam.x, game.cam.y)
|
camera(game.cam.x, game.cam.y)
|
||||||
|
setsource(tiles)
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
map(0,0,0,0,mapa.w, mapa.h)
|
||||||
|
setsource(sprites)
|
||||||
|
actors.draw()
|
||||||
camera(0,0)
|
camera(0,0)
|
||||||
|
|
||||||
|
balloon.show("HOLA", hero.y*8, {pos=90,under=true})
|
||||||
|
|
||||||
|
if hero and not hero.path and hero.dx+hero.dy==0 then
|
||||||
|
if btn(KEY_DOWN) then
|
||||||
|
hero.path={pos=0,route='d'}
|
||||||
|
elseif btn(KEY_UP) then
|
||||||
|
hero.path={pos=0,route='u'}
|
||||||
|
elseif btn(KEY_LEFT) then
|
||||||
|
hero.path={pos=0,route='l'}
|
||||||
|
elseif btn(KEY_RIGHT) then
|
||||||
|
hero.path={pos=0,route='r'}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if beat() then actors.update() end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ function _init()
|
|||||||
setsource(tiles)
|
setsource(tiles)
|
||||||
local pal=loadpal("tiles.gif")
|
local pal=loadpal("tiles.gif")
|
||||||
setpal(pal)
|
setpal(pal)
|
||||||
|
beat(6)
|
||||||
main_init()
|
main_init()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
BIN
data/sprites.gif
BIN
data/sprites.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user