Files
paku/data/modules/score.lua
T
Raimon @ quifisraimon d2ebbccbf6 - [NEW] El mono
- [NEW] Noves animacions de detallets
- [NEW] Més particles i eye candy
- [FIX] Si es ficava un item/enemic en la fila de baix del tot no es guardaba
- [FIX] Quan se disaparaba cap a la dreta amb el final de la pantalla o una pared en la esquena, la bala no eixia
- [WIP] Treballant en el marcador
2026-10-06 15:56:37 +02:00

79 lines
2.1 KiB
Lua

score = {
points = 0,
color = 27,
ypos = 3,
surf = nil,
font = nil
} local me = score
function me.init(reinit)
if not reinit then me.points = 0 end
me.ypos = 3
me.surf = surf.load("gfx/sprites.gif")
me.font = font.load("gfx/score_font.fnt")
end
local function draw_text()
local txt = string.format("%03d", me.points)
draw.text(txt,10,me.ypos,me.color)
-- font.current(me.font)
-- font.spacing(0)
-- draw.text(txt,2,me.ypos+2,1)
-- draw.text(txt,3,me.ypos+2,1)
-- draw.text(txt,4,me.ypos+2,1)
-- draw.text(txt,2,me.ypos-1,26)
-- draw.text(txt,3,me.ypos-1,26)
-- draw.text(txt,4,me.ypos-1,26)
-- draw.text(txt,2,me.ypos,26)
-- draw.text(txt,4,me.ypos,26)
-- draw.text(txt,2,me.ypos+1,26)
-- draw.text(txt,4,me.ypos+1,26)
---- draw.text(txt,3,me.ypos+1,1)
-- draw.text(txt,3,me.ypos,me.color)
font.current(font.DEFAULT)
font.spacing(1)
surf.source(me.surf)
end
local function draw_key(sx,sy,dx,dy)
pal.subpal(1,26,27)
for y=-1,1 do
for x=-1,1 do
if x~=0 and y~=0 then draw.surf(sx,sy,16,8, dx+x,dy+y) end
end
end
pal.subpal()
draw.surf(sx,sy,16,8, dx,dy)
end
function me.draw()
local paleta = palfade.get()
palfade.restore()
if sprites.hero.state == templates.DEAD then
if me.ypos > -100 then me.ypos=me.ypos-1 end
end
view.origin(0,0)
surf.target(0)
surf.clip()
draw_text()
draw.surf(0,40,8,8, 1,1)
local y = score.ypos
if sprites.hero.keys["verda"] then draw_key(16,48,140,y) y=y+8 end
if sprites.hero.keys["groga"] then draw_key(16,56,140,y) y=y+8 end
if sprites.hero.keys["roja"] then draw_key(32,48,140,y) y=y+8 end
if sprites.hero.keys["blava"] then draw_key(32,56,140,y) y=y+8 end
palfade.set(paleta)
end
function me.inc(value)
me.points = me.points + value
tweening.add(8, 0, 0.5, easing.linear, function(val,progress,finished) me.color = (math.floor(val)&1) == 0 and 27 or 14 end)
tweening.add(5, 3, 0.5, easing.easeOutElastic, function(val,progress,finished) me.ypos = math.floor(val) end)
end