610 lines
22 KiB
Lua
610 lines
22 KiB
Lua
function imp:_moure( foo, name )
|
|
name = name or "anonymous"
|
|
if not foo then
|
|
print_dbg(name.." not found")
|
|
else
|
|
print_dbg(name)
|
|
end
|
|
self.moure = foo
|
|
end
|
|
|
|
function noop ()
|
|
end
|
|
|
|
-------------------------------
|
|
--
|
|
-------------------------------
|
|
function imp:reduce_timers()
|
|
if self.mood==self.moods.stop then return end
|
|
if DEBUG_FN_NAME then print_dbg("reduce_timers") end
|
|
|
|
for key, val in pairs(self.timers) do
|
|
self.timers[key] = val - 1
|
|
if (val-1)<0 then self.timers[key] = 0 end
|
|
end
|
|
end
|
|
|
|
-------------------------------
|
|
--
|
|
-------------------------------
|
|
function imp:analyze_env() --OK
|
|
if self.mood==self.moods.stop then return end
|
|
if DEBUG_FN_NAME then print_dbg("analyze_env") end
|
|
-- Distancia fins a l'abad
|
|
local r = distancia(self,abad)
|
|
-- msg_print(10,20,r,true)
|
|
self.analisis.can_chase_abad = false
|
|
if r<=100 then
|
|
self.analisis.can_chase_abad=true
|
|
end
|
|
|
|
-- Els dos punts de cintura per a saber si es pot escalar
|
|
local x1_check = self.x+self.bb.x
|
|
local x2_check = self.x+self.bb.x+self.bb.w
|
|
local y_check = self.y+self.bb.h-4
|
|
local tile_type1, tile_code1= arc_check_tile(x1_check,y_check)
|
|
local tile_type2, tile_code2= arc_check_tile(x2_check,y_check)
|
|
self.analisis.can_climb = false
|
|
if tile_type1~=tiletype.void or tile_type2~=tiletype.void then
|
|
self.analisis.can_climb = true
|
|
end
|
|
|
|
-- Abad a tir
|
|
self.analisis.can_shot = false
|
|
if h_collision(self,abad) then self.analisis.can_shot=true end
|
|
|
|
-- Super preparat
|
|
self.analisis.can_super = false
|
|
if self.timers.super<=0 then self.analisis.can_super=true end
|
|
|
|
-- Acces a la zona central (només si el super està preparat)
|
|
x1_check = self.x+self.bb.x
|
|
x2_check = self.x+self.bb.x+self.bb.w
|
|
y_check = self.y+self.bb.h
|
|
self.analisis.can_go_altar = false
|
|
local hab1, tx1, ty1 = coords.world_to_tile(x1_check, y_check)
|
|
local hab2, tx2, ty2 = coords.world_to_tile(x2_check, y_check)
|
|
if (hab1==44 and tx1==6 and ty1==4) or (hab2==44 and tx2==7 and ty2==4)
|
|
or (hab1==45 and tx1==7 and ty1==3) or (hab2==45 and tx2==8 and ty2==3)then
|
|
if self.analisis.can_super then self.analisis.can_go_altar = true end
|
|
end
|
|
|
|
-- Cau al següent moviment?
|
|
self.analisis.going_to_fall = false
|
|
local step_length = self.step_length
|
|
if self.movement==self.actions.left then step_length = -step_length end
|
|
local tile_type1, tile_code1= arc_check_tile(x1_check+self.step_length,y_check)
|
|
local tile_type2, tile_code2= arc_check_tile(x2_check+self.step_length,y_check)
|
|
if tile_type1==tiletype.void and tile_type2==tiletype.void then
|
|
self.analisis.going_to_fall = true
|
|
end
|
|
|
|
-- Ha arribat a destí
|
|
self.analisis.target_reached = false
|
|
if not empty_table(self.pattern:target_node()) then
|
|
-- Target reached
|
|
if self.pattern:in_target(self) then self.analisis.target_reached=true end
|
|
-- if collision(self, self.pattern:target_node()) then self.analisis.target_reached=true end
|
|
end
|
|
end
|
|
|
|
-------------------------------
|
|
--
|
|
-------------------------------
|
|
function imp:choose_action() -- antic imp:move
|
|
if self.mood==self.moods.stop then return self.mood end
|
|
if DEBUG_FN_NAME then print_dbg("choose_action "..self.mood) end
|
|
|
|
local next_action = self.actions.no_action
|
|
|
|
-- Si no te ganes de fer res, no moure
|
|
if self.mood==self.moods.stop then return self.actions.no_action end
|
|
|
|
if self.analisis.going_to_fall then table.insert(self.action_event, "prefall") end
|
|
-- if self.analisis.target_reached then self.action_event="target" end
|
|
if self.analisis.can_go_altar then self:super_ready() end
|
|
-- if self.fight_mode == self.fight_modes["super"] then self.action_event="super" end
|
|
-- if self.fight_mode == self.fight_modes["end_super"] then self.action_event="end_super" end
|
|
|
|
next_action = self:next_action()
|
|
|
|
if self.analisis.target_reached and next_action=="super" then
|
|
-- print("Super READY!")
|
|
table.insert(self.action_event, "super_ready")
|
|
-- next_action = self:next_action()
|
|
self:super()
|
|
end
|
|
|
|
if self.old_action~=next_action then
|
|
self.old_action=next_action
|
|
-- print(self.old_action)
|
|
end
|
|
|
|
self.action = next_action
|
|
|
|
return next_action
|
|
end
|
|
|
|
-------------------------------
|
|
-- imp.controller_input()
|
|
--
|
|
-- Traduir a una entrada de pad
|
|
-------------------------------
|
|
function imp:controller_input()
|
|
if DEBUG_FN_NAME then print_dbg("controller_input") end
|
|
|
|
--To Do: JumpFWD
|
|
if (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
|
self.moure~=imp.state_super) and
|
|
(self.action == self.actions.right or self.action == self.actions.left) then
|
|
self.movement = self.action
|
|
-- self.moure=imp.state_walking
|
|
self:_moure(imp.state_walking, "state_walking (movement)")
|
|
elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
|
self.moure~=imp.state_super) and self.action == self.actions.jump then
|
|
self:do_jump()
|
|
elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
|
self.moure~=imp.state_super) and self.action == self.actions.jumpfwd then
|
|
self:do_jump(true)
|
|
elseif self.action == self.actions.shot then
|
|
self:shot()
|
|
elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
|
self.moure~=imp.state_super) and self.action == self.actions.super then
|
|
self.moure=imp.state_super
|
|
end
|
|
self.action = self.actions.no_action
|
|
self.action_event = {}
|
|
end
|
|
|
|
-------------------------------
|
|
--
|
|
-------------------------------
|
|
function imp:fight() -- OK
|
|
if DEBUG_FN_NAME then print_dbg("fight") end
|
|
self:create_hot_points()
|
|
self:load_pattern_paths()
|
|
|
|
self.pattern.manual_target = self.pattern.node[6]
|
|
self.pattern.manual_path = {target=6, actions={{action="right",event="target"}}}
|
|
|
|
self.shot_target = abad
|
|
|
|
self.mood=self.moods.chase
|
|
self:pattern_movement()
|
|
end
|
|
|
|
-------------------------------
|
|
--
|
|
-------------------------------
|
|
function imp:create_hot_points() --OK
|
|
self.pattern.node[1] = point.new(44, 6, 3, 0, 0,"P1")
|
|
self.pattern.node[2] = point.new(45, 7, 3, 0, 0,"P2")
|
|
self.pattern.node[3] = point.new(44,12, 5, 8, 0,"P3")
|
|
self.pattern.node[4] = point.new(54, 5, 4, -8, 0,"P4")
|
|
self.pattern.node[5] = point.new(54,12, 4, 8, 0,"P5")
|
|
self.pattern.node[6] = point.new(55, 8, 4, 8, 0,"P6")
|
|
self.pattern.node[7] = point.new(55, 8, 0, 0, 0,"P7")
|
|
self.pattern.node[8] = point.new(54, 5, 0, 0, 0,"P8")
|
|
self.pattern.node[9] = point.new(54, 9, 1, 0, 0,"P9")
|
|
self.pattern.node[10] = point.new(55, 4, 1, 0, 0,"P10")
|
|
-- self.hot_points[11] = abad
|
|
-- self.hot_points[11] = point.new(45, 1, 5, 8, 0,"altar-R")
|
|
-- self.hot_points[12] = point.new(44,11, 5, 0, 0,"altar-L")
|
|
end
|
|
|
|
-------------------------------
|
|
--
|
|
-------------------------------
|
|
function imp:load_pattern_paths() --OK
|
|
self.pattern.path[1] = {
|
|
{target=3, actions= {{action="right" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=4, actions= {{action="right" , event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=4, actions= {{action="right" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=10, actions= {{action="right" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=6, actions= {{action="right" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=5, actions= {{action="right" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=5, actions= {{action="right" , event="target"}}}
|
|
}
|
|
self.pattern.path[2] = {
|
|
{target=3, actions= {{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=6, actions= {{action="left" , event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=6, actions= {{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=9, actions= {{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=4, actions= {{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=5, actions= {{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=5, actions= {{action="left" , event="target"}}}
|
|
}
|
|
self.pattern.path[3] = {
|
|
{target=1, actions={{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="prefall"},
|
|
{action="jump" , event="target"}}},
|
|
{target=2, actions={{action="right" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="prefall"},
|
|
{action="jump" , event="target"}}},
|
|
{target=4, actions={{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="right" , event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=5, actions={{action="left" , event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=6, actions={{action="left" , event="land"},
|
|
{action="right" , event="target"}}}
|
|
}
|
|
self.pattern.path[4] = {
|
|
{target=1, actions={{action="jump" , event="target"}}},
|
|
{target=5, actions={{action="right", event="target"}}},
|
|
{target=6, actions={{action="right", event="target"}}},
|
|
{target=8, actions={{action="jump" , event="target"}}},
|
|
}
|
|
self.pattern.path[5] = {
|
|
{target=4, actions={{action="left" , event="target"}}},
|
|
{target=6, actions={{action="right", event="target"}}}
|
|
}
|
|
self.pattern.path[6] = {
|
|
{target=2, actions={{action="jump", event="target"}}},
|
|
{target=5, actions={{action="left", event="target"}}},
|
|
{target=7, actions={{action="jump", event="target"}}},
|
|
{target=4, actions={{action="left", event="target"}}}
|
|
}
|
|
self.pattern.path[7] = {
|
|
{target=5, actions={{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=10,actions={{action="left" , event="prefall"},
|
|
{action="jumpfwd", event="land"},
|
|
{action="left" , event="target"}}},
|
|
{target=2, actions={{action="jump" , event="target"}}}
|
|
}
|
|
self.pattern.path[8] = {
|
|
{target=5, actions={{action="right" , event="prefall"},
|
|
{action="jumpfwd" , event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=9, actions={{action="right" , event="land"},
|
|
{action="jumpfwd" , event="land"},
|
|
{action="right" , event="target"}}},
|
|
{target=1, actions={{action="jump" , event="target"}}}
|
|
}
|
|
self.pattern.path[9] = {
|
|
{target=5, actions={{action="right" , event="target"}}},
|
|
{target=1, actions={{action="left" , event="prefall"},
|
|
{action="jumpfwd" , event="land"},
|
|
{action="left" , event="prefall"},
|
|
{action="jump" , event="target"}}},
|
|
{target=4, actions={{action="left" , event="target"}}}
|
|
}
|
|
self.pattern.path[10] = {
|
|
{target=5, actions={{action="left" , event="target"}}},
|
|
{target=2, actions={{action="right" , event="prefall"},
|
|
{action="jumpfwd" , event="land"},
|
|
{action="right" , event="prefall"},
|
|
{action="jump" , event="target"}}},
|
|
{target=6, actions={{action="right" , event="target"}}}
|
|
}
|
|
self.pattern.path[11] = {
|
|
{target=4, actions={{action="left", event="target"}}}
|
|
}
|
|
self.pattern.path[12] = {
|
|
{target=6, actions={{action="right", event="target"}}}
|
|
}
|
|
|
|
end
|
|
|
|
-------------------------------------------------------------------
|
|
-- // PATTERN MOVEMENT
|
|
|
|
function imp:pattern_movement() --OK
|
|
if DEBUG_FN_NAME then print_dbg("pattern_movement") end
|
|
self.movement_type = "pattern"
|
|
-- print("Pattern")
|
|
end
|
|
|
|
-------------------------------------------------------------------
|
|
-- // ACTION
|
|
function imp:next_action()
|
|
local next_action = self.actions.no_action
|
|
|
|
-- Si el blanc està a tir disparar
|
|
if self.timers.shot<=0 then
|
|
if h_collision(self, self.shot_target) then
|
|
next_action = self.actions.shot
|
|
end
|
|
end
|
|
|
|
-- Resta d'accions
|
|
if next_action==self.actions.no_action then
|
|
if self.move_type==self.move_types.free then
|
|
-- FREE
|
|
-- next_action = self:free_next_action()
|
|
elseif self.move_type==self.move_types.pattern then
|
|
-- PATTERN
|
|
local in_target = self.pattern:in_target(self)
|
|
local action_event_done = in_table(self.action_event, self.pattern:event())
|
|
if in_target or action_event_done then
|
|
next_action=self.pattern:next_action()
|
|
print("TARGET => "..next_action)
|
|
else
|
|
next_action=self.pattern:action()
|
|
print("ON WAY => "..next_action)
|
|
end
|
|
elseif self.move_type==self.move_types.super then
|
|
-- SUPER
|
|
--
|
|
end
|
|
end
|
|
|
|
-- next_action es text, traduir
|
|
return self.actions[next_action]
|
|
end
|
|
|
|
function imp:do_jump ( jumpfwd )
|
|
if DEBUG_FN_NAME then print_dbg("") end
|
|
-- Inicialització de fer el salt
|
|
jumpfwd = jumpfwd or false
|
|
self.jump_height = 0
|
|
-- self.moure=imp.state_jumping
|
|
self:_moure(imp.state_jumping,"state_jumping (states)")
|
|
self.step=0
|
|
self.jumpfwd=jumpfwd
|
|
self.action=""
|
|
end
|
|
|
|
function imp:state_jumping()
|
|
if self.mood==self.moods.stop then return self.mood end
|
|
if DEBUG_FN_NAME then print_dbg("state_jumping") end
|
|
-- ??
|
|
self.wait=self.wait+1
|
|
self.wait=0
|
|
self.next_frame=imp.jumping_next_frame
|
|
-- Pujar o caure
|
|
if self.jump_height<self.max_jump_height then
|
|
-- Comprovar que pasa en l'aire
|
|
self:jump()
|
|
else
|
|
-- Canviar a mode caure
|
|
-- self.moure=imp.state_falling
|
|
self:_moure(imp.state_falling,"state_falling (states)")
|
|
end
|
|
self.step=self.step+1
|
|
|
|
-- cap endavant?
|
|
if self.jumpfwd then self:advance() end
|
|
end
|
|
|
|
function imp:jump()
|
|
if DEBUG_FN_NAME then print_dbg("jump") end
|
|
|
|
local vspace = self.vmove_space
|
|
-- Els dos punts de dalt del personatge
|
|
local x1_check = self.x+self.bb.x
|
|
local x2_check = self.x+self.bb.x+self.bb.w
|
|
local y_check = self.y-vspace; -- posicio de dalt
|
|
|
|
-- Comprovar on està pegant
|
|
local tile1_hit_type= arc_check_tile(x1_check, y_check )
|
|
local tile2_hit_type= arc_check_tile(x2_check, y_check)
|
|
local not_block_tile = tile1_hit_type ~= tiletype.block and tile2_hit_type ~= tiletype.block
|
|
|
|
-- Fer l'acció que correspon
|
|
if not_block_tile then
|
|
-- Ascendir
|
|
self.y=self.y-vspace
|
|
else
|
|
-- Si es un bloc permetre gastar l'espai no pintat
|
|
local tile1_hit = arc_get_tile(x1_check, y_check )
|
|
local tile2_hit = arc_get_tile(x2_check, y_check)
|
|
local half_block1 = mapa_is_half_block_tile(map_to_editor_tile(tile1_hit))
|
|
local half_block2 = mapa_is_half_block_tile(map_to_editor_tile(tile2_hit))
|
|
local full_block1 = tile1_hit_type == tiletype.block and not half_block1
|
|
local full_block2 = tile2_hit_type == tiletype.block and not half_block2
|
|
local full_block = full_block1 and full_block2
|
|
local half_block = half_block1 or half_block2
|
|
-- Si ninguno dels tiles tocats es un block complet
|
|
-- i almenys un dels tiles tocats es mig tile
|
|
-- permetre continuar en el salt
|
|
if not full_block and half_block then
|
|
if self.jump_in_half_block==0 and not self.jump_in_half_block_used then
|
|
self.jump_in_half_block = arcade_config.tiles_height / 2
|
|
end
|
|
if self.jump_in_half_block>0 then
|
|
self.y=self.y-vspace
|
|
self.jump_in_half_block = self.jump_in_half_block-1
|
|
self.jump_in_half_block_used = true
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Registrar el desplaçament
|
|
self.jump_height = self.jump_height+1
|
|
end
|
|
|
|
function imp:advance()
|
|
if DEBUG_FN_NAME then print_dbg("advance") end
|
|
|
|
local step_length=self.step_length; --lo que avança el imp cada pas
|
|
local limit=tiletype.block
|
|
|
|
if self.moure~=imp.state_walking then limit=tiletype.half end
|
|
|
|
local x_check = self.x+self.bb.x+self.bb.w+step_length
|
|
-- if self.flip then
|
|
-- step_length = -step_length
|
|
-- x_check = self.x+self.bb.x+step_length
|
|
-- end
|
|
|
|
-- self.action=="right"
|
|
-- if self.action=="left" then
|
|
-- print("ADVANCE => "..self.movement)
|
|
if self.movement==self.actions.left then
|
|
step_length = -step_length
|
|
x_check = self.x+self.bb.x+step_length
|
|
end
|
|
|
|
local y_check = self.y+self.bb.h-4
|
|
|
|
if arc_check_tile(x_check, y_check)<limit then
|
|
self.x=self.x+step_length
|
|
end
|
|
|
|
local hab,xx, yy = coords.world_to_tile(self.x, self.y)
|
|
self.hab = hab
|
|
-- self.movement = ""
|
|
end
|
|
|
|
function imp:state_falling()
|
|
if DEBUG_FN_NAME then print_dbg("state_falling") end
|
|
-- msg_print(16,16,"state_falling",true)
|
|
|
|
self.frame=30
|
|
self.wait=self.wait+1
|
|
self.next_frame=imp.falling_next_frame
|
|
-- Si toca terra canviar el mode
|
|
if self:land() then
|
|
-- self.moure=imp.state_normal
|
|
self:_moure(imp.state_normal,"state_normal (states)")
|
|
return
|
|
end
|
|
-- print_dbg("FALLING!")
|
|
-- Seguir caiguent
|
|
self.y=self.y+1
|
|
self.jump_height = self.jump_height-1
|
|
self.falling=self.falling+1
|
|
|
|
-- Caiguent cap endavant?
|
|
if self.jumpfwd then self:advance() end
|
|
end
|
|
|
|
function imp:land ()
|
|
if DEBUG_FN_NAME then print_dbg("land") end
|
|
-- msg_print(16,32,"land",true)
|
|
-- Els dos punts de baix de l'abad
|
|
local x1_check = self.x+self.bb.x
|
|
local x2_check = self.x+self.bb.x+self.bb.w
|
|
local y_check = self.y+self.bb.h
|
|
|
|
-- Comprovar on està aterrant
|
|
local tile1_hit= arc_check_tile(x1_check, y_check )
|
|
local tile2_hit= arc_check_tile(x2_check, y_check)
|
|
local floor_tile = tile1_hit>=tiletype.half or tile2_hit>=tiletype.half
|
|
|
|
-- Encara que siga un tile de piso s'ha de comprovar que
|
|
-- la y es un múltiple de l'alt dels tiles
|
|
local over_tile = (y_check & 0xF) == 0
|
|
|
|
local can_land = floor_tile and over_tile
|
|
|
|
if can_land then
|
|
self.jump_in_half_block_used = false
|
|
self.jump_height = 0
|
|
table.insert(self.action_event, "land")
|
|
end
|
|
-- if can_land then print_dbg ("LANDED") end
|
|
return can_land
|
|
end
|
|
|
|
function imp:state_walking()
|
|
if self.mood==self.moods.stop then return end
|
|
if not DEBUG_FN_NAME then print("state_walking") end
|
|
-- msg_print(16,48,"state_walking",true)
|
|
|
|
-- Limitar la velocitat de moviment
|
|
self.wait=self.wait+1
|
|
|
|
-- Funció de selecció de frame
|
|
self.next_frame = imp.walking_next_frame
|
|
|
|
-- Comprovar dos punts de contacte del personatge en el piso a vore si cau
|
|
local x1_check = self.x+self.bb.x
|
|
local x2_check = x1_check+self.bb.w
|
|
local y_check = self.y+self.bb.h; -- base del personatge
|
|
local tile1 = arc_check_tile(x1_check,y_check)
|
|
local tile2 = arc_check_tile(x2_check,y_check)
|
|
if tile1==tiletype.void and tile2==tiletype.void then
|
|
-- si no hi ha piso, caure
|
|
self.moure=imp.state_falling
|
|
self:_moure(imp.state_falling, "state_falling (states-walking)")
|
|
return
|
|
end
|
|
|
|
self:advance()
|
|
end
|
|
|
|
function imp:state_normal()
|
|
if DEBUG_FN_NAME then print_dbg("state_normal") end
|
|
self.frame=28
|
|
self.wait=0
|
|
self.step=0
|
|
self.jumpfwd=false
|
|
self.jump_height = 0
|
|
self.next_frame=imp.staying_next_frame
|
|
end
|
|
|
|
-- imp.next_frame()
|
|
function imp:walking_next_frame()
|
|
-- Selecció de frame
|
|
if self.wait==6 then
|
|
self.wait=0
|
|
self.step=(self.step+1)%4
|
|
self.frame=self.anim[self.step+1]
|
|
end
|
|
|
|
-- Orientar
|
|
self:do_flip()
|
|
|
|
-- Aguantar el flip
|
|
if self.timers.flip_wait<=0 then
|
|
if self.mood==self.moods.chase then
|
|
self:do_flip(abad)
|
|
else
|
|
self:do_flip(self.pattern:target_node())
|
|
end
|
|
end
|
|
end
|
|
|
|
function imp:jumping_next_frame()
|
|
self.frame=30
|
|
end
|
|
|
|
function imp:falling_next_frame()
|
|
self.frame=30
|
|
end
|
|
|
|
function imp:staying_next_frame()
|
|
self.frame=28
|
|
end
|
|
|
|
function imp:super_next_frame()
|
|
self.frame=11
|
|
end
|
|
|
|
function imp:do_flip( actor )
|
|
actor = actor or self.pattern:target_node()
|
|
-- enllaçat a actor
|
|
if actor.x<self.x then self.flip=true else self.flip=false end
|
|
end
|