- WIP animated tiles
This commit is contained in:
15
main.lua
15
main.lua
@@ -72,7 +72,7 @@ function update_dialog()
|
|||||||
_update=update_game
|
_update=update_game
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
scroll=0
|
||||||
function update_game()
|
function update_game()
|
||||||
cls(16)
|
cls(16)
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ function update_game()
|
|||||||
draw_hab(abad.hab,0,0,true)
|
draw_hab(abad.hab,0,0,true)
|
||||||
text(abad.hab,120,1,2)
|
text(abad.hab,120,1,2)
|
||||||
|
|
||||||
sspr(0,64,128,48,0,48)
|
sspr(0,64+scroll*8,128,48,0,48)
|
||||||
color(3)
|
color(3)
|
||||||
local xx=(seltile&15)*8
|
local xx=(seltile&15)*8
|
||||||
local yy=48+(seltile>>4)*8
|
local yy=48+(seltile>>4)*8
|
||||||
@@ -88,6 +88,7 @@ function update_game()
|
|||||||
text("EDIT",100,1,3)
|
text("EDIT",100,1,3)
|
||||||
local hx = abad.hab%10
|
local hx = abad.hab%10
|
||||||
local hy = flr(abad.hab/10)
|
local hy = flr(abad.hab/10)
|
||||||
|
scroll=0
|
||||||
if btnp(KEY_RIGHT) and hx<9 then
|
if btnp(KEY_RIGHT) and hx<9 then
|
||||||
abad.hab=abad.hab+1
|
abad.hab=abad.hab+1
|
||||||
elseif btnp(KEY_LEFT) and hx>0 then
|
elseif btnp(KEY_LEFT) and hx>0 then
|
||||||
@@ -104,6 +105,9 @@ function update_game()
|
|||||||
elseif btnp(KEY_C) then
|
elseif btnp(KEY_C) then
|
||||||
mapa_cycle_colors(abad.hab)
|
mapa_cycle_colors(abad.hab)
|
||||||
end
|
end
|
||||||
|
if btn(KEY_TAB) then
|
||||||
|
scroll=2
|
||||||
|
end
|
||||||
|
|
||||||
local mx,my=mousex(),mousey()
|
local mx,my=mousex(),mousey()
|
||||||
if mx>>3 < 12 and my>>3 < 6 then
|
if mx>>3 < 12 and my>>3 < 6 then
|
||||||
@@ -113,13 +117,13 @@ function update_game()
|
|||||||
end
|
end
|
||||||
if mbtn(1) then
|
if mbtn(1) then
|
||||||
if my>=48 then
|
if my>=48 then
|
||||||
seltile=(mx>>3)+((my-48)>>3)*16
|
seltile=(mx>>3)+((my-48+(scroll*8))>>3)*16
|
||||||
elseif mx<96 then
|
elseif mx<96 then
|
||||||
mapa_set_tile(abad.hab,mx>>3,my>>3,seltile)
|
mapa_set_tile(abad.hab,mx>>3,my>>3,seltile)
|
||||||
end
|
end
|
||||||
elseif mbtn(3) then
|
elseif mbtn(3) then
|
||||||
if my<48 and mx<96 then
|
if my<48 and mx<96 then
|
||||||
mapa_set_tile(abad.hab,mx>>3,my>>3,255)
|
mapa_set_tile(abad.hab,mx>>3,my>>3,256)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if mx>>3 < 12 and my>>3 < 6 then
|
if mx>>3 < 12 and my>>3 < 6 then
|
||||||
@@ -130,11 +134,14 @@ function update_game()
|
|||||||
draw_hab(abad.hab,0,0)
|
draw_hab(abad.hab,0,0)
|
||||||
text(abad.hab,1,1,2)
|
text(abad.hab,1,1,2)
|
||||||
draw_hab(premiere.hab,0,48)
|
draw_hab(premiere.hab,0,48)
|
||||||
|
text("Premiere",2,49,2)
|
||||||
|
|
||||||
score.draw()
|
score.draw()
|
||||||
setsource(tiles)
|
setsource(tiles)
|
||||||
prnt("x"..abad.vides,114,13,2)
|
prnt("x"..abad.vides,114,13,2)
|
||||||
rectfill(102+(abad.energia>>1),30,122,37,16)
|
rectfill(102+(abad.energia>>1),30,122,37,16)
|
||||||
|
|
||||||
|
mapa_update()
|
||||||
for key,actor in pairs(actors) do
|
for key,actor in pairs(actors) do
|
||||||
actor:update()
|
actor:update()
|
||||||
if actor.hab==cacau.hab and actor~=abad then
|
if actor.hab==cacau.hab and actor~=abad then
|
||||||
|
|||||||
25
mapa.lua
25
mapa.lua
@@ -1,6 +1,7 @@
|
|||||||
--mapa={}
|
--mapa={}
|
||||||
tiletype={void=0,stair=1,switch=2,half=3,block=4}
|
tiletype={void=0,stair=1,switch=2,half=3,block=4}
|
||||||
|
mapa.wait=0
|
||||||
|
mapa.step=0
|
||||||
function mapa_do_backup()
|
function mapa_do_backup()
|
||||||
mapa_backup={}
|
mapa_backup={}
|
||||||
for i=1,#mapa do
|
for i=1,#mapa do
|
||||||
@@ -26,7 +27,7 @@ function mapa_new()
|
|||||||
mapa[mi]={}
|
mapa[mi]={}
|
||||||
for ty=0,5 do
|
for ty=0,5 do
|
||||||
for tx=0,11 do
|
for tx=0,11 do
|
||||||
local tile=255
|
local tile=256
|
||||||
if mx==0 and tx==0 then
|
if mx==0 and tx==0 then
|
||||||
tile=16
|
tile=16
|
||||||
elseif mx==4 and tx==11 then
|
elseif mx==4 and tx==11 then
|
||||||
@@ -61,11 +62,29 @@ function mapa_save()
|
|||||||
io.close(file)
|
io.close(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
anim_tiles={177,178,176}
|
||||||
|
function mapa_update()
|
||||||
|
mapa.wait=mapa.wait+1
|
||||||
|
|
||||||
|
if mapa.wait==6 then
|
||||||
|
mapa.wait=0
|
||||||
|
mapa.step=(mapa.step+1)&7
|
||||||
|
for ty=0,5 do
|
||||||
|
for tx=0,11 do
|
||||||
|
local tile=mapa[1+hab][1+tx+ty*12]
|
||||||
|
if tile>=176 and tile<190 then
|
||||||
|
mapa[1+hab][1+tx+ty*12]=anim_tiles[tile-175]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function mapa_draw(hab)
|
function mapa_draw(hab)
|
||||||
for ty=0,5 do
|
for ty=0,5 do
|
||||||
for tx=0,11 do
|
for tx=0,11 do
|
||||||
local tile=mapa[1+hab][1+tx+ty*12]
|
local tile=mapa[1+hab][1+tx+ty*12]
|
||||||
if tile~=255 then
|
if tile~=256 and (tile<190 or mapa.step~=0) then
|
||||||
sspr((tile&15)*8,64+(tile>>4)*8,8,8,tx*8,ty*8)
|
sspr((tile&15)*8,64+(tile>>4)*8,8,8,tx*8,ty*8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function switches.update()
|
|||||||
|
|
||||||
if switches.wait==6 then
|
if switches.wait==6 then
|
||||||
switches.wait=0
|
switches.wait=0
|
||||||
mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,255)
|
mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,256)
|
||||||
switches.current_index=switches.current_index+1
|
switches.current_index=switches.current_index+1
|
||||||
if switches.current_index>#switches.current_list then
|
if switches.current_index>#switches.current_list then
|
||||||
switches.current_list=nil
|
switches.current_list=nil
|
||||||
|
|||||||
Reference in New Issue
Block a user