[WIP] Continue treballant en el jefe
This commit is contained in:
139
data/imp.lua
139
data/imp.lua
@@ -76,7 +76,7 @@ function imp.new(_hab, _x, _y)
|
||||
fight=imp.fight,
|
||||
draw=imp.draw,
|
||||
hit=imp.hit,
|
||||
direccio=imp.direccio,
|
||||
-- direccio=imp.direccio,
|
||||
do_jump=imp.do_jump,
|
||||
jump=imp.jump,
|
||||
state_jumping=imp.state_jumping,
|
||||
@@ -112,36 +112,8 @@ function imp:hit()
|
||||
print("HIT!")
|
||||
end
|
||||
|
||||
function imp:direccio( actor )
|
||||
msg_print(0,0,"direccio",true)
|
||||
local check_side = "L"
|
||||
-- definir el punts per a comprobar en el mapa
|
||||
if self.fight_modes[self.mode]=="away" then
|
||||
if actor.x>self.x then
|
||||
-- caminar cap "enrere", check costat esq
|
||||
check_side = "L"
|
||||
else
|
||||
-- caminar cap "endavant", check costat dret
|
||||
check_side = "R"
|
||||
end
|
||||
elseif self.fight_modes[self.mode]=="chase" then
|
||||
if actor.x>self.x then
|
||||
-- caminar cap "endavant", check costat dret
|
||||
check_side = "R"
|
||||
else
|
||||
-- caminar cap "enrere", check costat esq
|
||||
check_side = "L"
|
||||
end
|
||||
end
|
||||
|
||||
local step = 1
|
||||
if check_side=="L" then step = -step end
|
||||
|
||||
return step
|
||||
end
|
||||
|
||||
function imp:do_jump ( jumpfwd )
|
||||
msg_print(0,0,"do_jump",true)
|
||||
-- msg_print(0,0,"do_jump",true)
|
||||
-- Inicialització de fer el salt
|
||||
jumpfwd = jumpfwd or false
|
||||
self.jump_height = 0
|
||||
@@ -151,7 +123,7 @@ msg_print(0,0,"do_jump",true)
|
||||
end
|
||||
|
||||
function imp:state_jumping()
|
||||
msg_print(0,0,"state_jumping",true)
|
||||
-- msg_print(0,0,"state_jumping",true)
|
||||
self:reduce_cooldown()
|
||||
-- ??
|
||||
self.wait=self.wait+1
|
||||
@@ -169,10 +141,14 @@ function imp:state_jumping()
|
||||
|
||||
-- cap endavant?
|
||||
if self.jumpfwd then self:advance() end
|
||||
|
||||
self:set_fight_mode()
|
||||
self.think()
|
||||
self:controller_input()
|
||||
end
|
||||
|
||||
function imp:jump()
|
||||
msg_print(0,0,"jump",true)
|
||||
-- msg_print(0,0,"jump",true)
|
||||
local vspace = self.vmove_space
|
||||
-- Els dos punts de dalt del personatge
|
||||
local x1_check = self.x+self.bb.x
|
||||
@@ -218,7 +194,7 @@ msg_print(0,0,"jump",true)
|
||||
end
|
||||
|
||||
function imp:state_walking()
|
||||
msg_print(0,0,"state_walking",true)
|
||||
-- msg_print(0,0,"state_walking",true)
|
||||
self:reduce_cooldown()
|
||||
|
||||
-- Limitar la velocitat de moviment
|
||||
@@ -245,11 +221,14 @@ msg_print(0,0,"state_walking",true)
|
||||
end
|
||||
|
||||
self:advance()
|
||||
self:move()
|
||||
|
||||
self:set_fight_mode()
|
||||
self.think()
|
||||
self:controller_input()
|
||||
end
|
||||
|
||||
function imp:state_falling()
|
||||
msg_print(0,0,"state_falling",true)
|
||||
-- msg_print(0,0,"state_falling",true)
|
||||
self:reduce_cooldown()
|
||||
|
||||
self.frame=30
|
||||
@@ -268,10 +247,14 @@ msg_print(0,0,"state_falling",true)
|
||||
|
||||
-- Caiguent cap endavant?
|
||||
if self.jumpfwd then self:advance() end
|
||||
|
||||
self:set_fight_mode()
|
||||
self.think()
|
||||
self:controller_input()
|
||||
end
|
||||
|
||||
function imp:land ()
|
||||
msg_print(0,0,"land",true)
|
||||
-- msg_print(0,0,"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
|
||||
@@ -297,7 +280,7 @@ msg_print(0,0,"land",true)
|
||||
end
|
||||
|
||||
function imp:advance()
|
||||
msg_print(0,0,"advance",true)
|
||||
-- msg_print(0,0,"advance",true)
|
||||
local step_length=self.step_length; --lo que avança l'abad cada pas
|
||||
local limit=tiletype.block
|
||||
|
||||
@@ -327,7 +310,7 @@ end
|
||||
|
||||
-- Controlador principal del personatge
|
||||
function imp:state_normal()
|
||||
msg_print(0,0,"state_normal",true)
|
||||
-- msg_print(0,0,"state_normal",true)
|
||||
self:reduce_cooldown()
|
||||
|
||||
self.frame=28
|
||||
@@ -335,7 +318,9 @@ msg_print(0,0,"state_normal",true)
|
||||
self.step=0
|
||||
self.jumpfwd=false
|
||||
self.jump_height = 0
|
||||
self:move()
|
||||
self:set_fight_mode()
|
||||
self.think()
|
||||
self:controller_input()
|
||||
end
|
||||
|
||||
function imp:chase()
|
||||
@@ -366,13 +351,17 @@ function imp:do_flip(actor)
|
||||
if actor.x<self.x then self.flip=true else self.flip=false end
|
||||
end
|
||||
|
||||
function imp:move(abad)
|
||||
msg_print(0,0,"move",true)
|
||||
self:mode_controller()
|
||||
|
||||
self.action = self:movement(abad)
|
||||
-------------------------------
|
||||
-- imp.controller_input()
|
||||
--
|
||||
-- Traduir a una entrada de pad
|
||||
-------------------------------
|
||||
function imp:controller_input(abad)
|
||||
-- msg_print(0,0,"move",true)
|
||||
-- self.action = self:movement(abad)
|
||||
|
||||
if self.action == "right" or self.action == "left" then
|
||||
-- To Do: Si esta caiguent no se pot canviar
|
||||
self.update=imp.state_walking
|
||||
-- abad.flip=false
|
||||
elseif self.action == "jump" then
|
||||
@@ -387,7 +376,14 @@ msg_print(0,0,"move",true)
|
||||
end
|
||||
end
|
||||
|
||||
function imp:movement( actor )
|
||||
-------------------------------
|
||||
-- imp.think()
|
||||
--
|
||||
-- Cridar en cada iteració per
|
||||
-- a triar l'acció a fer i
|
||||
-- traduir a acció de pad
|
||||
-------------------------------
|
||||
function imp:think( actor )
|
||||
local action = "stay"
|
||||
|
||||
if self.mode=="stop" then return action end
|
||||
@@ -419,6 +415,8 @@ function imp:movement( actor )
|
||||
action="shot"
|
||||
end
|
||||
|
||||
self.action = action
|
||||
|
||||
return action
|
||||
end
|
||||
|
||||
@@ -430,7 +428,13 @@ function imp:reduce_cooldown()
|
||||
self.shoot_cooldown = self.shoot_cooldown -1
|
||||
end
|
||||
|
||||
function imp:mode_controller()
|
||||
-------------------------------
|
||||
-- imp.set_fight_mode()
|
||||
--
|
||||
-- Cridar en cada iteració per
|
||||
-- a canviar el mode de lluita
|
||||
-------------------------------
|
||||
function imp:set_fight_mode()
|
||||
if self.mode=="stop" then return end
|
||||
|
||||
if self.mode_cooldown <= 0 then
|
||||
@@ -452,13 +456,6 @@ function imp:mode_controller()
|
||||
self:do_flip(abad)
|
||||
-- self:movement(abad)
|
||||
|
||||
-- comprovar colisio en l'abad
|
||||
if viewp:inside(self.x, self.y, self.w, self.h) then
|
||||
if collision(abad,self) then
|
||||
abad_hurt(1)
|
||||
end
|
||||
end
|
||||
|
||||
--if imp.wait==6 then
|
||||
-- imp.wait=0
|
||||
-- if not imp.enabled then
|
||||
@@ -497,3 +494,39 @@ function imp:mode_controller()
|
||||
--end
|
||||
end
|
||||
|
||||
function imp:collision()
|
||||
-- comprovar colisio en l'abad
|
||||
if viewp:inside(self.x, self.y, self.w, self.h) then
|
||||
if collision(abad,self) then
|
||||
abad_hurt(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- function imp:direccio( actor )
|
||||
-- -- msg_print(0,0,"direccio",true)
|
||||
-- local check_side = "L"
|
||||
-- -- definir el punts per a comprobar en el mapa
|
||||
-- if self.fight_modes[self.mode]=="away" then
|
||||
-- if actor.x>self.x then
|
||||
-- -- caminar cap "enrere", check costat esq
|
||||
-- check_side = "L"
|
||||
-- else
|
||||
-- -- caminar cap "endavant", check costat dret
|
||||
-- check_side = "R"
|
||||
-- end
|
||||
-- elseif self.fight_modes[self.mode]=="chase" then
|
||||
-- if actor.x>self.x then
|
||||
-- -- caminar cap "endavant", check costat dret
|
||||
-- check_side = "R"
|
||||
-- else
|
||||
-- -- caminar cap "enrere", check costat esq
|
||||
-- check_side = "L"
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- local step = 1
|
||||
-- if check_side=="L" then step = -step end
|
||||
--
|
||||
-- return step
|
||||
-- end
|
||||
Reference in New Issue
Block a user