function imp:do_jump ( jumpfwd ) if DEBUG_FN_NAME then print("do_jump") end -- msg_print(0,0,"do_jump",true) -- 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("state_jumping") end -- msg_print(0,0,"state_jumping",true) -- ?? self.wait=self.wait+1 self.wait=0 -- Pujar o caure if self.jump_height0 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: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_falling() if DEBUG_FN_NAME then print("state_falling") end -- msg_print(16,16,"state_falling",true) self.frame=30 self.wait=self.wait+1 -- 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("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("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 self.action_event = "land" end return can_land end function imp:advance() if DEBUG_FN_NAME then print("advance") end -- msg_print(10,20,"advance",true) 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)