Primer render de múltiples habitacions en pantalla al mateix temps

This commit is contained in:
2026-03-18 16:48:06 +01:00
parent f218255f14
commit 59fc474770
5 changed files with 1160 additions and 23 deletions

View File

@@ -12,7 +12,13 @@ function frame() -- llama esto cada frame; recibe dt si tu motor lo proporciona
frame_count = 0
last_time = now
end
return fps
return math.floor(fps)
end
function fps_print()
local current_fps = frame()
draw.rectf(0,0,29,7,16)
draw.text(current_fps.." fps",1,1,2)
end
-- ejemplo de uso dentro de tu bucle:

149
data/game.lua Normal file
View File

@@ -0,0 +1,149 @@
require "fps"
require "mapa"
local arcade_config = require("arcade_config")
o2aX = arcade_config.org2arc_escala
local txr = arcade_config.tiles_per_row-1
local txr2 = arcade_config.tiles_per_row_base2
local toff= arcade_config.tiles_offset
local tw = arcade_config.tiles_width
local th = arcade_config.tiles_height
function game_init(menu)
game_update=update_game
end
function render_view ( hab )
-- el mapa te 10 habitacions d'ample
room_width = tw*12
room_height = th*6
room_x_offset = 0
draw_1st_col = 0
draw_2nd_col = 0
x_offset_col1 = 0
x_offset_col2 = room_width
x_offset_col3 = 2*room_width
y_offset_row1 = (arcade_config.resolucion.height-3*room_height)/2
y_offset_row2 = (arcade_config.resolucion.height-room_height)/2
y_offset_row3 = (arcade_config.resolucion.height+room_height)/2
-- 1ª columna d'habitacions
curr_hab = hab-10-1
if curr_hab>=0 then
draw_hab(curr_hab,x_offset_col1,y_offset_row1)
draw_1st_col = 1
end
curr_hab = hab-1
if curr_hab>=10 then
draw_hab(curr_hab,x_offset_col1,y_offset_row2)
draw_1st_col = 1
end
curr_hab = hab+10-1
if curr_hab>=20 then
draw_hab(curr_hab,x_offset_col1,y_offset_row3)
draw_1st_col = 1
end
-- 2ª columna d'habitacions
room_x_offset = x_offset_col1
if draw_1st_col == 1 then
room_x_offset = x_offset_col2
end
curr_hab = hab-10
if curr_hab>=0 then
draw_hab(curr_hab,room_x_offset,y_offset_row1)
end
curr_hab = hab
if curr_hab>=10 then
draw_hab(curr_hab,room_x_offset,y_offset_row2)
end
curr_hab = hab+10
if hab+10+1>=20 then
draw_hab(hab+10+1,0,y_offset_row3)
end
-- 3ª columna d'habitacions
room_x_offset = x_offset_col2
if draw_1st_col == 1 then
room_x_offset = x_offset_col3
end
curr_hab = hab-10+1
if curr_hab>=0 then
draw_hab(curr_hab,room_x_offset,y_offset_row1)
end
curr_hab = hab+1
if curr_hab>=10 then
draw_hab(curr_hab,room_x_offset,y_offset_row2)
end
curr_hab = hab+10+1
if curr_hab>=20 then
draw_hab(curr_hab,room_x_offset,y_offset_row3)
end
end
function update_game()
surf.target(0)
surf.cls(16)
-- surf.target(logo)
-- surf.cls(16)
-- draw.text("UPDATE_GAME",0,0,15)
-- surf.source(logo)
-- draw.surf(0,0,36,5,56,70,arcade_config.logo_sf.width,arcade_config.logo_sf.height)
surf.source(tiles)
render_view(10)
fps_print()
--- if abad.hurting == 0 then
--- draw_hab(abad.hab,0,0)
--- --text(abad.hab,1,1,2)
--- draw_hab(cameras[current_camera].hab,0,48)
--- -- text(camera_names[current_camera],2*o2aX,49*o2aX,8)
--- arc_textB(camera_names[current_camera],2*o2aX,49*o2aX,8)
---
--- score.draw()
--- surf.source(tiles)
--- -- draw.text("x"..abad.vides,114*o2aX,13*o2aX,2)
--- arc_text("x"..abad.vides,114*o2aX,13*o2aX,2)
--- draw.rectf((102+(abad.energia>>1))*o2aX,30*o2aX,(21-(abad.energia>>1))*o2aX,8*o2aX,16)
--- else
--- draw.surf(0,0,16*o2aX,9*o2aX,50*o2aX,40*o2aX,16*o2aX,9*o2aX,true)
--- if abad.hurting > 40 then
--- -- draw.text("x"..abad.vides+1,63*o2aX,43*o2aX,3)
--- arc_text("x"..abad.vides+1,63*o2aX,43*o2aX,3)
--- elseif abad.hurting < 20 then
--- -- draw.text("x"..abad.vides,63*o2aX,43*o2aX,2)
--- arc_text("x"..abad.vides,63*o2aX,43*o2aX,2)
--- end
--- end
---
--- mapa_update(abad.hab,cameras[current_camera].hab)
end
function draw_hab(hab,x,y,editing)
view.origin(x,y)
mapa_draw(hab)
-- if not editing then
-- for key,actor in pairs(actors) do
-- if actor.hab==hab then
-- actor:draw()
-- end
-- end
-- if imp.hab==hab then imp.draw() end
-- if bambolla.hab==hab then bambolla.draw() end
-- if cacau.hab==hab then cacau:draw() end
-- if fireball.hab==hab then fireball:draw() end
-- end
view.origin(0,0)
end

View File

@@ -1,9 +1,8 @@
require "fps"
require "fade"
require "game"
-- require "game"
-- require "mapa"
-- require "scenes"
@@ -26,23 +25,33 @@ function intro_init()
draw.surf(0,0,36,5,56,70,arcade_config.logo_sf.width,arcade_config.logo_sf.height)
-- surf.source(tiles)
-- fade.fadein()
fade.fadein()
end
function intro_intro()
-- text("presenta",48,50,14)
intro_wait=intro_wait-1
if intro_wait==0 or key.press(key.ESCAPE) or key.press(keyShoot) or pad.press(btnShoot) or pad.press(btnPause) then
intro_wait=1
-- game_update = intro_update
game_update = print_fps
game_update = intro_update
fade.fadeoutin()
end
end
function draw_item_intro( name, flip )
function intro_update()
fps_print()
if key.press(key.ESCAPE) or pad.press(btnPause) then
game_init(true)
fade.fadeoutin()
elseif key.press(key.SPACE) then
intro_wait=1
end
end
-- RESTOS DEL X2 CACAUS
function _draw_item_intro( name, flip )
local cw = arcade_config.character_width
local ch = arcade_config.character_height
if ( name == "abad" ) then
@@ -58,7 +67,7 @@ function draw_item_intro( name, flip )
end
end
function draw_escenari ()
function _draw_escenari ()
surf.cls(16)
draw_item_intro("marc",false)
view.origin(16*o2aX,4*o2aX)
@@ -67,19 +76,7 @@ function draw_escenari ()
draw_item_intro("pas porta")
end
function print_fps ()
print("IN")
local current_fps = frame()
surf.cls(16)
surf.target(logo)
surf.cls(16)
draw.text(current_fps.."fps",0,0,15)
surf.target(0)
surf.source(logo)
draw.surf(0,0,36,5,56,70,arcade_config.logo_sf.width,arcade_config.logo_sf.height)
end
function intro_update()
function _intro_update()
if key.press(key.ESCAPE) or pad.press(btnPause) then
game_init(true)
fade.fadeoutin()

802
data/map.lua Normal file
View File

@@ -0,0 +1,802 @@
mapa={
-- 1
{
256,256,256,18,19,21,20,21,20,21,20,21,
64,68,256,16,72,256,256,256,256,256,256,256,
256,256,66,256,88,256,256,70,71,256,256,256,
256,66,256,16,256,112,256,86,87,256,114,256,
66,256,256,16,256,256,256,256,256,256,256,256,
256,64,256,16,20,21,20,21,20,21,20,21,
},
-- 2
{
20,21,20,21,20,21,20,21,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,73,74,256,256,256,256,73,74,256,256,
256,256,89,90,256,256,256,256,89,90,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,21,256,80,17,20,21,
},
-- 3
{
20,21,20,21,20,21,20,21,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,256,256,
256,96,97,96,256,73,74,256,97,96,96,256,
256,99,256,100,256,89,90,256,99,256,100,256,
256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 4
{
20,21,20,21,20,21,20,21,20,21,18,19,
256,256,256,256,256,256,256,256,256,256,77,17,
256,73,74,256,256,73,74,256,98,98,93,17,
256,89,90,256,256,89,90,256,99,100,256,256,
256,256,256,256,256,256,256,256,10,11,256,256,
20,21,20,21,20,21,20,21,10,11,20,21,
},
-- 5
{
66,256,256,67,256,65,256,64,256,256,256,66,
256,256,64,256,256,256,256,256,256,68,256,67,
18,19,18,19,18,19,18,19,256,256,65,256,
256,256,256,256,256,256,256,16,256,256,256,256,
256,256,256,256,256,256,256,16,256,64,256,66,
20,21,20,21,20,21,20,21,256,256,66,256,
},
-- 6
{
256,66,256,41,44,45,44,45,44,45,44,45,
64,256,256,41,256,256,256,256,256,256,256,256,
68,256,66,256,256,256,96,97,256,256,256,256,
256,67,256,41,256,256,99,100,256,256,256,256,
65,256,256,41,95,256,256,256,10,11,256,256,
256,65,42,43,44,45,44,45,10,11,44,45,
},
-- 7
{
42,43,256,256,256,256,65,256,256,256,256,64,
256,41,256,67,256,256,256,256,68,256,256,256,
256,41,256,256,256,66,256,256,256,256,256,256,
256,256,256,64,256,256,65,256,67,256,67,256,
256,256,256,256,256,256,256,256,256,256,256,256,
42,43,20,21,20,21,20,21,20,21,20,21,
},
-- 8
{
67,256,256,256,256,65,256,256,256,256,64,256,
256,256,67,256,256,256,256,68,256,256,256,256,
256,256,256,256,66,256,256,256,256,256,256,67,
256,256,64,256,256,65,256,67,256,67,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
20,21,20,21,17,256,256,17,20,21,20,21,
},
-- 9
{
256,256,256,256,65,256,256,256,256,64,17,17,
256,67,256,256,256,256,68,256,256,256,17,256,
256,256,256,66,256,256,256,256,256,256,17,256,
256,64,256,256,65,256,67,256,67,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 10
{
17,17,17,17,17,17,17,17,17,17,18,19,
256,256,256,256,256,256,256,256,256,256,17,17,
256,256,73,74,256,256,73,74,256,256,18,19,
256,256,89,90,256,256,89,90,256,256,17,17,
256,256,256,256,256,256,256,256,256,256,18,19,
20,21,256,80,17,18,19,17,18,19,17,17,
},
-- 11
{
256,66,26,27,28,29,28,29,26,27,28,29,
256,256,256,24,256,256,256,256,15,25,256,256,
64,68,256,256,256,256,256,256,256,25,256,256,
256,256,66,24,256,121,256,256,256,38,256,256,
256,66,256,24,101,102,103,256,256,38,256,256,
66,256,256,24,28,29,28,29,28,29,28,29,
},
-- 12
{
28,29,28,29,28,29,29,256,256,256,26,27,
256,256,256,256,256,256,256,256,256,25,72,256,
256,256,73,74,256,256,256,256,1,256,88,256,
256,256,89,90,256,256,256,1,256,256,256,256,
256,256,256,256,256,256,1,256,256,256,256,256,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 13
{
28,29,26,27,26,27,28,29,28,29,28,29,
256,256,256,26,27,256,256,256,256,256,256,256,
256,256,256,256,256,256,256,256,73,74,256,256,
256,256,256,98,98,256,256,256,89,90,256,256,
256,256,104,101,102,103,256,256,256,256,256,256,
28,29,28,29,28,29,29,256,81,25,28,29,
},
-- 14
{
28,29,28,29,28,29,28,29,10,11,28,25,
256,256,256,256,256,256,256,256,10,11,256,25,
256,73,74,256,256,256,256,256,10,11,256,256,
256,89,90,256,256,75,76,256,10,11,256,25,
256,256,256,256,256,91,92,256,10,11,256,25,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 15
{
26,27,26,27,28,29,28,29,26,27,26,27,
28,29,256,256,256,256,256,256,256,256,28,24,
256,256,256,256,256,73,74,256,256,256,256,24,
256,256,75,76,256,89,90,256,75,76,256,24,
256,256,91,92,256,256,256,256,91,92,256,24,
26,27,28,29,28,29,28,29,28,29,26,27,
},
-- 16
{
64,256,26,27,28,29,28,29,10,11,28,29,
68,256,66,25,256,256,256,256,10,11,256,256,
256,67,256,256,256,107,108,256,10,11,256,256,
65,256,256,25,256,109,110,256,10,11,256,256,
256,65,256,25,256,256,256,256,10,11,256,256,
256,256,26,27,28,29,28,29,10,11,28,29,
},
-- 17
{
28,29,28,29,25,41,44,45,44,45,44,45,
256,256,256,256,25,41,256,256,256,256,256,256,
256,73,74,256,25,41,256,256,73,74,256,256,
256,89,90,78,25,41,256,256,89,90,256,256,
256,256,95,94,25,41,256,256,10,11,256,256,
28,29,28,29,25,41,44,45,10,11,44,45,
},
-- 18
{
44,45,44,45,41,256,256,41,44,45,44,45,
256,256,256,256,256,69,256,256,256,256,256,256,
256,256,256,256,256,256,69,256,256,256,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
256,256,256,41,41,256,69,41,41,256,256,256,
45,44,45,42,43,256,256,42,43,44,45,44,
},
-- 19
{
44,45,44,45,42,43,42,43,44,45,44,45,
256,256,256,256,256,40,40,256,256,256,256,256,
256,97,98,97,256,40,40,256,98,97,96,256,
256,99,256,100,256,40,40,256,99,256,100,256,
256,256,256,256,256,40,40,256,256,256,256,256,
3,41,83,256,44,45,44,45,44,45,44,45,
},
-- 20
{
44,45,256,256,256,42,43,41,42,43,41,41,
256,256,256,256,41,41,256,256,256,77,42,43,
256,256,256,3,256,41,256,256,256,93,41,41,
256,256,3,256,256,39,256,256,256,256,42,43,
256,3,256,256,256,38,256,256,8,9,41,41,
44,45,44,45,44,45,44,45,8,9,42,43,
},
-- 21
{
34,35,36,37,36,37,36,37,36,37,36,37,
32,256,256,256,256,256,256,256,256,256,256,256,
32,256,97,97,98,256,256,256,97,96,97,256,
32,256,99,256,100,256,256,256,99,256,100,256,
32,256,8,9,256,104,101,102,103,256,256,256,
34,35,8,9,36,37,36,37,36,37,36,37,
},
-- 22
{
36,37,33,33,36,37,36,37,33,33,36,37,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,256,256,96,97,96,98,256,256,256,256,
256,256,113,256,99,256,256,100,256,114,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 23
{
37,36,37,36,37,36,37,256,256,256,36,37,
256,256,256,256,256,256,256,256,256,33,256,256,
256,97,98,97,256,256,112,256,2,256,256,256,
256,99,256,100,256,256,256,2,256,75,76,256,
256,256,256,256,256,256,2,256,256,91,92,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 24
{
34,35,256,256,256,256,256,256,256,256,34,35,
256,2,34,35,34,35,34,35,34,35,2,256,
256,256,113,256,256,112,114,256,256,114,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
256,104,101,102,256,101,102,256,101,102,103,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 25
{
36,37,36,37,36,37,36,37,36,37,34,35,
256,256,256,256,256,256,73,74,256,256,77,32,
256,96,97,96,256,256,89,90,256,256,93,32,
256,99,256,100,256,121,256,256,256,256,256,32,
256,256,256,256,256,101,102,103,8,9,256,32,
36,37,36,37,36,37,36,37,8,9,33,32,
},
-- 26
{
18,19,17,17,18,19,17,17,10,11,18,19,
17,256,256,256,256,256,256,256,10,11,256,256,
18,19,256,256,256,256,256,256,10,11,256,256,
256,17,256,256,256,75,76,256,10,11,256,256,
18,19,256,256,256,91,92,256,10,11,256,256,
20,21,256,256,18,19,17,17,18,19,17,17,
},
-- 27
{
17,17,18,19,17,17,18,19,10,11,18,19,
256,256,256,256,256,256,256,256,10,11,256,256,
256,73,74,256,256,73,74,256,10,11,256,256,
256,89,90,256,256,89,90,256,10,11,256,256,
256,256,256,256,256,256,256,256,10,11,256,256,
17,17,18,19,17,256,80,17,18,19,17,17,
},
-- 28
{
18,19,17,18,19,256,256,33,33,34,35,33,
256,256,256,17,17,256,69,34,35,72,256,256,
256,256,256,18,19,256,69,33,33,88,256,256,
256,256,256,17,16,256,256,34,35,256,256,256,
256,256,256,18,19,69,256,41,33,256,256,256,
17,18,19,17,17,69,256,34,35,33,33,34,
},
-- 29
{
33,256,256,256,33,33,34,35,33,33,34,35,
256,33,256,256,256,256,256,256,256,256,256,256,
256,256,2,256,256,256,256,256,256,256,256,256,
256,256,256,2,256,256,256,117,98,106,116,256,
256,256,256,256,2,256,104,101,102,101,102,256,
34,35,33,33,34,35,33,33,34,35,33,33,
},
-- 30
{
33,33,34,35,33,33,34,35,8,9,33,33,
256,256,256,256,256,256,33,33,8,9,34,35,
256,256,256,256,256,97,34,35,8,9,33,33,
256,256,256,256,115,100,33,33,8,9,34,35,
256,256,256,104,101,102,34,35,8,9,33,33,
34,35,33,33,34,35,33,33,8,9,34,35,
},
-- 31
{
40,40,8,9,40,40,40,40,40,40,40,40,
40,45,8,9,45,44,45,44,45,44,45,44,
40,256,8,9,256,256,256,256,256,256,256,256,
40,256,8,9,256,256,112,75,76,113,256,256,
40,256,8,9,256,256,256,91,92,256,256,256,
42,43,44,45,44,45,44,45,44,45,44,45,
},
-- 32
{
40,40,40,40,40,40,40,40,40,40,40,40,
44,45,41,45,44,41,44,45,44,45,44,45,
256,256,38,256,256,38,256,256,256,256,256,256,
256,112,38,256,113,38,256,256,114,256,256,113,
256,256,38,256,256,38,256,256,256,256,256,256,
44,45,41,83,256,44,45,44,45,44,45,44,
},
-- 33
{
40,40,40,40,40,40,40,40,40,40,40,40,
43,44,45,44,45,42,43,44,45,44,45,42,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,75,76,256,114,113,256,75,76,256,256,
256,256,91,92,256,256,256,256,91,92,256,256,
44,45,44,45,44,45,44,45,44,45,44,45,
},
-- 34
{
40,40,40,40,40,40,40,40,40,40,40,40,
45,44,45,44,45,44,45,44,45,44,45,40,
256,256,256,256,256,256,256,256,73,74,256,40,
256,256,113,256,256,114,256,121,89,90,256,40,
256,256,256,256,256,256,256,101,102,103,256,40,
44,45,41,83,256,44,45,44,45,44,45,40,
},
-- 35
{
26,27,28,29,28,29,28,29,8,9,26,27,
24,15,256,256,256,256,256,256,8,9,256,24,
24,256,256,256,256,256,256,256,8,9,256,24,
24,256,256,256,256,256,256,256,8,9,256,24,
24,256,256,256,256,256,256,256,8,9,256,24,
26,27,28,29,28,29,28,29,8,9,26,27,
},
-- 36
{
24,29,256,256,1,25,26,27,25,1,28,29,
24,256,256,256,256,256,25,26,27,256,256,256,
24,256,256,256,256,256,256,256,25,256,256,256,
24,256,106,116,256,256,256,256,38,256,256,256,
24,25,101,102,256,256,256,256,38,256,256,256,
28,29,28,29,25,81,256,28,29,28,29,28,
},
-- 37
{
29,26,27,28,29,256,256,256,26,27,26,27,
256,256,256,256,256,256,256,25,256,256,28,29,
256,256,256,256,256,256,1,256,256,256,256,256,
256,112,256,256,256,1,256,256,256,256,113,256,
256,256,256,256,1,256,101,102,103,256,256,256,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 38
{
27,26,27,28,29,256,256,28,29,26,27,26,
29,256,256,256,256,256,69,256,256,256,256,28,
256,256,98,96,98,256,256,98,98,96,256,256,
256,256,99,256,100,256,256,99,256,100,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
29,28,29,28,29,69,256,28,29,28,29,28,
},
-- 39
{
28,29,25,25,28,29,25,25,28,29,25,25,
256,256,25,25,256,256,256,256,256,256,106,24,
256,256,15,256,256,256,256,256,256,256,95,24,
256,256,256,256,78,97,107,108,256,106,105,24,
256,256,256,256,94,101,102,110,103,105,98,24,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 40
{
24,29,28,29,28,29,28,29,8,9,26,27,
24,256,256,256,256,256,256,256,8,9,25,25,
24,256,114,256,256,256,112,256,8,9,26,27,
24,256,256,256,256,256,256,256,8,9,25,25,
24,256,256,256,105,256,256,256,8,9,26,27,
24,29,28,29,28,29,28,29,28,29,25,25,
},
-- 41
{
26,27,28,29,28,29,26,27,26,27,28,29,
24,72,256,256,256,256,256,28,29,256,256,256,
24,88,256,256,256,256,256,256,256,256,256,256,
24,256,256,256,112,256,256,256,256,256,114,256,
24,256,256,256,256,256,256,256,256,256,256,256,
28,29,28,29,28,29,25,81,256,28,29,29,
},
-- 42
{
28,29,256,256,256,1,26,27,26,27,28,29,
256,256,25,256,256,256,256,28,29,256,256,256,
256,256,256,1,256,256,256,256,256,256,256,256,
256,113,256,256,1,256,256,96,97,96,98,256,
256,256,256,256,256,1,256,101,256,256,102,256,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 43
{
28,29,28,29,26,27,26,27,28,29,26,27,
256,256,256,256,256,28,29,256,256,256,77,24,
256,256,256,256,256,256,256,256,256,256,93,24,
256,113,256,256,256,75,76,256,114,256,256,24,
256,256,10,11,256,91,92,256,256,256,256,24,
28,29,10,11,28,29,28,29,28,29,28,29,
},
-- 44
{
33,37,256,256,256,36,37,36,37,36,37,2,
32,256,33,256,256,256,256,256,256,256,256,256,
32,98,256,2,256,256,256,256,256,256,256,256,
32,99,256,256,2,256,256,256,75,76,256,256,
32,256,256,256,256,2,256,256,91,92,256,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 45
{
36,37,36,37,36,37,36,37,8,9,34,35,
256,256,256,256,256,256,256,256,8,9,256,32,
256,256,98,97,96,256,256,256,8,9,256,32,
256,256,99,256,100,256,256,256,8,9,256,32,
256,256,256,256,101,102,103,256,8,9,256,32,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 46
{
18,19,18,19,256,256,256,20,21,20,21,20,
18,19,72,256,17,256,256,256,256,256,256,256,
18,19,88,256,256,0,256,256,256,256,256,256,
18,19,256,75,76,78,0,256,256,116,256,256,
18,19,256,91,92,94,95,0,256,101,102,256,
18,19,18,19,18,19,18,19,18,19,18,19,
},
-- 47
{
20,21,20,21,20,21,20,21,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,256,256,
256,97,96,98,97,256,256,96,97,98,96,256,
114,99,256,256,100,114,114,99,256,256,100,114,
256,256,256,256,256,256,256,256,256,256,256,256,
18,19,18,19,18,19,18,19,18,19,18,19,
},
-- 48
{
20,21,20,21,17,256,256,17,20,21,20,21,
256,256,256,256,256,256,69,256,256,256,256,256,
256,256,96,97,256,256,69,256,256,256,256,256,
256,115,99,100,256,256,256,256,256,117,256,256,
256,101,102,103,256,111,111,256,101,102,103,256,
19,18,19,18,19,69,256,18,19,18,19,18,
},
-- 49
{
20,21,256,69,18,19,18,19,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,114,256,
256,256,69,256,256,256,114,256,256,256,256,256,
256,114,69,111,256,256,256,256,17,18,19,17,
256,256,111,256,18,19,18,19,18,19,18,19,
18,19,256,69,17,18,19,18,19,18,19,17,
},
-- 50
{
20,21,20,21,20,21,20,21,20,21,20,16,
256,114,256,256,256,256,256,256,256,256,98,16,
256,256,256,256,256,256,256,256,256,256,100,16,
17,19,256,256,256,114,256,256,256,256,78,16,
18,19,18,19,256,256,256,256,256,256,94,16,
17,18,19,18,19,18,19,256,80,17,18,19,
},
-- 51
{
42,43,44,45,44,45,256,256,256,44,45,45,
40,72,256,256,256,256,41,256,256,256,256,256,
40,96,256,256,256,256,256,3,256,256,256,256,
40,99,256,114,256,114,256,256,3,256,256,256,
40,256,256,256,256,256,256,256,256,3,256,256,
44,45,44,45,44,45,44,45,44,45,44,45,
},
-- 52
{
44,45,44,45,44,45,44,45,44,45,44,41,
256,256,256,256,256,256,256,256,256,256,256,40,
256,256,73,74,256,256,256,70,71,256,97,40,
256,256,89,90,256,256,256,86,87,256,100,40,
256,256,256,256,256,256,256,256,256,256,256,40,
44,45,41,83,256,44,44,45,44,45,44,45,
},
-- 53
{
18,19,10,11,18,19,17,17,20,21,20,21,
16,15,10,11,256,256,256,256,256,256,256,256,
16,256,10,11,256,256,75,76,256,256,256,256,
16,256,10,11,256,256,91,92,256,256,256,256,
16,256,10,11,256,256,18,19,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 54
{
20,21,20,21,21,17,18,19,67,256,256,256,
256,256,256,256,256,17,18,19,256,65,68,64,
256,256,256,256,256,256,18,19,256,256,256,256,
256,256,256,256,256,256,38,256,67,256,64,256,
256,256,256,256,256,256,38,256,256,256,256,256,
20,21,20,21,20,21,20,21,54,55,54,56,
},
-- 55
{
256,65,256,256,256,67,256,67,256,256,256,256,
256,256,256,64,256,256,256,256,65,68,64,256,
256,256,256,256,256,256,64,256,256,256,256,67,
256,256,65,67,256,256,64,256,256,64,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
54,55,54,56,56,55,54,56,54,56,55,54,
},
-- 56
{
65,256,256,256,67,256,67,256,256,256,256,64,
256,256,64,256,256,256,256,65,68,64,256,256,
256,256,256,256,256,64,256,256,256,256,67,256,
256,65,67,256,256,64,256,256,64,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
55,54,55,54,56,54,55,56,54,55,54,56,
},
-- 57
{
256,256,256,67,34,35,34,35,34,35,34,35,
256,64,256,256,34,35,72,256,256,256,256,256,
256,256,256,256,34,35,88,256,256,256,256,256,
65,67,256,256,256,38,256,256,75,76,256,256,
256,256,256,256,256,38,256,256,91,92,256,256,
54,55,56,54,36,37,36,37,36,37,36,37,
},
-- 58
{
35,34,35,34,35,69,256,34,35,34,35,34,
256,256,256,256,256,69,256,256,256,256,256,256,
256,113,70,71,114,256,256,112,107,108,113,256,
256,256,86,87,256,256,69,256,109,110,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
37,36,37,36,37,256,256,36,37,36,37,36,
},
-- 59
{
34,35,256,256,34,35,34,35,34,35,34,35,
256,256,256,69,256,256,256,256,256,256,256,256,
256,256,69,256,256,256,97,96,256,256,256,256,
256,256,111,111,256,256,99,100,256,256,256,256,
256,41,120,119,41,256,256,256,8,9,256,256,
3,41,46,47,41,3,36,37,8,9,36,37,
},
-- 60
{
35,34,35,34,35,34,35,256,256,33,34,35,
256,256,36,37,256,256,256,256,256,33,34,35,
256,256,256,256,256,256,256,256,2,77,34,35,
256,256,116,256,256,256,256,2,256,93,34,35,
256,256,101,102,103,256,2,256,256,256,34,35,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 61
{
18,19,21,20,21,20,21,20,21,17,18,19,
16,15,256,256,256,256,256,256,256,77,18,19,
16,256,256,256,256,256,256,256,256,93,18,19,
16,256,256,256,256,256,256,116,256,78,18,19,
16,256,10,11,256,256,101,102,256,94,18,19,
20,21,10,11,20,21,20,21,20,21,20,21,
},
-- 62
{
18,19,256,256,256,20,20,21,20,21,20,21,
16,72,17,256,256,256,256,256,256,256,256,256,
16,88,256,0,256,256,256,256,256,256,256,256,
16,256,256,78,0,256,256,114,75,76,256,256,
16,95,256,94,256,0,256,256,91,92,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 63
{
20,21,20,21,20,21,20,21,20,21,20,17,
256,256,256,256,256,256,256,256,256,256,256,16,
256,256,256,256,256,256,256,256,256,256,98,16,
256,256,256,256,256,256,117,97,96,256,100,16,
256,256,256,256,256,256,101,256,102,103,256,16,
20,21,17,80,256,20,20,21,20,21,20,21,
},
-- 64
{
41,48,49,48,50,49,48,49,48,50,49,48,
41,256,256,256,256,256,256,256,256,256,256,256,
41,256,256,256,256,256,256,256,256,256,256,256,
41,256,256,256,113,256,256,114,256,256,112,256,
41,256,8,9,256,256,256,256,256,256,256,256,
42,43,8,9,42,43,42,43,42,43,42,43,
},
-- 65
{
48,50,48,49,50,49,50,48,50,49,50,48,
256,256,256,256,256,256,256,256,256,256,112,256,
256,256,256,256,256,256,113,256,256,256,256,256,
256,256,114,256,256,256,256,256,42,43,42,43,
256,256,256,256,42,43,42,43,256,256,256,256,
42,43,42,43,256,256,256,256,256,256,256,256,
},
-- 66
{
48,49,48,48,50,49,48,50,49,48,48,50,
256,113,256,256,114,256,256,256,256,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
42,43,42,43,42,43,256,256,256,112,256,256,
256,256,256,256,42,43,3,256,256,256,256,256,
256,256,256,256,42,43,42,43,42,43,42,43,
},
-- 67
{
50,48,50,49,50,48,50,49,41,42,43,48,
256,256,256,256,256,256,256,256,77,42,43,256,
256,256,256,256,256,256,256,256,93,42,43,256,
256,256,114,256,256,113,256,256,256,42,43,256,
256,256,256,256,256,256,256,256,256,42,43,256,
42,43,41,41,42,43,41,83,256,42,43,50,
},
-- 68
{
25,28,29,26,27,256,69,26,27,28,29,28,
24,97,256,256,256,256,256,256,256,256,256,256,
24,99,256,256,256,69,256,256,256,256,256,256,
24,256,95,256,113,69,256,256,114,75,76,256,
24,101,102,103,256,111,111,256,256,91,92,256,
28,28,29,28,29,256,69,28,29,28,29,28,
},
-- 69
{
28,29,26,27,26,27,28,29,8,9,28,29,
256,256,256,28,29,256,256,256,8,9,256,256,
256,256,256,256,256,256,256,256,8,9,256,256,
75,76,75,76,75,76,75,76,8,9,256,256,
91,92,91,92,91,92,91,92,8,9,256,256,
28,29,1,26,27,1,28,29,8,9,28,29,
},
-- 70
{
28,29,26,27,25,25,256,256,65,256,256,256,
256,256,256,77,26,27,256,256,256,68,256,256,
256,256,256,93,25,25,256,256,256,256,66,256,
256,256,256,78,26,27,256,66,256,256,256,67,
256,256,95,94,25,25,256,256,256,256,256,256,
28,29,28,29,26,27,54,56,54,56,55,54,
},
-- 71
{
46,47,10,11,46,47,46,47,46,47,46,47,
47,256,10,11,256,256,256,256,256,256,256,256,
47,98,10,11,256,256,256,256,256,256,256,256,
47,99,10,11,256,256,115,105,256,256,256,256,
47,256,10,11,256,256,101,102,103,256,256,256,
46,47,46,47,46,47,46,47,46,47,46,47,
},
-- 72
{
46,47,46,47,46,47,46,47,46,47,46,47,
256,256,256,256,256,256,26,27,26,27,28,29,
256,256,256,256,256,256,38,256,256,256,256,256,
256,256,256,116,256,256,38,256,256,256,256,256,
256,256,101,102,256,256,26,27,26,27,256,256,
46,47,46,47,46,47,46,47,46,47,28,29,
},
-- 73
{
46,47,256,256,256,25,26,27,26,27,26,27,
28,29,25,256,256,256,256,256,256,28,29,25,
256,256,256,1,256,256,256,116,96,96,256,256,
256,256,256,256,1,256,256,99,256,100,256,256,
256,25,256,256,256,1,256,256,256,256,256,256,
28,29,28,29,26,27,26,27,26,27,26,27,
},
-- 74
{
26,27,8,9,26,27,26,27,26,27,26,27,
25,256,8,9,1,25,28,29,28,29,25,1,
256,256,8,9,256,256,256,256,256,256,256,256,
256,256,8,9,256,256,256,116,106,256,256,256,
256,256,8,9,256,256,104,101,102,103,256,256,
26,27,26,27,26,27,26,27,26,27,26,27,
},
-- 75
{
26,27,26,27,26,27,26,27,26,27,26,27,
256,256,28,29,25,28,29,25,28,29,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
256,114,256,256,256,113,256,256,256,256,114,256,
256,256,256,256,256,256,256,256,256,256,256,256,
26,27,28,29,28,29,28,29,28,29,26,27,
},
-- 76
{
26,27,26,27,26,27,26,27,18,19,20,21,
256,256,256,256,256,256,15,25,17,15,256,256,
256,256,256,256,256,256,256,25,17,256,256,256,
256,256,256,114,256,256,78,25,17,256,256,256,
256,256,256,256,256,95,94,25,17,256,256,256,
26,27,26,27,26,27,26,27,51,53,52,51,
},
-- 77
{
18,19,18,19,18,19,256,256,256,18,19,52,
256,256,17,72,256,256,17,256,256,256,256,256,
256,256,38,88,256,113,256,0,256,256,256,256,
256,256,38,256,256,256,256,256,0,256,256,256,
256,256,38,256,256,256,256,256,256,0,256,256,
52,51,52,53,52,53,51,52,51,53,52,53,
},
-- 78
{
51,52,53,51,52,256,256,52,53,51,52,17,
256,256,256,256,256,256,69,256,256,256,256,17,
256,256,256,256,256,69,256,256,256,256,256,17,
256,256,256,256,256,111,111,106,256,256,78,17,
256,256,256,256,17,118,119,17,256,95,94,17,
51,52,53,53,51,53,52,53,51,52,51,17,
},
-- 79
{
256,256,256,256,42,43,42,43,8,9,42,43,
256,256,256,256,42,43,72,256,8,9,256,256,
256,126,127,256,42,43,88,256,8,9,256,256,
256,256,256,256,42,43,256,256,8,9,256,256,
256,256,256,256,42,43,256,256,8,9,256,256,
256,256,256,256,42,43,42,43,42,43,42,43,
},
-- 80
{
42,43,42,43,42,43,42,43,256,256,256,256,
256,256,256,256,256,15,42,43,256,256,256,256,
256,256,256,256,256,256,42,43,256,126,127,256,
256,256,256,256,256,256,42,43,256,256,256,256,
256,256,256,256,256,256,42,43,256,256,256,256,
42,43,42,43,42,43,42,43,256,256,256,256,
},
}

183
data/mapa.lua Normal file
View File

@@ -0,0 +1,183 @@
require "map"
local arcade_config = require("arcade_config")
tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5}
mapa.wait=0
mapa.step=0
function mapa_do_backup()
mapa_backup={}
for i=1,#mapa do
mapa_backup[i]={}
for j=1,#mapa[i] do
mapa_backup[i][j]=mapa[i][j]
end
end
end
function mapa_restore_backup()
for i=1,#mapa do
for j=1,#mapa[i] do
mapa[i][j]=mapa_backup[i][j]
end
end
end
function mapa_new()
for my=0,7 do
for mx=0,9 do
local mi=1+mx+my*10
mapa[mi]={}
for ty=0,5 do
for tx=0,11 do
local tile=256
if mx==0 and tx==0 then
tile=16
elseif mx==4 and tx==11 then
tile=16
elseif ty==0 or ty==5 then
if tx%2==0 then
tile=20
else
tile=21
end
end
mapa[mi][1+tx+ty*12]=tile
end
end
end
end
end
function mapa_save()
local file = io.open("data/map.lua", "w")
io.output(file)
io.write("mapa={\n")
for i=1,80 do
io.write(" -- "..i.."\n {\n ")
for j=1,72 do
io.write(mapa[i][j]..",")
if j%12==0 then io.write("\n ") end
end
io.write("\n },\n")
end
io.write("}\n")
io.close(file)
end
anim_tiles={113,114,112,116,117,115,119,120,118,122,121}
function mapa_update(hab1,hab2)
mapa.wait=mapa.wait+1
if mapa.wait==6 then
mapa.wait=0
mapa.step=(mapa.step+1)&31
local hab=hab1
repeat
for ty=0,5 do
for tx=0,11 do
local tile=mapa[1+hab][1+tx+ty*12]
if tile>=112 and tile<126 then
mapa[1+hab][1+tx+ty*12]=anim_tiles[tile-111]
end
end
end
if hab==hab2 then break end
hab=hab2
until false
end
end
function mapa_draw(hab)
for ty=0,5 do
for tx=0,11 do
local tile=mapa[1+hab][1+tx+ty*12]
if tile~=256 and (tile<126 or mapa.step>4) then
-- draw.surf((tile&15)*8,64+(tile>>4)*8,8,8,tx*8,ty*8)
local txr = arcade_config.tiles_per_row-1
local txr2 = arcade_config.tiles_per_row_base2
local toff= arcade_config.tiles_offset
local tw = arcade_config.tiles_width
local th = arcade_config.tiles_height
draw.surf((tile&txr)*tw,toff+(tile>>txr2)*th,tw,th,tx*tw,ty*th)
end
end
end
end
function mapa_set_tile(hab,x,y,tile)
mapa[1+hab][1+x+y*12]=tile
end
function mapa_set_tile_by_index(hab,index,tile)
mapa[1+hab][index]=tile
end
function mapa_get_tile(hab,x,y)
return mapa[1+hab][1+x+y*12]
end
function mapa_cycle_colors(hab)
for i=1,72 do
local tile=mapa[1+hab][i]
if tile<4 then
tile=(tile+1)&3
elseif tile>=16 and tile<48 then
tile=tile+8
if tile>=48 then tile=tile-32 end
end
mapa[1+hab][i]=tile
end
end
function check_tile(hab,x,y)
local xx=math.min(11,math.max(0,math.floor(x/8)))
local yy=math.min(5,math.max(0,math.floor(y/8)))
--rect(xx*8,yy*8,xx*8+8,yy*8+8,3)
local tile=mapa_get_tile(hab,xx,yy)
if tile<8 then
return tiletype.half
elseif tile<15 then
return tiletype.stair
elseif tile==15 then
return tiletype.switch
elseif tile<64 then
return tiletype.block
elseif tile==111 then
return tiletype.nonpc
else
return tiletype.void
end
end
pix={14,10,7,1,0,0,0,0,4,4,4,4,0,0,0,8,14,14,14,14,14,14,0,0,10,10,10,10,10,10,10,10,7,7,7,7,7,7,2,2,1,1,1,1,1,1,12,12,1,1,1,9,9,9,10,10,10,0,0,0,0,0,0,0}
function mapa_create_minimap()
minimap = surf.new(128,96)
surf.target(minimap)
for h=0,79 do
for y=0,5 do
for x=0,11 do
local tile=mapa[h+1][1+x+y*12]
if h==45 then
print(x..","..y.."="..tile)
end
if tile<64 then
surf.pixel(x+(h%10)*12,y+math.floor(h/10)*6,pix[1+tile])
end
end
end
end
game_update=mapa_draw_minimap
end
function mapa_draw_minimap()
--print("HOLA")
surf.source(minimap)
surf.target(0)
surf.cls(16)
draw.surf(0,0,128*o2aX,96*o2Ax,0,0)
end