- [NEW] Marcador millorat i funcionant
This commit is contained in:
11
data/gfx/score_font.fnt
Normal file
11
data/gfx/score_font.fnt
Normal file
@@ -0,0 +1,11 @@
|
||||
bitmap=gfx/score_font.gif
|
||||
48: 0 0 8 8 0 # 0
|
||||
49: 8 0 8 8 0 # 1
|
||||
50: 16 0 8 8 0 # 2
|
||||
51: 24 0 8 8 0 # 3
|
||||
52: 32 0 8 8 0 # 4
|
||||
53: 40 0 8 8 0 # 5
|
||||
54: 48 0 8 8 0 # 6
|
||||
55: 56 0 8 8 0 # 7
|
||||
56: 64 0 8 8 0 # 8
|
||||
57: 72 0 8 8 0 # 9
|
||||
BIN
data/gfx/score_font.gif
Normal file
BIN
data/gfx/score_font.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 133 B |
@@ -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
|
||||
|
||||
@@ -51,7 +51,6 @@ game = {
|
||||
surf.target(0)
|
||||
view.clip()
|
||||
|
||||
score.draw()
|
||||
surf.target(game.back_buf)
|
||||
|
||||
-- Pintar el mapa i sprites
|
||||
@@ -61,6 +60,8 @@ game = {
|
||||
game.apply_water()
|
||||
game.apply_light()
|
||||
|
||||
score.draw()
|
||||
|
||||
if key.press(key.ESCAPE) or key.press(key.F9) then
|
||||
rooms.reload()
|
||||
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||
@@ -87,7 +88,6 @@ game = {
|
||||
surf.target(0)
|
||||
view.clip()
|
||||
|
||||
score.draw()
|
||||
surf.target(game.back_buf)
|
||||
--view.clip()
|
||||
|
||||
@@ -102,6 +102,8 @@ game = {
|
||||
game.apply_water()
|
||||
game.apply_light()
|
||||
|
||||
score.draw()
|
||||
|
||||
game.chg_step = game.chg_step - 1
|
||||
if game.chg_step == 0 then
|
||||
sprites.remove_out_of_room()
|
||||
|
||||
Reference in New Issue
Block a user