[WIP] Reestructurant codi
[WIP] Stage 2 ja 'arranca'
This commit is contained in:
+39
-19
@@ -1,23 +1,43 @@
|
||||
audio_main_song="mus_menu.ogg"
|
||||
audio_song_batman="mus_batm.ogg"
|
||||
audio_main_song ="mus_menu.ogg"
|
||||
audio_song_batman ="mus_batm.ogg"
|
||||
audio_song_premiere="mus_prem.ogg"
|
||||
audio_song_elalien="mus_alie.ogg"
|
||||
audio_life_lost="mus_life.ogg"
|
||||
audio_game_over="mus_over.ogg"
|
||||
audio_song_imp="mus_imp.ogg"
|
||||
audio_song_copter="mus_copter.ogg"
|
||||
audio_song_elalien ="mus_alie.ogg"
|
||||
audio_life_lost ="mus_life.ogg"
|
||||
audio_game_over ="mus_over.ogg"
|
||||
audio_song_imp ="mus_imp.ogg"
|
||||
audio_song_copter ="mus_copter.ogg"
|
||||
audio_final=audio_main_song
|
||||
|
||||
audio_abad_jump="snd_ajmp.wav"
|
||||
audio_abad_fall="snd_afal.wav"
|
||||
audio_abad_hit="snd_ahit.wav"
|
||||
audio_abad_shot="snd_asht.wav"
|
||||
audio_abad_step={"snd_ast1.wav", "snd_ast2.wav", "snd_ast3.wav", "snd_ast2.wav"}
|
||||
audio_switch="snd_swch.wav"
|
||||
audio_hit="snd_hit.wav"
|
||||
audio_low="snd_low.wav"
|
||||
audio_text_abad="snd_txta.wav"
|
||||
audio_abad_jump ="snd_ajmp.wav"
|
||||
audio_abad_fall ="snd_afal.wav"
|
||||
audio_abad_hit ="snd_ahit.wav"
|
||||
audio_abad_shot ="snd_asht.wav"
|
||||
audio_abad_step ={"snd_ast1.wav", "snd_ast2.wav", "snd_ast3.wav", "snd_ast2.wav"}
|
||||
audio_switch ="snd_swch.wav"
|
||||
audio_hit ="snd_hit.wav"
|
||||
audio_low ="snd_low.wav"
|
||||
audio_text_abad ="snd_txta.wav"
|
||||
audio_text_premiere="snd_txtp.wav"
|
||||
audio_text_elalien="snd_txte.wav"
|
||||
audio_text_batman="snd_txtb.wav"
|
||||
audio_text_imp="snd_txtb.wav"
|
||||
audio_text_elalien ="snd_txte.wav"
|
||||
audio_text_batman ="snd_txtb.wav"
|
||||
audio_text_imp ="snd_txtb.wav"
|
||||
|
||||
function audio_init()
|
||||
-- Càrrega dels audios
|
||||
audio_text_abad = sound.load(audio_text_abad)
|
||||
audio_text_premiere = sound.load(audio_text_premiere)
|
||||
audio_text_elalien = sound.load(audio_text_elalien)
|
||||
audio_text_batman = sound.load(audio_text_batman)
|
||||
audio_text_imp = sound.load(audio_text_imp)
|
||||
audio_abad_jump = sound.load(audio_abad_jump)
|
||||
audio_abad_fall = sound.load(audio_abad_fall)
|
||||
audio_abad_hit = sound.load(audio_abad_hit)
|
||||
audio_abad_shot = sound.load(audio_abad_shot)
|
||||
audio_abad_step[1] = sound.load(audio_abad_step[1])
|
||||
audio_abad_step[2] = sound.load(audio_abad_step[2])
|
||||
audio_abad_step[3] = sound.load(audio_abad_step[3])
|
||||
audio_abad_step[4] = audio_abad_step[2]
|
||||
audio_switch = sound.load(audio_switch)
|
||||
audio_hit = sound.load(audio_hit)
|
||||
audio_low = sound.load(audio_low)
|
||||
end
|
||||
|
||||
+23
-126
@@ -64,6 +64,19 @@ require "sign"
|
||||
|
||||
font_default = font.current()
|
||||
|
||||
local tile_w = arcade_config.tiles_width
|
||||
local tile_h = arcade_config.tiles_height
|
||||
local res_w = arcade_config.resolucion.width
|
||||
local res_h = arcade_config.resolucion.height
|
||||
|
||||
local view_tile_id = false
|
||||
local view_checking_tile = false
|
||||
|
||||
viewp = viewport.new(arcade_config.resolucion.width, arcade_config.resolucion.height)
|
||||
viewp:position(0,0)
|
||||
|
||||
-- actors={}
|
||||
|
||||
function game_load()
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
@@ -88,6 +101,11 @@ function game_init(menu)
|
||||
states:next()
|
||||
end
|
||||
|
||||
function game_exit()
|
||||
-- mapa_restore_backup()
|
||||
actors={}
|
||||
-- cameras={}
|
||||
end
|
||||
--
|
||||
-- Carregar fonts general del joc
|
||||
--
|
||||
@@ -105,120 +123,16 @@ function images_init()
|
||||
warp.init(tiles)
|
||||
end
|
||||
|
||||
function image_close()
|
||||
surf.free(tiles)
|
||||
warp.close()
|
||||
end
|
||||
-- function image_close()
|
||||
-- surf.free(tiles)
|
||||
-- warp.close()
|
||||
-- end
|
||||
|
||||
function mapa_surface_init()
|
||||
if (sf_mapa) then surf.free(sf_mapa) end
|
||||
sf_mapa=surf.new(mapa_room_cols*mapa_rooms_per_piso,mapa_room_rows*mapa_pisos)
|
||||
end
|
||||
|
||||
function audio_init()
|
||||
-- Càrrega dels audios
|
||||
audio_text_abad = sound.load(audio_text_abad)
|
||||
audio_text_premiere = sound.load(audio_text_premiere)
|
||||
audio_text_elalien = sound.load(audio_text_elalien)
|
||||
audio_text_batman = sound.load(audio_text_batman)
|
||||
audio_text_imp = sound.load(audio_text_imp)
|
||||
audio_abad_jump = sound.load(audio_abad_jump)
|
||||
audio_abad_fall = sound.load(audio_abad_fall)
|
||||
audio_abad_hit = sound.load(audio_abad_hit)
|
||||
audio_abad_shot = sound.load(audio_abad_shot)
|
||||
audio_abad_step[1] = sound.load(audio_abad_step[1])
|
||||
audio_abad_step[2] = sound.load(audio_abad_step[2])
|
||||
audio_abad_step[3] = sound.load(audio_abad_step[3])
|
||||
audio_abad_step[4] = audio_abad_step[2]
|
||||
audio_switch = sound.load(audio_switch)
|
||||
audio_hit = sound.load(audio_hit)
|
||||
audio_low = sound.load(audio_low)
|
||||
end
|
||||
|
||||
|
||||
local tile_w = arcade_config.tiles_width
|
||||
local tile_h = arcade_config.tiles_height
|
||||
local res_w = arcade_config.resolucion.width
|
||||
local res_h = arcade_config.resolucion.height
|
||||
|
||||
local view_tile_id = false
|
||||
local view_checking_tile = false
|
||||
|
||||
viewp = viewport.new(arcade_config.resolucion.width, arcade_config.resolucion.height)
|
||||
viewp:position(0,0)
|
||||
|
||||
function foo()
|
||||
print("foo")
|
||||
end
|
||||
|
||||
function actor_warp_draw(actor)
|
||||
local shrink_w = actor.w*actor.shrink
|
||||
local shrink_h = actor.h*actor.shrink
|
||||
local offset_x = math.floor((actor.w-shrink_w)/2)
|
||||
local offset_y = math.floor((actor.h-shrink_h)/2)
|
||||
local scr_x, scr_y = viewp:screen_coords( actor.x+offset_x, actor.y+offset_y )
|
||||
shrink_w = math.floor(shrink_w)
|
||||
shrink_h = math.floor(shrink_h)
|
||||
|
||||
if shrink_w>0 and shrink_h>0 then
|
||||
draw.surfrot((actor.frame&7)*cw, (actor.frame>>cxr2)*ch,
|
||||
cw, ch,
|
||||
scr_x, scr_y,
|
||||
actor.angle,
|
||||
shrink_w, shrink_h,
|
||||
actor.flip)
|
||||
end
|
||||
end
|
||||
|
||||
function actor_warp_update(actor)
|
||||
-- warp, wait, respawn
|
||||
if actor.warping then
|
||||
if actor.step<actor.death_time then
|
||||
actor.shrink=actor.shrink-actor.d_shrink
|
||||
actor.angle=actor.angle+actor.d_angle
|
||||
if actor.angle>=360 then actor.angle = actor.angle % 360 end
|
||||
if actor.shrink<=0 then
|
||||
actor.shrink=1
|
||||
actor.d_shrink=1
|
||||
actor.angle=0
|
||||
actor.d_angle=1
|
||||
actor.warping = false
|
||||
actor.frame = -1
|
||||
actor.step = 0
|
||||
if actor.energy~=nil then
|
||||
actor.energy = actor.max_energy
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif actor.step<actor.death_time/2 then
|
||||
actor.frame = -1
|
||||
elseif actor.step<actor.death_time then
|
||||
if actor.step%2==0 then
|
||||
actor.frame=actor.anim[#actor.anim]
|
||||
else
|
||||
actor.frame=-1
|
||||
end
|
||||
elseif actor.step>=actor.death_time then
|
||||
actor.frame=actor.anim[1]
|
||||
actor.step=0
|
||||
actor.wait=0
|
||||
if actor.name=="caco" then
|
||||
actor.update=caco.update_normal
|
||||
elseif actor.name=="zombie" then
|
||||
actor.update=zombie.update_normal
|
||||
end
|
||||
actor.dying = false
|
||||
end
|
||||
end
|
||||
|
||||
actors={}
|
||||
|
||||
function game_exit()
|
||||
-- mapa_restore_backup()
|
||||
actors={}
|
||||
-- cameras={}
|
||||
end
|
||||
|
||||
function render_map( sf_map, sf_tiles, x, y, target )
|
||||
target = target or 0
|
||||
map.surf(sf_map)
|
||||
@@ -230,23 +144,6 @@ function render_map( sf_map, sf_tiles, x, y, target )
|
||||
view.origin(0,0)
|
||||
end
|
||||
|
||||
function viewport_update()
|
||||
-- Moure el viewport
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
|
||||
local vp_center_offset_x = (viewp.width // 2)
|
||||
local vp_center_offset_y = (viewp.height // 2)
|
||||
|
||||
vp_x = abad.x+(abad.w/2) - 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()
|
||||
@@ -327,7 +224,7 @@ function update_game()
|
||||
|
||||
world_update()
|
||||
|
||||
viewport_update()
|
||||
stages.stage_viewport_update()
|
||||
|
||||
world_draw()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local mini_version = ""
|
||||
local versio_req = {1,5,11}
|
||||
local versio_req = {1,5,13}
|
||||
local parts = {}
|
||||
local printed = false
|
||||
|
||||
|
||||
+20
-2
@@ -15,7 +15,7 @@ function stages.stage1_init()
|
||||
mapa_room_rows = s01_mapa_room_rows
|
||||
mapa_rooms_per_piso = s01_mapa_rooms_per_piso
|
||||
mapa_pisos = s01_mapa_pisos
|
||||
mapa_empty_tile = s01_mapa_empty_tile
|
||||
mapa_empty_tile = s01_mapa_empty_tile
|
||||
|
||||
tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5}
|
||||
mapa.wait=0
|
||||
@@ -204,11 +204,12 @@ function stages.stage1_init()
|
||||
|
||||
-- abad init
|
||||
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
|
||||
-- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
|
||||
local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
|
||||
-- local abad_x, abad_y = coords.room_to_world ( 8, 9, 3 )
|
||||
abad:move(abad_x, abad_y)
|
||||
abad_make_safe( true )
|
||||
|
||||
-- viewport init
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
viewp:free_move()
|
||||
end
|
||||
@@ -245,6 +246,23 @@ function stages.stage1_bg_music()
|
||||
music_player:play(audio_song_premiere)
|
||||
end
|
||||
|
||||
function stages.stage1_viewport_update()
|
||||
-- Moure el viewport
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
|
||||
local vp_center_offset_x = (viewp.width // 2)
|
||||
local vp_center_offset_y = (viewp.height // 2)
|
||||
|
||||
vp_x = abad.x+(abad.w/2) - 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 stages.stage1_toBatcave()
|
||||
local switches_enabled = 0
|
||||
|
||||
|
||||
+12
-30
@@ -11,23 +11,6 @@ function stages.stage1_boss_ready()
|
||||
stages.boss_finished = false
|
||||
end
|
||||
|
||||
-- function stages.stage1_boss()
|
||||
-- -- if not scene.running and not stages.boss_loaded then
|
||||
-- load_tilemap( sf_mapa, stage1_boss_mapa )
|
||||
-- -- actors_in_room_backup_and_remove(stage1_boss_mapa.r0.r,stage1_boss_mapa.r1.r)
|
||||
-- -- viewp:fixed({l=8,r=44,u=48,d=0}, viewp.x, viewp.y-48)
|
||||
-- -- viewp:fixed({l=8,r=44,u=0,d=0})
|
||||
-- stages.boss_loaded = true
|
||||
-- boss.reason=""
|
||||
-- boss.enabled=true
|
||||
-- boss:fight()
|
||||
-- trigger_event.new("Premiere Boss 1",
|
||||
-- trigger_ev.premiere_boss1_trigger,
|
||||
-- trigger_ev.premiere_healer_init,
|
||||
-- premiere.healer_update)
|
||||
-- -- end
|
||||
-- end
|
||||
|
||||
function stages.stage1_boss_update()
|
||||
-- print("stage1_update")
|
||||
fireball.update()
|
||||
@@ -51,22 +34,21 @@ function stages.stage1_boss_draw_front()
|
||||
boss_meter:draw()
|
||||
end
|
||||
|
||||
function stages.stage1_boss_bg_music()
|
||||
-- music_player:play(audio_song_premiere)
|
||||
end
|
||||
|
||||
function stages.stage1_boss_viewport_update()
|
||||
-- Moure el viewport
|
||||
stages.stage1_viewport_update()
|
||||
end
|
||||
|
||||
|
||||
function stages.stage1_boss_finished()
|
||||
stages.boss_ready = true
|
||||
stages.boss_finished = true
|
||||
end
|
||||
|
||||
-- function stages.stage1_boss_end()
|
||||
-- mapa_restore_backup()
|
||||
-- set_actors_enabled_by_room(true, "boss", stage1_boss_mapa.r0.r, stage1_boss_mapa.r1.r)
|
||||
-- remove_actor(boss)
|
||||
-- stages.boss_ready = false
|
||||
-- stages.boss_finished = false
|
||||
-- stages.boss_loaded = false
|
||||
-- viewp:free_move()
|
||||
-- end
|
||||
|
||||
|
||||
-- INTRO FUNCTIONS
|
||||
function stages.stage1_boss_intro_init()
|
||||
trigger_event.new("Premiere Boss 1",
|
||||
@@ -75,7 +57,7 @@ function stages.stage1_boss_intro_init()
|
||||
premiere.healer_update)
|
||||
load_tilemap( sf_mapa, stage1_boss_mapa )
|
||||
set_actors_enabled_by_room(false, "boss", stage1_boss_mapa.r0.r, stage1_boss_mapa.r1.r)
|
||||
viewp:fixed({l=8,r=44,u=0,d=0}, viewp.x, viewp.y-48)
|
||||
viewp:fixed({l=24,r=28,u=0,d=0}, viewp.x, viewp.y-48)
|
||||
boss.enabled=true
|
||||
boss.reason=""
|
||||
boss:fight()
|
||||
@@ -86,7 +68,7 @@ end
|
||||
|
||||
function stages.stage1_boss_intro_update()
|
||||
if stage1_boss.time==0 then
|
||||
start_scene(scenes.lluita_imp, nil, false)
|
||||
-- start_scene(scenes.lluita_imp, nil, false)
|
||||
stages.stage1_boss_ready()
|
||||
end
|
||||
|
||||
|
||||
+37
-6
@@ -1,6 +1,3 @@
|
||||
-- stages = {}
|
||||
|
||||
-- stages.actors={}
|
||||
|
||||
function stages.stage2_init()
|
||||
-- stagemgr init
|
||||
@@ -13,12 +10,26 @@ function stages.stage2_init()
|
||||
|
||||
-- mapa init
|
||||
mapa = stage2_mapa
|
||||
|
||||
mapa_room_cols = s02_mapa_room_cols
|
||||
mapa_room_rows = s02_mapa_room_rows
|
||||
mapa_rooms_per_piso = s02_mapa_rooms_per_piso
|
||||
mapa_pisos = s02_mapa_pisos
|
||||
mapa_empty_tile = s02_mapa_empty_tile
|
||||
|
||||
tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5}
|
||||
mapa.wait=0
|
||||
mapa.step=0
|
||||
surf.free(sf_mapa)
|
||||
sf_mapa=surf.new(s2_mapa_room_cols*s2_mapa_rooms_per_piso,s2_mapa_room_rows*s2_mapa_pisos)
|
||||
mapa_surface_init()
|
||||
load_tilemap( sf_mapa )
|
||||
|
||||
coords.set_config({
|
||||
tiles_width = arcade_config.tiles_width,
|
||||
tiles_height = arcade_config.tiles_height,
|
||||
room_cols = mapa_room_cols,
|
||||
room_rows = mapa_room_rows,
|
||||
rooms_per_floor = mapa_rooms_per_piso,
|
||||
})
|
||||
|
||||
-- actors init
|
||||
batvio.init()
|
||||
@@ -33,7 +44,6 @@ function stages.stage2_init()
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
viewp:free_move()
|
||||
|
||||
-- remote_view_init()
|
||||
end
|
||||
|
||||
function stages.stage2_update()
|
||||
@@ -60,6 +70,27 @@ function stages.stage2_draw_front()
|
||||
|
||||
end
|
||||
|
||||
function stages.stage2_bg_music()
|
||||
music_player:play(audio_song_premiere)
|
||||
end
|
||||
|
||||
function stages.stage2_viewport_update()
|
||||
-- Moure el viewport
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
|
||||
local vp_center_offset_x = (viewp.width // 2)
|
||||
local vp_center_offset_y = (viewp.height // 2)
|
||||
|
||||
vp_x = abad.x+(abad.w/2) - 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
|
||||
|
||||
require "stage2_world_map"
|
||||
require "stage2_boss_map"
|
||||
require "stage2_boss"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
s2_mapa_room_cols = 12; -- en quantitat de tiles
|
||||
s2_mapa_room_rows = 6; -- en quantitat de tiles
|
||||
s2_mapa_rooms_per_piso = 16
|
||||
s2_mapa_pisos = 1
|
||||
mapa_empty_tile = 256
|
||||
s02_mapa_room_cols = 12; -- en quantitat de tiles
|
||||
s02_mapa_room_rows = 6; -- en quantitat de tiles
|
||||
s02_mapa_rooms_per_piso = 16
|
||||
s02_mapa_pisos = 1
|
||||
mapa_empty_tile = 256
|
||||
|
||||
stage2_mapa={
|
||||
-- 1
|
||||
|
||||
+18
-14
@@ -1,8 +1,8 @@
|
||||
stages = {}
|
||||
|
||||
stages.stage = 1
|
||||
stages.stage = 2
|
||||
stages.stage_loaded = 0
|
||||
stages.last_stage = 1
|
||||
stages.last_stage = 2
|
||||
|
||||
stages.actors={}
|
||||
stages.boss_loaded = false
|
||||
@@ -20,12 +20,13 @@ stages.stage_bg_music = nil
|
||||
function stages.load_stage( init )
|
||||
print("Loading stage "..stages.stage)
|
||||
init = init or false
|
||||
stages.stage_init = stages["stage"..stages.stage.."_init"]
|
||||
stages.stage_update = stages["stage"..stages.stage.."_update"]
|
||||
stages.stage_draw_back = stages["stage"..stages.stage.."_draw_back"]
|
||||
stages.stage_draw_middle = stages["stage"..stages.stage.."_draw_middle"]
|
||||
stages.stage_draw_front = stages["stage"..stages.stage.."_draw_front"]
|
||||
stages.stage_bg_music = stages["stage"..stages.stage.."_bg_music"]
|
||||
stages.stage_init = stages["stage"..stages.stage.."_init"]
|
||||
stages.stage_update = stages["stage"..stages.stage.."_update"]
|
||||
stages.stage_draw_back = stages["stage"..stages.stage.."_draw_back"]
|
||||
stages.stage_draw_middle = stages["stage"..stages.stage.."_draw_middle"]
|
||||
stages.stage_draw_front = stages["stage"..stages.stage.."_draw_front"]
|
||||
stages.stage_bg_music = stages["stage"..stages.stage.."_bg_music"]
|
||||
stages.stage_viewport_update = stages["stage"..stages.stage.."_viewport_update"]
|
||||
stages.stage_loaded = stages.stage
|
||||
stages.boss_ready = false
|
||||
stages.boss_loaded = false
|
||||
@@ -33,11 +34,13 @@ function stages.load_stage( init )
|
||||
end
|
||||
|
||||
function stages.load_boss_stage()
|
||||
stages.stage_init = stages["stage"..stages.stage.."_boss_init"]
|
||||
stages.stage_update = stages["stage"..stages.stage.."_boss_update"]
|
||||
stages.stage_draw_back = stages["stage"..stages.stage.."_boss_draw_back"]
|
||||
stages.stage_draw_middle = stages["stage"..stages.stage.."_boss_draw_middle"]
|
||||
stages.stage_draw_front = stages["stage"..stages.stage.."_boss_draw_front"]
|
||||
stages.stage_init = stages["stage"..stages.stage.."_boss_init"]
|
||||
stages.stage_update = stages["stage"..stages.stage.."_boss_update"]
|
||||
stages.stage_draw_back = stages["stage"..stages.stage.."_boss_draw_back"]
|
||||
stages.stage_draw_middle = stages["stage"..stages.stage.."_boss_draw_middle"]
|
||||
stages.stage_draw_front = stages["stage"..stages.stage.."_boss_draw_front"]
|
||||
stages.stage_bg_music = stages["stage"..stages.stage.."_boss_bg_music"]
|
||||
stages.stage_viewport_update = stages["stage"..stages.stage.."_boss_viewport_update"]
|
||||
stages.boss_loaded = true
|
||||
end
|
||||
|
||||
@@ -57,4 +60,5 @@ function stages.next_stage()
|
||||
end
|
||||
end
|
||||
|
||||
require "stage1"
|
||||
require "stage1"
|
||||
require "stage2"
|
||||
@@ -99,3 +99,62 @@ function warp.update_all()
|
||||
end
|
||||
end
|
||||
|
||||
function actor_warp_draw(actor)
|
||||
local shrink_w = actor.w*actor.shrink
|
||||
local shrink_h = actor.h*actor.shrink
|
||||
local offset_x = math.floor((actor.w-shrink_w)/2)
|
||||
local offset_y = math.floor((actor.h-shrink_h)/2)
|
||||
local scr_x, scr_y = viewp:screen_coords( actor.x+offset_x, actor.y+offset_y )
|
||||
shrink_w = math.floor(shrink_w)
|
||||
shrink_h = math.floor(shrink_h)
|
||||
|
||||
if shrink_w>0 and shrink_h>0 then
|
||||
draw.surfrot((actor.frame&7)*cw, (actor.frame>>cxr2)*ch,
|
||||
cw, ch,
|
||||
scr_x, scr_y,
|
||||
actor.angle,
|
||||
shrink_w, shrink_h,
|
||||
actor.flip)
|
||||
end
|
||||
end
|
||||
|
||||
function actor_warp_update(actor)
|
||||
-- warp, wait, respawn
|
||||
if actor.warping then
|
||||
if actor.step<actor.death_time then
|
||||
actor.shrink=actor.shrink-actor.d_shrink
|
||||
actor.angle=actor.angle+actor.d_angle
|
||||
if actor.angle>=360 then actor.angle = actor.angle % 360 end
|
||||
if actor.shrink<=0 then
|
||||
actor.shrink=1
|
||||
actor.d_shrink=1
|
||||
actor.angle=0
|
||||
actor.d_angle=1
|
||||
actor.warping = false
|
||||
actor.frame = -1
|
||||
actor.step = 0
|
||||
if actor.energy~=nil then
|
||||
actor.energy = actor.max_energy
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif actor.step<actor.death_time/2 then
|
||||
actor.frame = -1
|
||||
elseif actor.step<actor.death_time then
|
||||
if actor.step%2==0 then
|
||||
actor.frame=actor.anim[#actor.anim]
|
||||
else
|
||||
actor.frame=-1
|
||||
end
|
||||
elseif actor.step>=actor.death_time then
|
||||
actor.frame=actor.anim[1]
|
||||
actor.step=0
|
||||
actor.wait=0
|
||||
if actor.name=="caco" then
|
||||
actor.update=caco.update_normal
|
||||
elseif actor.name=="zombie" then
|
||||
actor.update=zombie.update_normal
|
||||
end
|
||||
actor.dying = false
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user