------------------------------------------------------------------- -- // FREE MOVEMENT function imp:free_movement() --OK if DEBUG_FN_NAME then print("free_movement") end self.move_type = self.move_types.free print("Free") end ------------------------------------------------------------------- -- // PATTERN MOVEMENT function imp:pattern_movement() --OK if DEBUG_FN_NAME then print("pattern_movement") end self.movement_type = "pattern" -- print("Pattern") end function imp:pattern_recovery() -- OK -- print("Pattern recovery") self:pattern_movement() -- Canviar a moviment per patró self:path_reset() -- Borrar les instruccions pendents -- Situar-se en el mapa respecte als punts de recuperació (els tres punts del pis) local x_after_4 = false local x_after_5 = false local x_after_6 = false local y_upper_4 = false local y_upper_5 = false local y_upper_6 = false if self.hot_points[4].xself.y+self.h then y_upper_4 = true end if self.hot_points[5].y>self.y+self.h then y_upper_5 = true end if self.hot_points[6].y>self.y+self.h then y_upper_6 = true end -- Seleccionar les instruccions segons la posicio if not y_upper_5 then -- target 5 self.target = self.hot_points[5] if not x_after_5 then -- right target self.path = {next=5, actions={{action="right",event="target"}}} else -- left target self.path = {next=5, actions={{action="left",event="target"}}} end else if x_after_5 then --target 4 self.target = self.hot_points[4] -- left target self.path = {next=4, actions={{action="left",event="target"}}} else --target 6 self.target = self.hot_points[6] -- right target self.path = {next=6, actions={{action="right",event="target"}}} end end -- Tornar l'acció a fer return self.actions[self.path.actions[1].action] end ------------------------------- -- imp.controller_input() -- -- Traduir a una entrada de pad ------------------------------- function imp:controller_input() if DEBUG_FN_NAME then print("controller_input") end print(self.action) --To Do: JumpFWD if 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.action == self.actions.jump then self:do_jump() elseif self.action == "jumpfwd" then -- self:do_jump(true) elseif self.action == self.actions.shot then -- self:shot() elseif self.action == self.actions.super then -- self.moure=imp.state_super end self.action = self.actions.no_action end