Primer render de múltiples habitacions en pantalla al mateix temps
This commit is contained in:
149
data/game.lua
Normal file
149
data/game.lua
Normal 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
|
||||
Reference in New Issue
Block a user