[WIP] Score
This commit is contained in:
@@ -56,7 +56,8 @@ function abad_init()
|
|||||||
respawning=0,
|
respawning=0,
|
||||||
hab=10,
|
hab=10,
|
||||||
vides=3,
|
vides=3,
|
||||||
energia=40,
|
energia=6,
|
||||||
|
max_energia=6,
|
||||||
falling=0,
|
falling=0,
|
||||||
step=0,
|
step=0,
|
||||||
mustep=1,
|
mustep=1,
|
||||||
@@ -135,7 +136,7 @@ function abad_hurt(howmuch)
|
|||||||
music.play(audio_game_over,0)
|
music.play(audio_game_over,0)
|
||||||
else
|
else
|
||||||
music.play(audio_life_lost,0)
|
music.play(audio_life_lost,0)
|
||||||
abad.energia=40
|
abad.energia=abad.max_energia
|
||||||
-- abad.hab=abad.safe.hab
|
-- abad.hab=abad.safe.hab
|
||||||
-- abad.x=abad.safe.x
|
-- abad.x=abad.safe.x
|
||||||
-- abad.y=abad.safe.y
|
-- abad.y=abad.safe.y
|
||||||
@@ -310,7 +311,10 @@ function abad_state_normal()
|
|||||||
|
|
||||||
if abad.falling>0 then
|
if abad.falling>0 then
|
||||||
if abad.falling>(abad.max_jump_height<<1) then
|
if abad.falling>(abad.max_jump_height<<1) then
|
||||||
abad_hurt(abad.falling-(abad.max_jump_height<<1))
|
-- numero de pisos caiguts * 2
|
||||||
|
local damage = math.floor(abad.falling/(mapa_room_rows*arcade_config.tiles_height))*2
|
||||||
|
if damage>abad.energia then damage=abad.energia end
|
||||||
|
abad_hurt(damage)
|
||||||
end
|
end
|
||||||
abad.falling=0
|
abad.falling=0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ require "gps"
|
|||||||
require "peu"
|
require "peu"
|
||||||
require "premiere"
|
require "premiere"
|
||||||
require "elalien"
|
require "elalien"
|
||||||
|
require "score"
|
||||||
|
|
||||||
local tile_w = arcade_config.tiles_width
|
local tile_w = arcade_config.tiles_width
|
||||||
local tile_h = arcade_config.tiles_height
|
local tile_h = arcade_config.tiles_height
|
||||||
@@ -82,6 +83,8 @@ function game_init(menu)
|
|||||||
table.insert( actors, zombie.new(68, 3, 3,false) )
|
table.insert( actors, zombie.new(68, 3, 3,false) )
|
||||||
table.insert( actors, zombie.new(73, 3, 3,false) )
|
table.insert( actors, zombie.new(73, 3, 3,false) )
|
||||||
|
|
||||||
|
score.create()
|
||||||
|
|
||||||
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
|
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
|
||||||
-- local abad_x, abad_y = arc_mapa_get_coords ( 77, 3, 2 )
|
-- local abad_x, abad_y = arc_mapa_get_coords ( 77, 3, 2 )
|
||||||
abad:move(abad_x, abad_y)
|
abad:move(abad_x, abad_y)
|
||||||
@@ -175,6 +178,7 @@ function update_game()
|
|||||||
|
|
||||||
arc_mapa_update()
|
arc_mapa_update()
|
||||||
|
|
||||||
|
|
||||||
for key,actor in pairs(actors) do
|
for key,actor in pairs(actors) do
|
||||||
actor:update()
|
actor:update()
|
||||||
--if actor.hab==cacau.hab and actor~=abad then
|
--if actor.hab==cacau.hab and actor~=abad then
|
||||||
@@ -212,6 +216,8 @@ function update_game()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
cacau:draw()
|
cacau:draw()
|
||||||
|
|
||||||
|
score.draw()
|
||||||
|
|
||||||
fps_print()
|
fps_print()
|
||||||
viewp:print()
|
viewp:print()
|
||||||
|
|||||||
104
data/score.lua
Normal file
104
data/score.lua
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
score={}
|
||||||
|
|
||||||
|
function score.avatar()
|
||||||
|
local x = 64
|
||||||
|
local y = 0
|
||||||
|
local w = 13
|
||||||
|
local h = 15
|
||||||
|
draw.rectf( x, y, w, h, 15 ); -- fons negre
|
||||||
|
draw.surf(211,128,w-2,h-2,x+1,y+1,w-2,h-2,true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function score.border()
|
||||||
|
draw.surf(32*o2aX,64*o2aX,8*o2aX,8*o2aX,0,0) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,8*o2aX,0) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,16*o2aX,0) draw.surf(40*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,0)
|
||||||
|
draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,8*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,8*o2aX) draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,16*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,16*o2aX)
|
||||||
|
draw.surf(32*o2aX,64*o2aX,8*o2aX,8*o2aX,0,24*o2aX) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,8*o2aX,24*o2aX) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,16*o2aX,24*o2aX) draw.surf(40*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,24*o2aX)
|
||||||
|
draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,32*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,32*o2aX)
|
||||||
|
draw.surf(32*o2aX,64*o2aX,8*o2aX,8*o2aX,0,40*o2aX) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,8*o2aX,40*o2aX) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,16*o2aX,40*o2aX) draw.surf(40*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,40*o2aX)
|
||||||
|
|
||||||
|
draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,48*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,48*o2aX) draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,56*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,56*o2aX)
|
||||||
|
draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,64*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,64*o2aX) --draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,72*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,72*o2aX)
|
||||||
|
draw.surf(32*o2aX,64*o2aX,8*o2aX,8*o2aX,0,72*o2aX) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,8*o2aX,72*o2aX) draw.surf(48*o2aX,72*o2aX,8*o2aX,8*o2aX,16*o2aX,72*o2aX) draw.surf(40*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,72*o2aX)
|
||||||
|
draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,80*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,80*o2aX) draw.surf(48*o2aX,64*o2aX,8*o2aX,8*o2aX,0,88*o2aX) draw.surf(56*o2aX,64*o2aX,8*o2aX,8*o2aX,24*o2aX,88*o2aX)
|
||||||
|
end
|
||||||
|
|
||||||
|
function score.jailgames()
|
||||||
|
arc_text("jail",6*o2aX,77*o2aX,2)
|
||||||
|
arc_text("games",8*o2aX, 82*o2aX,2)
|
||||||
|
arc_text("2026",9*o2aX,89*o2aX,1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function score.life_meter()
|
||||||
|
local x = 0
|
||||||
|
local y = 2
|
||||||
|
local w = 6
|
||||||
|
local h = 7
|
||||||
|
-- borde blau
|
||||||
|
draw.hline(1+x, y, 8*w+4-2, 15)
|
||||||
|
draw.hline(1+x, y+h+3, 8*w+4-2, 15)
|
||||||
|
draw.vline(0+x, y+1, y+h+2, 15)
|
||||||
|
draw.vline(8*w+4-1, y+1, y+h+2, 15)
|
||||||
|
|
||||||
|
draw.rectf( 1+x, 1+y, 8*w+2, h+2, 16 ); -- fons negre
|
||||||
|
|
||||||
|
if abad.energia>abad.max_energia/2 then
|
||||||
|
-- 50%
|
||||||
|
color = 10; -- verd
|
||||||
|
elseif abad.energia>abad.max_energia/3 then
|
||||||
|
-- 33%
|
||||||
|
color = 8; -- groc
|
||||||
|
else
|
||||||
|
color = 3; -- roig
|
||||||
|
end
|
||||||
|
|
||||||
|
local full_width = 48
|
||||||
|
local curr_width = math.floor(full_width*(abad.energia/abad.max_energia))
|
||||||
|
local life_segment = math.floor(full_width/6)
|
||||||
|
draw.rectf( 2+0+x+0*w, 2+y, full_width, h, 16 );
|
||||||
|
draw.rectf( 2+0+x+0*w, 2+y, curr_width, h, color );
|
||||||
|
draw.vline( 2+0+x+0*w+life_segment*1, y+2, y+h+1, 16)
|
||||||
|
draw.vline( 2+0+x+0*w+life_segment*2, y+2, y+h+1, 16)
|
||||||
|
draw.vline( 2+0+x+0*w+life_segment*3, y+2, y+h+1, 16)
|
||||||
|
draw.vline( 2+0+x+0*w+life_segment*4, y+2, y+h+1, 16)
|
||||||
|
draw.vline( 2+0+x+0*w+life_segment*5, y+2, y+h+1, 16)
|
||||||
|
end
|
||||||
|
|
||||||
|
function score.create()
|
||||||
|
score.surf=surf.new(arcade_config.resolucion.width,arcade_config.resolucion.height)
|
||||||
|
surf.target(score.surf)
|
||||||
|
surf.cls(0)
|
||||||
|
|
||||||
|
score.avatar()
|
||||||
|
|
||||||
|
-- score.border()
|
||||||
|
-- score.jailgames()
|
||||||
|
|
||||||
|
score.life_meter()
|
||||||
|
surf.target(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function score.draw()
|
||||||
|
local x = 225
|
||||||
|
local y = 12
|
||||||
|
surf.target(score.surf)
|
||||||
|
surf.cls(0)
|
||||||
|
score.avatar()
|
||||||
|
score.life_meter()
|
||||||
|
surf.target(0)
|
||||||
|
|
||||||
|
surf.source(score.surf)
|
||||||
|
draw.surf(0,0,arcade_config.resolucion.width,arcade_config.resolucion.height,170,10)
|
||||||
|
surf.source(tiles)
|
||||||
|
if abad.objects.gorro~=nil then draw.surf(96*o2aX,32*o2aX,16*o2aX,16*o2aX,99*o2aX,44*o2aX) end
|
||||||
|
if abad.objects.peu~=nil then draw.surf(112*o2aX,32*o2aX,16*o2aX,16*o2aX,109*o2aX,44*o2aX) end
|
||||||
|
if abad.objects.gps~=nil then draw.surf(112*o2aX,48*o2aX,16*o2aX,16*o2aX,100*o2aX,55*o2aX) end
|
||||||
|
|
||||||
|
if abad.objects.clau_premiere~=nil then draw.surf(112*o2aX,8*o2aX,8*o2aX,8*o2aX,104*o2aX,48*o2aX) end
|
||||||
|
if abad.objects.clau_elalien~=nil then draw.surf(120*o2aX,8*o2aX,8*o2aX,8*o2aX,112*o2aX,48*o2aX) end
|
||||||
|
|
||||||
|
if abad.objects.bol~=nil then draw.surf(112*o2aX,88*o2aX,16*o2aX,8*o2aX,104*o2aX,46*o2aX) end
|
||||||
|
|
||||||
|
arc_text(abad.vides,x,y,2)
|
||||||
|
|
||||||
|
-- draw.rectf((102+(abad.energia>>1))*o2aX,30*o2aX,(21-(abad.energia>>1))*o2aX,8*o2aX,2)
|
||||||
|
end
|
||||||
BIN
data/tiles.gif
BIN
data/tiles.gif
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user