Compare commits
3 Commits
53aea81265
...
edd07509d0
| Author | SHA1 | Date | |
|---|---|---|---|
| edd07509d0 | |||
| 7090a6134f | |||
| abb3e5e048 |
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 |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -206,16 +206,16 @@ animations = {
|
|||||||
},
|
},
|
||||||
["gota_generador"] = {
|
["gota_generador"] = {
|
||||||
cycle = {1,2,3,4,5,6,7,8},
|
cycle = {1,2,3,4,5,6,7,8},
|
||||||
loop = false,
|
loop = true,
|
||||||
frames = {
|
frames = {
|
||||||
|
{ frame={x=48,y=0,w=8,h=8}, wait=50 },
|
||||||
|
{ frame={x=48,y=0,w=8,h=8}, wait=1 },
|
||||||
{ frame={x=0,y=0,w=8,h=8}, wait=2 },
|
{ frame={x=0,y=0,w=8,h=8}, wait=2 },
|
||||||
{ frame={x=8,y=0,w=8,h=8}, wait=2 },
|
{ frame={x=8,y=0,w=8,h=8}, wait=2 },
|
||||||
{ frame={x=16,y=0,w=8,h=8}, wait=2 },
|
{ frame={x=16,y=0,w=8,h=8}, wait=2 },
|
||||||
{ frame={x=24,y=0,w=8,h=8}, wait=2 },
|
{ frame={x=24,y=0,w=8,h=8}, wait=2 },
|
||||||
{ frame={x=32,y=0,w=8,h=8}, wait=2 },
|
{ frame={x=32,y=0,w=8,h=8}, wait=2 },
|
||||||
{ frame={x=40,y=0,w=8,h=8}, wait=2 },
|
{ frame={x=40,y=0,w=8,h=8}, wait=2 },
|
||||||
{ frame={x=48,y=0,w=8,h=8}, wait=50 },
|
|
||||||
{ frame={x=48,y=0,w=8,h=8}, wait=1 }
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
["gota"] = {
|
["gota"] = {
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
|
|
||||||
function ia.update_gota(spr)
|
function ia.update_gota(spr)
|
||||||
if spr.timer > 0 then
|
if spr.timer > 0 then
|
||||||
spr.invisible = true
|
|
||||||
spr.timer = spr.timer-1
|
spr.timer = spr.timer-1
|
||||||
if spr.timer == 1 then
|
return
|
||||||
spr.animation_finished = nil
|
|
||||||
spr.current_frame = 1
|
|
||||||
spr.current_wait = 1
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
spr.invisible = nil;
|
spr.invisible = nil;
|
||||||
if spr.animation_finished then
|
if spr.current_frame==2 then
|
||||||
local gota = templates.create("gota_caiguent", {pos={x=spr.pos.x, y=spr.pos.y}, flipped=spr.flipped})
|
local gota = templates.create("gota_caiguent", {pos={x=spr.pos.x, y=spr.pos.y}, flipped=spr.flipped})
|
||||||
table.insert(sprites.list, gota)
|
table.insert(sprites.list, gota)
|
||||||
spr.animation_finished = nil
|
--spr.animation_finished = nil
|
||||||
spr.current_frame = 1
|
--spr.current_frame = 1
|
||||||
spr.current_wait = 1
|
--spr.current_wait = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,6 +49,33 @@ function ia.update_hero()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Si li han pegat...
|
||||||
|
if sprites.hero.has_been_hit then
|
||||||
|
if sprites.hero.flipped then
|
||||||
|
local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3
|
||||||
|
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||||
|
if tx<rooms.pos.x then
|
||||||
|
game.change_room(-1,0)
|
||||||
|
else
|
||||||
|
sprites.hero.pos.x = sprites.hero.pos.x + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local tx, ty = (sprites.hero.pos.x+12)>>3, (sprites.hero.pos.y+16)>>3
|
||||||
|
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||||
|
if tx>rooms.pos.x+19 then
|
||||||
|
game.change_room(1,0)
|
||||||
|
else
|
||||||
|
sprites.hero.pos.x = sprites.hero.pos.x - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sprites.hero.has_been_hit = sprites.hero.has_been_hit - 1
|
||||||
|
if sprites.hero.has_been_hit == 0 then
|
||||||
|
sprites.hero.has_been_hit = nil;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- si està en l'animació de disparar, no podem fer res i eixim ja
|
-- si està en l'animació de disparar, no podem fer res i eixim ja
|
||||||
if sprites.hero.shooting then
|
if sprites.hero.shooting then
|
||||||
-- A no ser que siga l'ultim frame, en tal cas tornem a estar de peu i au
|
-- A no ser que siga l'ultim frame, en tal cas tornem a estar de peu i au
|
||||||
@@ -165,7 +192,7 @@ function ia.update_hero()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- ESTIGA COM ESTIGA, SI POLSA ESQUERRA O DRETA...
|
-- ESTIGA COM ESTIGA, SI POLSA ESQUERRA O DRETA...
|
||||||
if not sprites.hero.shooting then
|
if not sprites.hero.shooting and not sprites.hero.has_been_hit then
|
||||||
if key.down(key.LEFT) or pad.down(pad.LEFT) then
|
if key.down(key.LEFT) or pad.down(pad.LEFT) then
|
||||||
sprites.hero.flipped = true
|
sprites.hero.flipped = true
|
||||||
anim = move_anim
|
anim = move_anim
|
||||||
@@ -221,6 +248,10 @@ function ia.hero_hit(live)
|
|||||||
elseif sprites.hero.lives < 4 then
|
elseif sprites.hero.lives < 4 then
|
||||||
sprites.hero.state = templates.DYING
|
sprites.hero.state = templates.DYING
|
||||||
sprites.hero.cooldown = 60
|
sprites.hero.cooldown = 60
|
||||||
|
sprites.hero.shooting = false
|
||||||
|
sprites.set_animation(sprites.hero, "hero_stand")
|
||||||
|
sprites.hero.jumping = 8
|
||||||
|
sprites.hero.has_been_hit = 16
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ function ia.update_mummy(spr)
|
|||||||
-- Si toca al heroi...
|
-- Si toca al heroi...
|
||||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
sprites.hero.hit()
|
sprites.hero.hit()
|
||||||
|
spr.flipped = not spr.flipped
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ function ia.update_rata(spr)
|
|||||||
-- Si toca al heroi...
|
-- Si toca al heroi...
|
||||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
sprites.hero.hit()
|
sprites.hero.hit()
|
||||||
|
spr.flipped = not spr.flipped
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,65 @@
|
|||||||
score = {
|
score = {
|
||||||
points = 0,
|
points = 0,
|
||||||
color = 28,
|
color = 21,
|
||||||
zoom = 1,
|
ypos = 3,
|
||||||
surf = nil,
|
surf = nil,
|
||||||
|
font = nil
|
||||||
} local me = score
|
} local me = score
|
||||||
|
|
||||||
function me.init()
|
function me.init()
|
||||||
me.points = 0
|
me.points = 0
|
||||||
me.surf = surf.load("gfx/sprites.gif")
|
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
|
end
|
||||||
|
|
||||||
function me.draw()
|
function me.draw()
|
||||||
draw.rectf(0,0,160,8,1)
|
view.origin(0,0)
|
||||||
draw.text(string.format("%03d", me.points),1,1,me.color)
|
surf.target(0)
|
||||||
surf.source(me.surf)
|
view.clip()
|
||||||
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
|
draw_text()
|
||||||
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
|
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
|
end
|
||||||
|
|
||||||
function me.inc(value)
|
function me.inc(value)
|
||||||
me.points = me.points + 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
|
end
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ function me.create(type, options)
|
|||||||
animation = "gota_generador",
|
animation = "gota_generador",
|
||||||
state = me.ALIVE,
|
state = me.ALIVE,
|
||||||
enemy = true,
|
enemy = true,
|
||||||
timer = 0,
|
timer = math.random(0,100),
|
||||||
room = options.room,
|
room = options.room,
|
||||||
ia = ia.update_gota
|
ia = ia.update_gota
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ game = {
|
|||||||
surf.target(0)
|
surf.target(0)
|
||||||
view.clip()
|
view.clip()
|
||||||
|
|
||||||
score.draw()
|
|
||||||
surf.target(game.back_buf)
|
surf.target(game.back_buf)
|
||||||
|
|
||||||
-- Pintar el mapa i sprites
|
-- Pintar el mapa i sprites
|
||||||
@@ -61,6 +60,8 @@ game = {
|
|||||||
game.apply_water()
|
game.apply_water()
|
||||||
game.apply_light()
|
game.apply_light()
|
||||||
|
|
||||||
|
score.draw()
|
||||||
|
|
||||||
if key.press(key.ESCAPE) or key.press(key.F9) then
|
if key.press(key.ESCAPE) or key.press(key.F9) then
|
||||||
rooms.reload()
|
rooms.reload()
|
||||||
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||||
@@ -87,7 +88,6 @@ game = {
|
|||||||
surf.target(0)
|
surf.target(0)
|
||||||
view.clip()
|
view.clip()
|
||||||
|
|
||||||
score.draw()
|
|
||||||
surf.target(game.back_buf)
|
surf.target(game.back_buf)
|
||||||
--view.clip()
|
--view.clip()
|
||||||
|
|
||||||
@@ -102,6 +102,8 @@ game = {
|
|||||||
game.apply_water()
|
game.apply_water()
|
||||||
game.apply_light()
|
game.apply_light()
|
||||||
|
|
||||||
|
score.draw()
|
||||||
|
|
||||||
game.chg_step = game.chg_step - 1
|
game.chg_step = game.chg_step - 1
|
||||||
if game.chg_step == 0 then
|
if game.chg_step == 0 then
|
||||||
sprites.remove_out_of_room()
|
sprites.remove_out_of_room()
|
||||||
|
|||||||
Reference in New Issue
Block a user