[WIP] Afegint codi per a múltiples fases
This commit is contained in:
@@ -93,7 +93,7 @@ function abad:draw()
|
||||
abad.respawning=abad.respawning-1
|
||||
end
|
||||
|
||||
draw.rect(x+abad.bb.x,y+abad.bb.y,abad.bb.w,abad.bb.h,3)
|
||||
-- draw.rect(x+abad.bb.x,y+abad.bb.y,abad.bb.w,abad.bb.h,3)
|
||||
end
|
||||
|
||||
function abad_make_safe( force )
|
||||
@@ -108,7 +108,7 @@ end
|
||||
|
||||
|
||||
function abad_hurt(howmuch)
|
||||
howmuch = 0
|
||||
-- howmuch = 0
|
||||
if abad.hurting == 0 and abad.respawning==0 then
|
||||
sound.play(audio_abad_hit)
|
||||
abad.energia=abad.energia-howmuch
|
||||
|
||||
209
data/game.lua
209
data/game.lua
@@ -207,8 +207,7 @@ function render_map( sf_map, sf_tiles, x, y )
|
||||
view.origin(0,0)
|
||||
end
|
||||
|
||||
function update_game()
|
||||
if stage~=stage_loaded then
|
||||
function load_stage()
|
||||
local stage_init = stages["stage"..stage.."_init"]
|
||||
if stage_init then
|
||||
stage_init()
|
||||
@@ -219,37 +218,26 @@ function update_game()
|
||||
end
|
||||
end
|
||||
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
function viewport_update()
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
|
||||
if key.press(key.N1) then
|
||||
local hab = abad.hab-1
|
||||
if hab<0 then hab=0 end
|
||||
local hab_x = 4
|
||||
local hab_y = 3
|
||||
local abad_x, abad_y = coords.room_to_world ( hab, hab_x, hab_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
if key.press(key.N2) then
|
||||
local hab = abad.hab+1
|
||||
if hab<0 then hab=0 end
|
||||
local hab_x = 4
|
||||
local hab_y = 3
|
||||
local abad_x, abad_y = coords.room_to_world ( hab, hab_x, hab_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
if key.press(key.N0) then
|
||||
local abad_x, abad_y = coords.room_to_world ( 41, 3, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
local vp_center_offset_x = (viewp.width >> 1)
|
||||
local vp_center_offset_y = (viewp.height >> 1)
|
||||
|
||||
vp_x = abad.x - vp_center_offset_x
|
||||
if vp_x < 0 then vp_x = 0 end
|
||||
|
||||
vp_y = abad.y - vp_center_offset_y
|
||||
if vp_y < 0 then vp_y = 0 end
|
||||
|
||||
viewp:position(vp_x, vp_y)
|
||||
end
|
||||
|
||||
function world_update()
|
||||
-- Actualitzar moviment del mapa (ex: tiles animats)
|
||||
arc_mapa_update()
|
||||
|
||||
|
||||
-- Moure a tots
|
||||
for key,actor in pairs(actors) do
|
||||
actor:update()
|
||||
@@ -268,35 +256,24 @@ function update_game()
|
||||
end
|
||||
end
|
||||
|
||||
-- Actualizar el que queda
|
||||
cacau.update()
|
||||
switches.update()
|
||||
warp.update_all()
|
||||
end
|
||||
|
||||
-- Moure el viewport
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
--viewp:position(vp_x, vp_y)
|
||||
|
||||
local vp_center_offset_x = (viewp.width >> 1)
|
||||
local vp_center_offset_y = (viewp.height >> 1)
|
||||
|
||||
vp_x = abad.x - vp_center_offset_x
|
||||
if vp_x < 0 then vp_x = 0 end
|
||||
|
||||
vp_y = abad.y - vp_center_offset_y
|
||||
if vp_y < 0 then vp_y = 0 end
|
||||
|
||||
viewp:position(vp_x, vp_y)
|
||||
|
||||
function world_draw()
|
||||
-- Pintar la finestra del mon
|
||||
render_map(sf_mapa, tiles, vp_x, vp_y)
|
||||
render_map(sf_mapa, tiles, viewp.x, viewp.y)
|
||||
|
||||
-- pintar warps
|
||||
for key,warp in pairs(warp.warp_list) do
|
||||
if viewp:inside(warp.x, warp.y, warp.w, warp.h) then
|
||||
warp:draw()
|
||||
end
|
||||
end
|
||||
|
||||
--pintar actors
|
||||
for key,actor in pairs(actors) do
|
||||
if viewp:inside(actor.x, actor.y, actor.w, actor.h) then
|
||||
actor:draw()
|
||||
@@ -304,59 +281,28 @@ function update_game()
|
||||
end
|
||||
|
||||
cacau:draw()
|
||||
end
|
||||
|
||||
function update_game()
|
||||
if stage~=stage_loaded then load_stage() end
|
||||
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
|
||||
-- special_keys()
|
||||
|
||||
world_update()
|
||||
|
||||
-- Moure el viewport
|
||||
viewport_update()
|
||||
|
||||
world_draw()
|
||||
|
||||
score.draw()
|
||||
|
||||
font.current(font_default)
|
||||
viewp:print()
|
||||
msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
|
||||
msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true)
|
||||
local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
|
||||
msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
|
||||
msg_print(0,35,hab.." ( "..xx..", "..yy.." )", true)
|
||||
-- msg_print(0,42," JH= "..abad.jump_height,true)
|
||||
|
||||
-- view_coord(abad.x+8, abad.y+0, 16, 32, 6)
|
||||
-- view_coord(abad.x+abad.bb.x, abad.y+abad.bb.h, 2, 2, 4)
|
||||
-- view_coord(abad.x+abad.bb.x+abad.bb.w, abad.y+abad.bb.h, 2, 2, 2)
|
||||
-- view_coord(abad.x, abad.y, 2, 2, 3)
|
||||
|
||||
-- if key.press(key.T) then
|
||||
-- view_tile_id = not view_tile_id
|
||||
-- view_checking_tile = false
|
||||
-- end
|
||||
-- if key.press(key.C) then
|
||||
-- view_checking_tile = not view_checking_tile
|
||||
-- view_tile_id = false
|
||||
-- end
|
||||
--
|
||||
-- if view_tile_id then
|
||||
-- write_tile(abad.x, abad.y, 0, true, "R")
|
||||
-- write_tile(abad.x, abad.y+16, 0, true, "R")
|
||||
-- write_tile(abad.x, abad.y+32, 0, true, "R")
|
||||
--
|
||||
-- write_tile(abad.x+16, abad.y+32, 0, true, "C")
|
||||
--
|
||||
-- write_tile(abad.x+32, abad.y, 0, true, "L")
|
||||
-- write_tile(abad.x+32, abad.y+16, 0, true, "L")
|
||||
-- write_tile(abad.x+32, abad.y+32, 0, true, "L")
|
||||
-- end
|
||||
--
|
||||
-- if view_checking_tile then
|
||||
-- local msg = "FLIP= true"
|
||||
-- if not abad.flip then
|
||||
-- msg ="FLIP= false"
|
||||
-- view_coord(abad.x+abad.bb.w+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
-- else
|
||||
-- view_coord(abad.x+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
-- end
|
||||
-- msg_print(abad.x, abad.y-8,msg)
|
||||
-- end
|
||||
font.current(font_sf)
|
||||
-- debug_info()
|
||||
end
|
||||
|
||||
|
||||
|
||||
function pause()
|
||||
print("pause()")
|
||||
-- surf.source(0)
|
||||
@@ -428,6 +374,83 @@ function update_pause()
|
||||
end
|
||||
end
|
||||
|
||||
function special_keys()
|
||||
if key.press(key.N1) then
|
||||
-- abad prev room
|
||||
local hab = abad.hab-1
|
||||
if hab<0 then hab=0 end
|
||||
local hab_x = 4
|
||||
local hab_y = 3
|
||||
local abad_x, abad_y = coords.room_to_world ( hab, hab_x, hab_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
if key.press(key.N2) then
|
||||
-- abad next room
|
||||
local hab = abad.hab+1
|
||||
if hab<0 then hab=0 end
|
||||
local hab_x = 4
|
||||
local hab_y = 3
|
||||
local abad_x, abad_y = coords.room_to_world ( hab, hab_x, hab_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
if key.press(key.N0) then
|
||||
-- abad go to room
|
||||
local abad_x, abad_y = coords.room_to_world ( 70, 6, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
end
|
||||
|
||||
function debug_info()
|
||||
font.current(font_default)
|
||||
viewp:print()
|
||||
msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
|
||||
msg_print(0,21,"VIEW= "..viewp.x..", "..viewp.y, true)
|
||||
local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
|
||||
msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
|
||||
msg_print(0,35,hab.." ( "..xx..", "..yy.." )", true)
|
||||
-- msg_print(0,42," JH= "..abad.jump_height,true)
|
||||
|
||||
-- view_coord(abad.x+8, abad.y+0, 16, 32, 6)
|
||||
-- view_coord(abad.x+abad.bb.x, abad.y+abad.bb.h, 2, 2, 4)
|
||||
-- view_coord(abad.x+abad.bb.x+abad.bb.w, abad.y+abad.bb.h, 2, 2, 2)
|
||||
-- view_coord(abad.x, abad.y, 2, 2, 3)
|
||||
|
||||
-- if key.press(key.T) then
|
||||
-- view_tile_id = not view_tile_id
|
||||
-- view_checking_tile = false
|
||||
-- end
|
||||
-- if key.press(key.C) then
|
||||
-- view_checking_tile = not view_checking_tile
|
||||
-- view_tile_id = false
|
||||
-- end
|
||||
--
|
||||
-- if view_tile_id then
|
||||
-- write_tile(abad.x, abad.y, 0, true, "R")
|
||||
-- write_tile(abad.x, abad.y+16, 0, true, "R")
|
||||
-- write_tile(abad.x, abad.y+32, 0, true, "R")
|
||||
--
|
||||
-- write_tile(abad.x+16, abad.y+32, 0, true, "C")
|
||||
--
|
||||
-- write_tile(abad.x+32, abad.y, 0, true, "L")
|
||||
-- write_tile(abad.x+32, abad.y+16, 0, true, "L")
|
||||
-- write_tile(abad.x+32, abad.y+32, 0, true, "L")
|
||||
-- end
|
||||
--
|
||||
-- if view_checking_tile then
|
||||
-- local msg = "FLIP= true"
|
||||
-- if not abad.flip then
|
||||
-- msg ="FLIP= false"
|
||||
-- view_coord(abad.x+abad.bb.w+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
-- else
|
||||
-- view_coord(abad.x+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
-- end
|
||||
-- msg_print(abad.x, abad.y-8,msg)
|
||||
-- end
|
||||
font.current(font_sf)
|
||||
end
|
||||
|
||||
flow:registrar("game", {game_init, update_game} )
|
||||
|
||||
@@ -69,6 +69,8 @@ function gota:update_normal()
|
||||
self.dy=-4
|
||||
self.dy=-2
|
||||
if self.hab==abad.hab then sound.play(audio_low) end
|
||||
else
|
||||
self.draw=gota.draw_falling
|
||||
end
|
||||
else
|
||||
--self.flip=not self.flip
|
||||
@@ -101,6 +103,13 @@ end
|
||||
function gota:hit()
|
||||
end
|
||||
|
||||
function gota:draw_falling()
|
||||
local gota_x, gota_y = viewp:screen_coords( self.x, self.y )
|
||||
draw.circf( gota_x+4, gota_y+12, 4, 16)
|
||||
draw.circf( gota_x+5, gota_y+13, 3, 11)
|
||||
surf.pixel( gota_x+3, gota_y+13, 2)
|
||||
end
|
||||
|
||||
function gota:draw_drop( x, y )
|
||||
splash_x, splash_y = viewp:screen_coords( x, y )
|
||||
draw.circf( splash_x, splash_y, 2, 16)
|
||||
|
||||
@@ -11,13 +11,13 @@ function invisible.new(_hab,_x,_y)
|
||||
hit=invisible.hit,
|
||||
update=invisible.update,
|
||||
draw=invisible.draw,
|
||||
bb={x=0,y=0,w=16,h=16}}
|
||||
bb={x=0,y=1,w=16,h=15}}
|
||||
end
|
||||
|
||||
function invisible:draw()
|
||||
-- Es invisible, res que drawar
|
||||
-- local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
-- draw.rectf(scr_x, scr_y, 16, 8, 2)
|
||||
-- local scr_x, scr_y = viewp:screen_coords( self.x+self.bb.x, self.y+self.bb.y )
|
||||
-- draw.rect(scr_x, scr_y, 16, 16, 3)
|
||||
end
|
||||
|
||||
function invisible:update()
|
||||
|
||||
@@ -87,7 +87,7 @@ function mini.init()
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
|
||||
flow:executar("title")
|
||||
flow:executar("logo")
|
||||
end
|
||||
|
||||
function mini.update()
|
||||
|
||||
@@ -29,7 +29,7 @@ scenes={
|
||||
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"MERDA!!","S'HA ENFADAT!!!","CACAUS A MI!!!!"},die=20},
|
||||
},
|
||||
llibre_trobat={
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Este llibre...","Es el de les tècniques","especials ..."}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Este llibre...","Es el de les tècniques","especials dels abad..."}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"...","TÈCNICA 'CACAU AERI'","salt i dispar"}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Ja se"," 'CACAU AERI'",""}},
|
||||
},
|
||||
@@ -52,8 +52,8 @@ scenes={
|
||||
},
|
||||
abad_inici={
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Se va a enterar eixe","imbècil de Batman","quan el pille..."}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Gonna per el GPS","per a trobarlo.",""}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"I igual hi ha","algú més per ací","que em puga ajudar."}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Ràpid! A casa de Batman!","Abans de que se menje","tots el cacaus"}},
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Vaig a parlar en Premiere","que està al pis de dalt", "a vore si me pot ajudar"}},
|
||||
},
|
||||
abad_corfes={
|
||||
{x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Osti, està ple de","monstruacos.",""}},
|
||||
|
||||
@@ -18,8 +18,8 @@ end
|
||||
|
||||
function trigger:draw()
|
||||
-- do nothing
|
||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
draw.rect(scr_x,scr_y,self.w,self.h,3)
|
||||
-- local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
-- draw.rect(scr_x,scr_y,self.w,self.h,3)
|
||||
end
|
||||
|
||||
function trigger:update()
|
||||
|
||||
Reference in New Issue
Block a user