- [NEW] Animació de moneda agafada

- [NEW] Agafar monedes augmenta el marcador
- [NEW] Marcador bàsic visible
- [NEW] Al cambiar d'habitació es manté el efecte d'iluminació. A més, va un poc més lento
- [NEW] Al agafar moneda, no torna al eixir i entrar. Al tornar al editor se recupera.
- [NEW] Gestió de l'iluminació fora dels update i dins dels draw
- [NEW] Afegides més habitacions
This commit is contained in:
2026-02-24 13:23:16 +01:00
parent c5dd0344c0
commit 12673f1dc4
9 changed files with 143 additions and 77 deletions

View File

@@ -23,35 +23,100 @@ game = {
update = function()
game.water_counter = game.water_counter + 0.05
local counter = game.water_counter
view.origin(0,0)
surf.target(game.back_buf)
surf.target(0)
view.clip()
score.draw()
surf.target(game.back_buf)
-- Pintar el mapa i sprites
rooms.draw()
sprites.update()
--sprites.update_hero()
game.apply_water()
game.apply_light()
if key.press(key.ESCAPE) or key.press(key.F9) then
rooms.retrieve_original_items()
editor.enable()
end
end,
change_room = function(x,y)
game.chg_adv.x = x*0.25
game.chg_adv.y = y*0.25
game.chg_step = 8*4
sprites.pause_ia = true
-- [TODO] Crear els sprites per als items de l'habitació a la que entrem
sprites.add_from_room(rooms.pos.x+x*20, rooms.pos.y+y*12)
app.push(game.update_change_room)
--sys.beat(10)
end,
update_change_room = function()
--if not sys.beat() then return end
view.origin(0,0)
surf.target(0)
view.clip()
score.draw()
surf.target(game.back_buf)
--view.clip()
-- Pintar el mapa i sprites
rooms.pos.x = rooms.pos.x + (game.chg_adv.x*2.5)
rooms.pos.y = rooms.pos.y + (game.chg_adv.y*1.5)
sprites.hero.pos.x = sprites.hero.pos.x + game.chg_adv.x
sprites.hero.pos.y = sprites.hero.pos.y + game.chg_adv.y
rooms.draw()
sprites.update()
game.apply_water()
game.apply_light()
game.chg_step = game.chg_step - 1
if game.chg_step == 0 then
sprites.remove_out_of_room()
sprites.pause_ia = false
app.pop()
--sys.beat(2)
end
end,
draw_light = function(x,y,size)
surf.target(game.circ_buf)
local s = size+(game.light_strobe_value/2)
draw.mode(draw.OR)
draw.circf(x,y,s,1)
draw.circf(x,y,2*(s/3),2)
draw.mode(draw.NORMAL)
surf.target(game.back_buf)
end,
apply_water = function()
view.origin(0,0)
if rooms.pos.y == 84 then
surf.target(game.back_buf)
surf.source(game.back_buf)
for x=0,159 do
local water_level = math.sin(counter)*2
local water_level = math.sin(game.water_counter)*2
for y=96+water_level,103 do
local pixel = surf.pixel(x,y)
surf.pixel(x,y,game.water_pal[pixel+1])
end
end
end
end,
apply_light = function()
game.light_strobe_value = game.light_strobe_value + game.light_strobe_dir
if math.abs(game.light_strobe_value)==2 then
game.light_strobe_dir = -game.light_strobe_dir
end
surf.target(0)
--surf.source(game.back_buf)
--draw.surf(0,0,160,104,0,0,160,104)
for y=0,103 do
for x=0,159 do
surf.source(game.back_buf)
@@ -60,60 +125,14 @@ game = {
local light = surf.pixel(x,y)
if light==0 then
surf.pixel(x,y,1)
elseif light==1 then
surf.pixel(x,y,game.fade_pal[pixel+1])
else
elseif (light&2)==2 then
surf.pixel(x,y,pixel)
else
surf.pixel(x,y,game.fade_pal[pixel+1])
end
end
end
if key.press(key.ESCAPE) or key.press(key.F9) then
editor.enable()
end
end,
change_room = function(x,y)
game.chg_adv.x = x
game.chg_adv.y = y
game.chg_step = 8
sprites.pause_ia = true
-- [TODO] Crear els sprites per als items de l'habitació a la que entrem
sprites.add_from_room(rooms.pos.x+x*20, rooms.pos.y+y*12)
app.push(game.update_change_room)
end,
update_change_room = function()
view.origin(0,0)
surf.target(0)
view.clip()
score.draw()
-- Pintar el mapa i sprites
rooms.pos.x = rooms.pos.x + game.chg_adv.x*2.5
rooms.pos.y = rooms.pos.y + game.chg_adv.y*1.5
sprites.hero.pos.x = sprites.hero.pos.x + game.chg_adv.x
sprites.hero.pos.y = sprites.hero.pos.y + game.chg_adv.y
rooms.draw()
sprites.update()
game.chg_step = game.chg_step - 1
if game.chg_step == 0 then
sprites.remove_out_of_room()
sprites.pause_ia = false
app.pop()
end
end,
draw_light = function(x,y,size)
surf.target(game.circ_buf)
local s = size+game.light_strobe_value
draw.circf(x,y,s,1)
draw.circf(x,y,2*(s/3),2)
game.light_strobe_value = game.light_strobe_value + game.light_strobe_dir
if math.abs(game.light_strobe_value)==1 then
game.light_strobe_dir = -game.light_strobe_dir
end
--surf.target(game.circ_buf)
end
}