- [NEW] Tot el tema de l'iluminació i l'aigua s'ha passat a jocs de paleta gestionats des del propi mini, en compte de pixel a pixel en Lua. Per a millorar el rendiment en la Banana Pi.

This commit is contained in:
Raimon @ quifisraimon committed 2026-10-13 10:24:36 +02:00
1 parent 3488bcbf64
commit 107cde3b9f
1 file changed
+45 -29
+45 -29
View File
@@ -12,11 +12,14 @@ cheats = {}
game = { game = {
chg_adv = {x=0, y=0}, chg_adv = {x=0, y=0},
chg_step = 0, chg_step = 0,
back_buf = 0, --back_buf = 0,
circ_buf = 0, circ_buf = 0,
water_buf = 0,
old_water_level = 0,
water_pal = {6,6,21,21,6,21,6,22,22,22,22,22,22,22,22,21,21,22,22,22,22,21,22,22,21,22,22,22,22,6,6,6}, water_pal = {6,6,21,21,6,21, 6,22,22,22,22,22,22,22,22,21,21,22,22,22,22,21,22,22,21,22,22,22,22,6,6,6},
fade_pal = {1,1,3,1,1,3,29,29,3,3,3,3,3,6,6,29,29,3,3,3,3,29,6,29,29,6,29,6,6,1,1,1}, fade_pal = {1,1, 3, 1,1, 3,29,29, 3, 3, 3, 3, 3, 6, 6,29,29, 3, 3, 3, 3,29, 6,29,29, 6,29, 6, 6,1,1,1},
black_pal = {1,1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1},
light_strobe_value = 0, light_strobe_value = 0,
light_strobe_dir = 1, light_strobe_dir = 1,
@@ -24,10 +27,16 @@ game = {
fade=0, fade=0,
enable = function() enable = function()
if game.back_buf == 0 then if game.circ_buf == 0 then
game.back_buf = surf.new(160,104) --game.back_buf = surf.new(160,104)
game.circ_buf = surf.new(160,104) game.circ_buf = surf.new(160,104)
game.water_buf = surf.new(160,104)
end end
pal.lut(0,game.black_pal)
pal.lut(1,game.fade_pal)
pal.lut(3)
pal.lut(2,game.water_pal)
app.update = game.update app.update = game.update
sys.beat(2) sys.beat(2)
palfade.init() palfade.init()
@@ -62,7 +71,7 @@ game = {
surf.target(0) surf.target(0)
surf.clip() surf.clip()
surf.target(game.back_buf) surf.target(0)--game.back_buf)
-- Pintar el mapa i sprites -- Pintar el mapa i sprites
rooms.draw() rooms.draw()
@@ -92,7 +101,7 @@ game = {
win.fullscreen(not win.fullscreen()) win.fullscreen(not win.fullscreen())
end end
--draw.text(sys.fps(),2,20,8) draw.text(math.floor(sys.fps()),144,1,14)
end, end,
change_room = function(x,y) change_room = function(x,y)
@@ -112,7 +121,7 @@ game = {
surf.target(0) surf.target(0)
surf.clip() surf.clip()
surf.target(game.back_buf) surf.target(0)--game.back_buf)
--view.clip() --view.clip()
-- Pintar el mapa i sprites -- Pintar el mapa i sprites
@@ -149,15 +158,20 @@ game = {
apply_water = function() apply_water = function()
view.origin(0,0) view.origin(0,0)
if rooms.pos.y == 91 then if rooms.pos.y == 91 then
surf.target(game.back_buf) surf.target(game.water_buf)
surf.source(game.back_buf) surf.cls(3)
for x=0,159 do for x=0,159 do
local water_level = math.sin(game.water_counter)*2 --local water_level = math.sin(game.water_counter+x/20)*2
for y=88+water_level,104 do local water_level = math.sin(game.water_counter+x/20)+math.cos(-game.water_counter+x/10)
local pixel = draw.pixel(x,y) draw.vline(x, 88+water_level, 104, 2)
draw.pixel(x,y,game.water_pal[pixel+1]) --for y=88+water_level,104 do
end -- local pixel = draw.pixel(x,y)
-- draw.pixel(x,y,game.water_pal[pixel+1])
--end
end end
surf.target(0)
surf.source(game.water_buf)
pal.mask()
end end
end, end,
@@ -168,21 +182,23 @@ game = {
end end
surf.target(0) surf.target(0)
for y=0,103 do
for x=0,159 do
surf.source(game.back_buf)
local pixel = draw.pixel(x,y)
surf.source(game.circ_buf) surf.source(game.circ_buf)
local light = draw.pixel(x,y) pal.mask()
if light==0 then --for y=0,103 do
draw.pixel(x,y,1) -- for x=0,159 do
elseif (light&2)==2 then -- surf.source(game.back_buf)
draw.pixel(x,y,pixel) -- local pixel = draw.pixel(x,y)
else -- surf.source(game.circ_buf)
draw.pixel(x,y,game.fade_pal[pixel+1]) -- local light = draw.pixel(x,y)
end -- if light==0 then
end -- draw.pixel(x,y,1)
end -- elseif (light&2)==2 then
-- draw.pixel(x,y,pixel)
-- else
-- draw.pixel(x,y,game.fade_pal[pixel+1])
-- end
-- end
--end
end end