- [WIP] Llum de antorxa

This commit is contained in:
2026-01-06 10:08:46 +01:00
parent c0dfd49360
commit 021eb62399
6 changed files with 52 additions and 2 deletions

View File

@@ -1,8 +1,20 @@
game = { game = {
chg_adv = {x=0, y=0}, chg_adv = {x=0, y=0},
chg_step = 0, chg_step = 0,
back_buf = 0,
circ_buf = 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},
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},
light_strobe_value = 0,
light_strobe_dir = 1,
enable = function() enable = function()
if game.back_buf == 0 then
game.back_buf = surf.new(160,104)
game.circ_buf = surf.new(160,104)
end
app.update = game.update app.update = game.update
sys.beat(2) sys.beat(2)
--shader.enable(); --shader.enable();
@@ -10,7 +22,7 @@ game = {
update = function() update = function()
view.origin(0,0) view.origin(0,0)
surf.target(0) surf.target(game.back_buf)
view.clip() view.clip()
score.draw() score.draw()
@@ -20,6 +32,26 @@ game = {
sprites.update() sprites.update()
--sprites.update_hero() --sprites.update_hero()
view.origin(0,0)
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)
local pixel = surf.pixel(x,y)
surf.source(game.circ_buf)
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
surf.pixel(x,y,pixel)
end
end
end
if key.press(key.ESCAPE) or key.press(key.F9) then if key.press(key.ESCAPE) or key.press(key.F9) then
editor.enable() editor.enable()
end end
@@ -55,5 +87,17 @@ game = {
sprites.pause_ia = false sprites.pause_ia = false
app.pop() app.pop()
end 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 end
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1004 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -94,6 +94,10 @@ sprites = {
update = function() update = function()
if not sys.beat() then return end if not sys.beat() then return end
surf.target(game.circ_buf)
surf.cls()
sprites.update_sprite(sprites.hero) sprites.update_sprite(sprites.hero)
for i,v in ipairs(sprites.list) do for i,v in ipairs(sprites.list) do
sprites.update_sprite(v) sprites.update_sprite(v)
@@ -203,6 +207,8 @@ sprites = {
end, end,
update_hero = function() update_hero = function()
game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100)
-- Update hero -- Update hero
local anim = "hero_stand" local anim = "hero_stand"
local move_anim = "hero_walk" local move_anim = "hero_walk"