- [NEW] Marcador millorat i funcionant
This commit is contained in:
@@ -1,26 +1,65 @@
|
||||
score = {
|
||||
points = 0,
|
||||
color = 28,
|
||||
zoom = 1,
|
||||
color = 21,
|
||||
ypos = 3,
|
||||
surf = nil,
|
||||
font = nil
|
||||
} local me = score
|
||||
|
||||
function me.init()
|
||||
me.points = 0
|
||||
me.surf = surf.load("gfx/sprites.gif")
|
||||
me.font = font.load("gfx/score_font.fnt")
|
||||
end
|
||||
|
||||
local function draw_text()
|
||||
font.current(me.font)
|
||||
font.spacing(0)
|
||||
local txt = string.format("%03d", me.points)
|
||||
draw.text(txt,2,me.ypos-1,27)
|
||||
draw.text(txt,3,me.ypos-1,27)
|
||||
draw.text(txt,4,me.ypos-1,27)
|
||||
draw.text(txt,2,me.ypos,27)
|
||||
draw.text(txt,4,me.ypos,27)
|
||||
draw.text(txt,2,me.ypos+1,27)
|
||||
draw.text(txt,4,me.ypos+1,27)
|
||||
draw.text(txt,2,me.ypos+2,27)
|
||||
draw.text(txt,3,me.ypos+2,27)
|
||||
draw.text(txt,4,me.ypos+2,27)
|
||||
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()
|
||||
draw.rectf(0,0,160,8,1)
|
||||
draw.text(string.format("%03d", me.points),1,1,me.color)
|
||||
surf.source(me.surf)
|
||||
if sprites.hero.keys["verda"] then draw.surf(16,48,16,8, 32,-1) end
|
||||
if sprites.hero.keys["groga"] then draw.surf(16,56,16,8, 32,-1) end
|
||||
if sprites.hero.keys["roja"] then draw.surf(32,48,16,8, 32,-1) end
|
||||
if sprites.hero.keys["blava"] then draw.surf(32,56,16,8, 32,-1) end
|
||||
view.origin(0,0)
|
||||
surf.target(0)
|
||||
view.clip()
|
||||
|
||||
draw_text()
|
||||
|
||||
local y = 3
|
||||
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
|
||||
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 28 or 14 end)
|
||||
tweening.add(8, 0, 0.5, easing.linear, function(val,progress,finished) me.color = (math.floor(val)&1) == 0 and 21 or 14 end)
|
||||
tweening.add(5, 3, 0.5, easing.easeOutElastic, function(val,progress,finished) me.ypos = math.floor(val) end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user