[WIP] Treballant en el jefe. Per fi! Ja comença a funcionar de nou
This commit is contained in:
@@ -133,7 +133,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function abad_hurt(howmuch)
|
function abad_hurt(howmuch)
|
||||||
-- howmuch = 0
|
howmuch = 0
|
||||||
if abad.hurting == 0 and abad.respawning==0 then
|
if abad.hurting == 0 and abad.respawning==0 then
|
||||||
sound.play(audio_abad_hit)
|
sound.play(audio_abad_hit)
|
||||||
abad.energia=abad.energia-howmuch
|
abad.energia=abad.energia-howmuch
|
||||||
|
|||||||
@@ -257,8 +257,8 @@ function update_game()
|
|||||||
|
|
||||||
score.draw()
|
score.draw()
|
||||||
|
|
||||||
if DEBUG then
|
|
||||||
special_keys()
|
special_keys()
|
||||||
|
if DEBUG then
|
||||||
debug_info()
|
debug_info()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -334,7 +334,55 @@ function update_pause()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function print_analisis_field ( field )
|
||||||
|
local field_state=" "
|
||||||
|
if boss.analisis[field] then field_state="X" end
|
||||||
|
print(" [ "..field_state.." ] "..field)
|
||||||
|
end
|
||||||
|
|
||||||
|
function print_analisis()
|
||||||
|
print("--------------------------------------------")
|
||||||
|
print_analisis_field("can_chase_abad")
|
||||||
|
print_analisis_field("can_climb")
|
||||||
|
print_analisis_field("can_shot")
|
||||||
|
print_analisis_field("can_super")
|
||||||
|
print_analisis_field("can_go_altar")
|
||||||
|
print_analisis_field("falling")
|
||||||
|
print_analisis_field("going_to_fall")
|
||||||
|
print_analisis_field("target_reached")
|
||||||
|
print("X= "..boss.x..", OX= "..boss.x_old)
|
||||||
|
print(" ")
|
||||||
|
end
|
||||||
|
|
||||||
function special_keys()
|
function special_keys()
|
||||||
|
if key.press(key.A) then
|
||||||
|
boss.x_old = boss.x
|
||||||
|
boss.x = boss.x-1
|
||||||
|
print_analisis()
|
||||||
|
end
|
||||||
|
if key.press(key.S) then
|
||||||
|
boss.y_old = boss.y
|
||||||
|
boss.y = boss.y+1
|
||||||
|
print_analisis()
|
||||||
|
end
|
||||||
|
if key.press(key.D) then
|
||||||
|
boss.x_old = boss.x
|
||||||
|
boss.x = boss.x+1
|
||||||
|
print_analisis()
|
||||||
|
end
|
||||||
|
if key.press(key.W) then
|
||||||
|
boss.y_old = boss.y
|
||||||
|
boss.y = boss.y-1
|
||||||
|
print_analisis()
|
||||||
|
end
|
||||||
|
if key.press(key.W) then
|
||||||
|
boss.y_old = boss.y
|
||||||
|
boss.y = boss.y-1
|
||||||
|
print_analisis()
|
||||||
|
end
|
||||||
|
if key.press(key.F) then
|
||||||
|
boss._pause = not boss._pause
|
||||||
|
end
|
||||||
if key.press(key.N1) then
|
if key.press(key.N1) then
|
||||||
-- -- abad prev room
|
-- -- abad prev room
|
||||||
-- local hab = abad.hab-1
|
-- local hab = abad.hab-1
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ function in_table(tabla, valor)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function table_key (tabla, valor)
|
||||||
|
for k, v in pairs(tabla) do
|
||||||
|
if v==valor then return k end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
function collision(a, b)
|
function collision(a, b)
|
||||||
return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x)
|
return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x)
|
||||||
and (a.x+a.bb.x <= b.x+b.bb.x+b.bb.w)
|
and (a.x+a.bb.x <= b.x+b.bb.x+b.bb.w)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
function imp:_moure( foo, name )
|
function imp:_moure( foo, name )
|
||||||
name = name or "anonymous"
|
-- name = name or "anonymous"
|
||||||
if not foo then
|
-- if not foo then
|
||||||
print_dbg(name.." not found")
|
-- print_dbg(name.." not found")
|
||||||
else
|
-- else
|
||||||
print_dbg(name)
|
-- print_dbg(name)
|
||||||
end
|
-- end
|
||||||
self.moure = foo
|
self.moure = foo
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -24,6 +24,23 @@ if DEBUG_FN_NAME then print_dbg("reduce_timers") end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------
|
||||||
|
--
|
||||||
|
-------------------------------
|
||||||
|
function imp:reset_timer( timer )
|
||||||
|
if self.mood == self.moods.stop then return end
|
||||||
|
if DEBUG_FN_NAME then print_dbg("reduce_timers") end
|
||||||
|
local time = 0
|
||||||
|
if timer=="mood" then time = 150
|
||||||
|
elseif timer=="target" then time = 250
|
||||||
|
elseif timer=="shot" then time = 100
|
||||||
|
elseif timer=="super" then time = 200
|
||||||
|
elseif timer=="flip_wait" then time = 50
|
||||||
|
end
|
||||||
|
|
||||||
|
if time > 0 then self.timers[timer] = time end
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------
|
-------------------------------
|
||||||
--
|
--
|
||||||
-------------------------------
|
-------------------------------
|
||||||
@@ -32,7 +49,7 @@ function imp:analyze_env() --OK
|
|||||||
if DEBUG_FN_NAME then print_dbg("analyze_env") end
|
if DEBUG_FN_NAME then print_dbg("analyze_env") end
|
||||||
-- Distancia fins a l'abad
|
-- Distancia fins a l'abad
|
||||||
local r = distancia(self,abad)
|
local r = distancia(self,abad)
|
||||||
-- msg_print(10,20,r,true)
|
|
||||||
self.analisis.can_chase_abad = false
|
self.analisis.can_chase_abad = false
|
||||||
if r<=100 then
|
if r<=100 then
|
||||||
self.analisis.can_chase_abad=true
|
self.analisis.can_chase_abad=true
|
||||||
@@ -60,23 +77,47 @@ if DEBUG_FN_NAME then print_dbg("analyze_env") end
|
|||||||
-- Acces a la zona central (només si el super està preparat)
|
-- Acces a la zona central (només si el super està preparat)
|
||||||
x1_check = self.x+self.bb.x
|
x1_check = self.x+self.bb.x
|
||||||
x2_check = self.x+self.bb.x+self.bb.w
|
x2_check = self.x+self.bb.x+self.bb.w
|
||||||
y_check = self.y+self.bb.h
|
y_check = self.y+self.bb.h+8
|
||||||
self.analisis.can_go_altar = false
|
self.analisis.can_go_altar = false
|
||||||
local hab1, tx1, ty1 = coords.world_to_tile(x1_check, y_check)
|
hab1, tx1, ty1 = coords.world_to_tile(x1_check, y_check)
|
||||||
local hab2, tx2, ty2 = coords.world_to_tile(x2_check, y_check)
|
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)
|
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
|
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
|
if self.analisis.can_super then self.analisis.can_go_altar = true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Caiguent
|
||||||
|
self.analisis.falling = false
|
||||||
|
local tile_type1, tile_code1= arc_check_tile(x1_check,y_check)
|
||||||
|
local tile_type2, tile_code2= arc_check_tile(x2_check,y_check)
|
||||||
|
if tile_type1==tiletype.void and tile_type2==tiletype.void then
|
||||||
|
self.analisis.falling = true
|
||||||
|
end
|
||||||
|
|
||||||
-- Cau al següent moviment?
|
-- Cau al següent moviment?
|
||||||
self.analisis.going_to_fall = false
|
self.analisis.going_to_fall = false
|
||||||
local step_length = self.step_length
|
if not self.analisis.falling then
|
||||||
if self.movement==self.actions.left then step_length = -step_length end
|
local step_length = self.step_length
|
||||||
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)
|
-- default movent-se cap a la dreta
|
||||||
if tile_type1==tiletype.void and tile_type2==tiletype.void then
|
x1_check = self.x+self.bb.x+(self.bb.w/2)
|
||||||
self.analisis.going_to_fall = true
|
x2_check = self.x+self.bb.x+self.bb.w
|
||||||
|
if self.x_old>self.x then
|
||||||
|
-- movent-se cap a l'esquerra
|
||||||
|
step_length = -step_length
|
||||||
|
x1_check = self.x+self.bb.x
|
||||||
|
x2_check = x1_check+(self.bb.w/2)
|
||||||
|
elseif self.x_old==self.x then
|
||||||
|
-- quet
|
||||||
|
step_length = 0
|
||||||
|
x1_check = self.x+self.bb.x
|
||||||
|
x2_check = self.x+self.bb.x+self.bb.w
|
||||||
|
end
|
||||||
|
local tile_type1, tile_code1= arc_check_tile(x1_check+step_length,y_check)
|
||||||
|
local tile_type2, tile_code2= arc_check_tile(x2_check+step_length,y_check)
|
||||||
|
if tile_type1==tiletype.void and tile_type2==tiletype.void then
|
||||||
|
self.analisis.going_to_fall = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ha arribat a destí
|
-- Ha arribat a destí
|
||||||
@@ -84,42 +125,67 @@ if DEBUG_FN_NAME then print_dbg("analyze_env") end
|
|||||||
if not empty_table(self.pattern:target_node()) then
|
if not empty_table(self.pattern:target_node()) then
|
||||||
-- Target reached
|
-- Target reached
|
||||||
if self.pattern:in_target(self) then self.analisis.target_reached=true end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function imp:update_action_events()
|
||||||
|
if self.analisis.going_to_fall then
|
||||||
|
self:add_action_event("prefall")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.analisis.falling then
|
||||||
|
self:add_action_event("falling")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.analisis.target_reached then
|
||||||
|
self:add_action_event("target")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.analisis.can_go_altar then
|
||||||
|
self:add_action_event("super_init")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.x_old>self.x then
|
||||||
|
self:add_action_event("left")
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.x_old<self.x then
|
||||||
|
self:add_action_event("right")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function imp:check_action_event ( event )
|
||||||
|
for _, v in ipairs(self.action_event) do
|
||||||
|
-- print_dbg(v)
|
||||||
|
if v == event then return true end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function imp:add_action_event ( event )
|
||||||
|
table.insert(self.action_event, event)
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------
|
-------------------------------
|
||||||
--
|
--
|
||||||
-------------------------------
|
-------------------------------
|
||||||
function imp:choose_action() -- antic imp:move
|
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.." / "..self.moods.stop) end
|
||||||
if DEBUG_FN_NAME then print_dbg("choose_action "..self.mood) end
|
-- if self.mood==self.moods.stop then return self.mood end
|
||||||
|
|
||||||
local next_action = self.actions.no_action
|
|
||||||
|
|
||||||
-- Si no te ganes de fer res, no moure
|
-- Si no te ganes de fer res, no moure
|
||||||
if self.mood==self.moods.stop then return self.actions.no_action end
|
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
|
local next_action = self:next_action()
|
||||||
-- 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
|
if self.analisis.target_reached and next_action=="super" then
|
||||||
-- print("Super READY!")
|
self.add_action_event("super ready")
|
||||||
table.insert(self.action_event, "super_ready")
|
|
||||||
-- next_action = self:next_action()
|
-- next_action = self:next_action()
|
||||||
self:super()
|
self:super()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.old_action~=next_action then
|
if self.old_action~=next_action then
|
||||||
self.old_action=next_action
|
self.old_action=next_action
|
||||||
-- print(self.old_action)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.action = next_action
|
self.action = next_action
|
||||||
|
|
||||||
return next_action
|
return next_action
|
||||||
@@ -132,28 +198,46 @@ end
|
|||||||
-------------------------------
|
-------------------------------
|
||||||
function imp:controller_input()
|
function imp:controller_input()
|
||||||
if DEBUG_FN_NAME then print_dbg("controller_input") end
|
if DEBUG_FN_NAME then print_dbg("controller_input") end
|
||||||
|
-- for k,v in pairs(self.actions) do
|
||||||
|
-- if v==self.action then print("CONTROLLER => "..self.action.." / "..k) end
|
||||||
|
-- end
|
||||||
|
|
||||||
--To Do: JumpFWD
|
if (self.action == self.actions.right or
|
||||||
if (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
self.action == self.actions.left) then
|
||||||
self.moure~=imp.state_super) and
|
if self.moure == imp.state_normal or self.moure == imp.state_walking then
|
||||||
(self.action == self.actions.right or self.action == self.actions.left) then
|
self:_moure(imp.state_walking, "")
|
||||||
self.movement = self.action
|
end
|
||||||
-- self.moure=imp.state_walking
|
elseif (self.action == self.actions.jump) then
|
||||||
self:_moure(imp.state_walking, "state_walking (movement)")
|
if self.moure == imp.state_normal or self.moure == imp.state_walking then
|
||||||
elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
self:jump()
|
||||||
self.moure~=imp.state_super) and self.action == self.actions.jump then
|
end
|
||||||
self:do_jump()
|
elseif (self.action == self.actions.jumpfwd) then
|
||||||
elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
if self.moure == imp.state_normal or self.moure == imp.state_walking then
|
||||||
self.moure~=imp.state_super) and self.action == self.actions.jumpfwd then
|
self:jump(true)
|
||||||
self:do_jump(true)
|
end
|
||||||
elseif self.action == self.actions.shot then
|
elseif (self.action == self.actions.shot) then
|
||||||
self:shot()
|
self:shot()
|
||||||
elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
|
elseif (self.action == self.actions.super) then
|
||||||
self.moure~=imp.state_super) and self.action == self.actions.super then
|
|
||||||
self.moure=imp.state_super
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if --(self.moure==imp.state_normal or self.moure==imp.state_walking) and
|
||||||
|
-- (self.action == self.actions.right or self.action == self.actions.left) then
|
||||||
|
-- -- 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:jump()
|
||||||
|
-- elseif (self.moure==imp.state_normal or self.moure==imp.state_walking) and self.action == self.actions.jumpfwd then
|
||||||
|
-- self: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.old_action = self.action
|
||||||
self.action = self.actions.no_action
|
self.action = self.actions.no_action
|
||||||
self.action_event = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------
|
-------------------------------
|
||||||
@@ -171,6 +255,28 @@ if DEBUG_FN_NAME then print_dbg("fight") end
|
|||||||
|
|
||||||
self.mood=self.moods.chase
|
self.mood=self.moods.chase
|
||||||
self:pattern_movement()
|
self:pattern_movement()
|
||||||
|
self:_moure(imp.state_normal,"")
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------
|
||||||
|
--
|
||||||
|
-------------------------------
|
||||||
|
function imp:shot(actor)
|
||||||
|
if DEBUG_FN_NAME then print("shot") end
|
||||||
|
self:do_flip(abad)
|
||||||
|
-- print_dbg("FIREBALL!!")
|
||||||
|
|
||||||
|
local flip = false
|
||||||
|
local x_ini = self.x+self.bb.x+self.bb.w+4
|
||||||
|
if self.x>abad.x then
|
||||||
|
flip=true
|
||||||
|
x_ini = self.x-4
|
||||||
|
end
|
||||||
|
local hab, tx, ty, off_x, off_y = coords.world_to_tile(x_ini,self.y+(self.h/4))
|
||||||
|
fireball.init(hab, tx, ty, flip, off_x, off_y)
|
||||||
|
sound.play(audio_hit)
|
||||||
|
|
||||||
|
self:reset_timer("shot")
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------
|
-------------------------------
|
||||||
@@ -180,9 +286,9 @@ function imp:create_hot_points() --OK
|
|||||||
self.pattern.node[1] = point.new(44, 6, 3, 0, 0,"P1")
|
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[2] = point.new(45, 7, 3, 0, 0,"P2")
|
||||||
self.pattern.node[3] = point.new(44,12, 5, 8, 0,"P3")
|
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[4] = point.new(54, 5, 4, 0, 0,"P4")
|
||||||
self.pattern.node[5] = point.new(54,12, 4, 8, 0,"P5")
|
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[6] = point.new(55, 8, 4, 0, 0,"P6")
|
||||||
self.pattern.node[7] = point.new(55, 8, 0, 0, 0,"P7")
|
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[8] = point.new(54, 5, 0, 0, 0,"P8")
|
||||||
self.pattern.node[9] = point.new(54, 9, 1, 0, 0,"P9")
|
self.pattern.node[9] = point.new(54, 9, 1, 0, 0,"P9")
|
||||||
@@ -200,7 +306,8 @@ function imp:load_pattern_paths() --OK
|
|||||||
{target=3, actions= {{action="right" , event="prefall"},
|
{target=3, actions= {{action="right" , event="prefall"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="jumpfwd", event="land"},
|
||||||
{action="right" , event="target"}}},
|
{action="right" , event="target"}}},
|
||||||
{target=4, actions= {{action="right" , event="land"},
|
{target=4, actions= {{action="" , event="land"},
|
||||||
|
{action="right" , event="land"},
|
||||||
{action="left" , event="target"}}},
|
{action="left" , event="target"}}},
|
||||||
{target=4, actions= {{action="right" , event="prefall"},
|
{target=4, actions= {{action="right" , event="prefall"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="jumpfwd", event="land"},
|
||||||
@@ -221,11 +328,21 @@ function imp:load_pattern_paths() --OK
|
|||||||
{target=3, actions= {{action="left" , event="prefall"},
|
{target=3, actions= {{action="left" , event="prefall"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="jumpfwd", event="land"},
|
||||||
{action="left" , event="target"}}},
|
{action="left" , event="target"}}},
|
||||||
{target=6, actions= {{action="left" , event="land"},
|
{target=6, actions= {{action="" , event="land"},
|
||||||
|
{action="left" , event="land"},
|
||||||
{action="right" , event="target"}}},
|
{action="right" , event="target"}}},
|
||||||
{target=6, actions= {{action="left" , event="prefall"},
|
{target=6, actions= {{action="left" , event="prefall"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="jumpfwd", event="land"},
|
||||||
{action="right" , event="target"}}},
|
{action="right" , event="target"}}},
|
||||||
|
{target=6, actions= {{action="left" , event="prefall"},
|
||||||
|
{action="jumpfwd", event="land"},
|
||||||
|
{action="left" , event="land"},
|
||||||
|
{action="right" , event="target"}}},
|
||||||
|
{target=6, actions= {{action="left" , event="prefall"},
|
||||||
|
{action="jumpfwd", event="land"},
|
||||||
|
{action="right" , event="land"},
|
||||||
|
{action="left" , event="land"},
|
||||||
|
{action="right" , event="target"}}},
|
||||||
{target=9, actions= {{action="left" , event="prefall"},
|
{target=9, actions= {{action="left" , event="prefall"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="jumpfwd", event="land"},
|
||||||
{action="left" , event="target"}}},
|
{action="left" , event="target"}}},
|
||||||
@@ -276,21 +393,30 @@ function imp:load_pattern_paths() --OK
|
|||||||
{target=5, actions={{action="left" , event="prefall"},
|
{target=5, actions={{action="left" , event="prefall"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="jumpfwd", event="land"},
|
||||||
{action="left" , event="target"}}},
|
{action="left" , event="target"}}},
|
||||||
{target=10,actions={{action="left" , event="prefall"},
|
{target=10,actions={{action="" , event="land"},
|
||||||
{action="jumpfwd", event="land"},
|
{action="left" , event="land"},
|
||||||
{action="left" , event="target"}}},
|
{action="left" , event="prefall"},
|
||||||
{target=2, actions={{action="jump" , event="target"}}}
|
{action="jumpfwd", event="land"},
|
||||||
|
{action="left" , event="target"}}},
|
||||||
|
{target=2, actions={{action="jump" , event="target"}}},
|
||||||
|
{target=6, actions={{action="" , event="land"},
|
||||||
|
{action="left" , event="land"},
|
||||||
|
{action="left" , event="land"},
|
||||||
|
{action="right", event="target"}}},
|
||||||
|
|
||||||
}
|
}
|
||||||
self.pattern.path[8] = {
|
self.pattern.path[8] = {
|
||||||
{target=5, actions={{action="right" , event="prefall"},
|
{target=5, actions={{action="right" , event="prefall"},
|
||||||
{action="jumpfwd" , event="land"},
|
{action="jumpfwd" , event="land"},
|
||||||
{action="right" , event="target"}}},
|
{action="right" , event="target"}}},
|
||||||
{target=9, actions={{action="right" , event="land"},
|
{target=9, actions={{action="" , event="land"},
|
||||||
|
{action="right" , event="land"},
|
||||||
{action="jumpfwd" , event="land"},
|
{action="jumpfwd" , event="land"},
|
||||||
{action="right" , event="target"}}},
|
{action="right" , event="target"}}},
|
||||||
{target=1, actions={{action="jump" , event="target"}}}
|
{target=1, actions={{action="jump" , event="target"}}}
|
||||||
}
|
}
|
||||||
self.pattern.path[9] = {
|
self.pattern.path[9] = {
|
||||||
|
{target=6, actions={{action="right" , event="target"}}},
|
||||||
{target=5, actions={{action="right" , event="target"}}},
|
{target=5, actions={{action="right" , event="target"}}},
|
||||||
{target=1, actions={{action="left" , event="prefall"},
|
{target=1, actions={{action="left" , event="prefall"},
|
||||||
{action="jumpfwd" , event="land"},
|
{action="jumpfwd" , event="land"},
|
||||||
@@ -301,10 +427,12 @@ function imp:load_pattern_paths() --OK
|
|||||||
self.pattern.path[10] = {
|
self.pattern.path[10] = {
|
||||||
{target=5, actions={{action="left" , event="target"}}},
|
{target=5, actions={{action="left" , event="target"}}},
|
||||||
{target=2, actions={{action="right" , event="prefall"},
|
{target=2, actions={{action="right" , event="prefall"},
|
||||||
{action="jumpfwd" , event="land"},
|
{action="jumpfwd" , event="land"},
|
||||||
{action="right" , event="prefall"},
|
{action="right" , event="prefall"},
|
||||||
{action="jump" , event="target"}}},
|
{action="jump" , event="target"}}},
|
||||||
{target=6, actions={{action="right" , event="target"}}}
|
{target=6, actions={{action="right" , event="target"}}},
|
||||||
|
{target=6, actions={{action="left" , event="land"},
|
||||||
|
{action="right" , event = "target"}}}
|
||||||
}
|
}
|
||||||
self.pattern.path[11] = {
|
self.pattern.path[11] = {
|
||||||
{target=4, actions={{action="left", event="target"}}}
|
{target=4, actions={{action="left", event="target"}}}
|
||||||
@@ -330,10 +458,8 @@ function imp:next_action()
|
|||||||
local next_action = self.actions.no_action
|
local next_action = self.actions.no_action
|
||||||
|
|
||||||
-- Si el blanc està a tir disparar
|
-- Si el blanc està a tir disparar
|
||||||
if self.timers.shot<=0 then
|
if self.timers.shot<=0 and h_collision(self, self.shot_target) then
|
||||||
if h_collision(self, self.shot_target) then
|
next_action = "shot"
|
||||||
next_action = self.actions.shot
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Resta d'accions
|
-- Resta d'accions
|
||||||
@@ -343,40 +469,43 @@ function imp:next_action()
|
|||||||
-- next_action = self:free_next_action()
|
-- next_action = self:free_next_action()
|
||||||
elseif self.move_type==self.move_types.pattern then
|
elseif self.move_type==self.move_types.pattern then
|
||||||
-- PATTERN
|
-- PATTERN
|
||||||
local in_target = self.pattern:in_target(self)
|
local action_event_done = self:check_action_event(self.pattern:event())
|
||||||
local action_event_done = in_table(self.action_event, self.pattern:event())
|
-- local str_aev = ""
|
||||||
if in_target or action_event_done then
|
-- for k,v in pairs(self.action_event) do str_aev=str_aev..", "..v end
|
||||||
|
if action_event_done then
|
||||||
next_action=self.pattern:next_action()
|
next_action=self.pattern:next_action()
|
||||||
print("TARGET => "..next_action)
|
-- print_dbg("NEXT ACTION "..next_action)
|
||||||
else
|
else
|
||||||
next_action=self.pattern:action()
|
next_action=self.pattern:action()
|
||||||
print("ON WAY => "..next_action)
|
-- print_dbg("HOLD ACTION "..next_action)
|
||||||
end
|
end
|
||||||
elseif self.move_type==self.move_types.super then
|
elseif self.move_type==self.move_types.super then
|
||||||
-- SUPER
|
-- SUPER
|
||||||
--
|
--
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.action_event = {}
|
||||||
|
|
||||||
-- next_action es text, traduir
|
-- next_action es text, traduir
|
||||||
return self.actions[next_action]
|
return self.actions[next_action]
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:do_jump ( jumpfwd )
|
function imp:jump ( jumpfwd )
|
||||||
if DEBUG_FN_NAME then print_dbg("") end
|
if DEBUG_FN_NAME then print_dbg("") end
|
||||||
-- Inicialització de fer el salt
|
-- Inicialització de fer el salt
|
||||||
jumpfwd = jumpfwd or false
|
jumpfwd = jumpfwd or false
|
||||||
self.jump_height = 0
|
self.jump_height = 0
|
||||||
-- self.moure=imp.state_jumping
|
-- self.moure=imp.state_jumping
|
||||||
self:_moure(imp.state_jumping,"state_jumping (states)")
|
|
||||||
self.step=0
|
self.step=0
|
||||||
self.jumpfwd=jumpfwd
|
self.jumpfwd=jumpfwd
|
||||||
self.action=""
|
self:_moure(imp.state_jumping,"")
|
||||||
|
-- self.action=""
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:state_jumping()
|
function imp:state_jumping()
|
||||||
if self.mood==self.moods.stop then return self.mood end
|
if self.mood==self.moods.stop then return self.mood end
|
||||||
if DEBUG_FN_NAME then print_dbg("state_jumping") end
|
if DEBUG_FN_NAME then print_dbg("state_jumping") end
|
||||||
|
-- print_dbg(">>>>>>>>>> state_jumping")
|
||||||
-- ??
|
-- ??
|
||||||
self.wait=self.wait+1
|
self.wait=self.wait+1
|
||||||
self.wait=0
|
self.wait=0
|
||||||
@@ -384,7 +513,7 @@ if DEBUG_FN_NAME then print_dbg("state_jumping") end
|
|||||||
-- Pujar o caure
|
-- Pujar o caure
|
||||||
if self.jump_height<self.max_jump_height then
|
if self.jump_height<self.max_jump_height then
|
||||||
-- Comprovar que pasa en l'aire
|
-- Comprovar que pasa en l'aire
|
||||||
self:jump()
|
self:do_jump()
|
||||||
else
|
else
|
||||||
-- Canviar a mode caure
|
-- Canviar a mode caure
|
||||||
-- self.moure=imp.state_falling
|
-- self.moure=imp.state_falling
|
||||||
@@ -396,7 +525,7 @@ if DEBUG_FN_NAME then print_dbg("state_jumping") end
|
|||||||
if self.jumpfwd then self:advance() end
|
if self.jumpfwd then self:advance() end
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:jump()
|
function imp:do_jump()
|
||||||
if DEBUG_FN_NAME then print_dbg("jump") end
|
if DEBUG_FN_NAME then print_dbg("jump") end
|
||||||
|
|
||||||
local vspace = self.vmove_space
|
local vspace = self.vmove_space
|
||||||
@@ -413,6 +542,7 @@ if DEBUG_FN_NAME then print_dbg("jump") end
|
|||||||
-- Fer l'acció que correspon
|
-- Fer l'acció que correspon
|
||||||
if not_block_tile then
|
if not_block_tile then
|
||||||
-- Ascendir
|
-- Ascendir
|
||||||
|
self.old_y = self.y
|
||||||
self.y=self.y-vspace
|
self.y=self.y-vspace
|
||||||
else
|
else
|
||||||
-- Si es un bloc permetre gastar l'espai no pintat
|
-- Si es un bloc permetre gastar l'espai no pintat
|
||||||
@@ -432,6 +562,7 @@ if DEBUG_FN_NAME then print_dbg("jump") end
|
|||||||
self.jump_in_half_block = arcade_config.tiles_height / 2
|
self.jump_in_half_block = arcade_config.tiles_height / 2
|
||||||
end
|
end
|
||||||
if self.jump_in_half_block>0 then
|
if self.jump_in_half_block>0 then
|
||||||
|
self.old_y = self.y
|
||||||
self.y=self.y-vspace
|
self.y=self.y-vspace
|
||||||
self.jump_in_half_block = self.jump_in_half_block-1
|
self.jump_in_half_block = self.jump_in_half_block-1
|
||||||
self.jump_in_half_block_used = true
|
self.jump_in_half_block_used = true
|
||||||
@@ -440,57 +571,67 @@ if DEBUG_FN_NAME then print_dbg("jump") end
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Registrar el desplaçament
|
-- Registrar el desplaçament
|
||||||
self.jump_height = self.jump_height+1
|
self.jump_height = self.jump_height+vspace
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:advance()
|
function imp:advance()
|
||||||
if DEBUG_FN_NAME then print_dbg("advance") end
|
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
|
local limit=tiletype.block
|
||||||
|
|
||||||
if self.moure~=imp.state_walking then limit=tiletype.half end
|
if self.moure~=imp.state_walking then limit=tiletype.half end
|
||||||
|
|
||||||
local x_check = self.x+self.bb.x+self.bb.w+step_length
|
local step_length=self.step_length; --lo que avança el imp cada pas
|
||||||
-- if self.flip then
|
local x_check = 0
|
||||||
-- step_length = -step_length
|
local y_check = self.y+self.bb.h-1
|
||||||
-- x_check = self.x+self.bb.x+step_length
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- self.action=="right"
|
if (self.old_action == self.actions.right or
|
||||||
-- if self.action=="left" then
|
self.old_action == self.actions.left) then
|
||||||
-- print("ADVANCE => "..self.movement)
|
-- orientació des de control
|
||||||
if self.movement==self.actions.left then
|
if self.old_action == self.actions.left then
|
||||||
step_length = -step_length
|
step_length = -step_length
|
||||||
x_check = self.x+self.bb.x+step_length
|
x_check = self.x+self.bb.x
|
||||||
|
else
|
||||||
|
x_check = self.x+self.bb.x+self.bb.w
|
||||||
|
end
|
||||||
|
x_check = x_check + step_length
|
||||||
|
else
|
||||||
|
-- detectar orientacio des del movimentl
|
||||||
|
if self.x_old>self.x then
|
||||||
|
step_length = -step_length
|
||||||
|
x_check = self.x+self.bb.x
|
||||||
|
else
|
||||||
|
x_check = self.x+self.bb.x+self.bb.w
|
||||||
|
end
|
||||||
|
|
||||||
|
x_check = x_check + step_length
|
||||||
end
|
end
|
||||||
|
|
||||||
local y_check = self.y+self.bb.h-4
|
|
||||||
|
|
||||||
if arc_check_tile(x_check, y_check)<limit then
|
if arc_check_tile(x_check, y_check)<limit then
|
||||||
|
self.x_old = self.x
|
||||||
self.x=self.x+step_length
|
self.x=self.x+step_length
|
||||||
end
|
end
|
||||||
|
|
||||||
local hab,xx, yy = coords.world_to_tile(self.x, self.y)
|
local hab,xx, yy = coords.world_to_tile(self.x, self.y)
|
||||||
self.hab = hab
|
self.hab = hab
|
||||||
-- self.movement = ""
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:state_falling()
|
function imp:state_falling()
|
||||||
if DEBUG_FN_NAME then print_dbg("state_falling") end
|
if DEBUG_FN_NAME then print_dbg("state_falling") end
|
||||||
-- msg_print(16,16,"state_falling",true)
|
-- print_dbg(">>>>>>>>>> state_falling")
|
||||||
|
-- self.frame=30
|
||||||
self.frame=30
|
|
||||||
self.wait=self.wait+1
|
self.wait=self.wait+1
|
||||||
self.next_frame=imp.falling_next_frame
|
self.next_frame=imp.falling_next_frame
|
||||||
-- Si toca terra canviar el mode
|
-- Si toca terra canviar el mode
|
||||||
if self:land() then
|
if self:land() then
|
||||||
-- self.moure=imp.state_normal
|
-- self.moure=imp.state_normal
|
||||||
self:_moure(imp.state_normal,"state_normal (states)")
|
self:_moure(imp.state_normal,"state_normal (states)")
|
||||||
|
self.jumpfwd = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- print_dbg("FALLING!")
|
|
||||||
-- Seguir caiguent
|
-- Seguir caiguent
|
||||||
|
self.old_y = self.y
|
||||||
self.y=self.y+1
|
self.y=self.y+1
|
||||||
self.jump_height = self.jump_height-1
|
self.jump_height = self.jump_height-1
|
||||||
self.falling=self.falling+1
|
self.falling=self.falling+1
|
||||||
@@ -501,7 +642,6 @@ end
|
|||||||
|
|
||||||
function imp:land ()
|
function imp:land ()
|
||||||
if DEBUG_FN_NAME then print_dbg("land") end
|
if DEBUG_FN_NAME then print_dbg("land") end
|
||||||
-- msg_print(16,32,"land",true)
|
|
||||||
-- Els dos punts de baix de l'abad
|
-- Els dos punts de baix de l'abad
|
||||||
local x1_check = self.x+self.bb.x
|
local x1_check = self.x+self.bb.x
|
||||||
local x2_check = self.x+self.bb.x+self.bb.w
|
local x2_check = self.x+self.bb.x+self.bb.w
|
||||||
@@ -521,7 +661,7 @@ if DEBUG_FN_NAME then print_dbg("land") end
|
|||||||
if can_land then
|
if can_land then
|
||||||
self.jump_in_half_block_used = false
|
self.jump_in_half_block_used = false
|
||||||
self.jump_height = 0
|
self.jump_height = 0
|
||||||
table.insert(self.action_event, "land")
|
self:add_action_event("land")
|
||||||
end
|
end
|
||||||
-- if can_land then print_dbg ("LANDED") end
|
-- if can_land then print_dbg ("LANDED") end
|
||||||
return can_land
|
return can_land
|
||||||
@@ -529,8 +669,8 @@ end
|
|||||||
|
|
||||||
function imp:state_walking()
|
function imp:state_walking()
|
||||||
if self.mood==self.moods.stop then return end
|
if self.mood==self.moods.stop then return end
|
||||||
if not DEBUG_FN_NAME then print("state_walking") end
|
if DEBUG_FN_NAME then print("state_walking") end
|
||||||
-- msg_print(16,48,"state_walking",true)
|
-- print_dbg(">>>>>>>>>> state_walking")
|
||||||
|
|
||||||
-- Limitar la velocitat de moviment
|
-- Limitar la velocitat de moviment
|
||||||
self.wait=self.wait+1
|
self.wait=self.wait+1
|
||||||
@@ -546,7 +686,7 @@ if not DEBUG_FN_NAME then print("state_walking") end
|
|||||||
local tile2 = arc_check_tile(x2_check,y_check)
|
local tile2 = arc_check_tile(x2_check,y_check)
|
||||||
if tile1==tiletype.void and tile2==tiletype.void then
|
if tile1==tiletype.void and tile2==tiletype.void then
|
||||||
-- si no hi ha piso, caure
|
-- si no hi ha piso, caure
|
||||||
self.moure=imp.state_falling
|
-- self.moure=imp.state_falling
|
||||||
self:_moure(imp.state_falling, "state_falling (states-walking)")
|
self:_moure(imp.state_falling, "state_falling (states-walking)")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -556,6 +696,7 @@ end
|
|||||||
|
|
||||||
function imp:state_normal()
|
function imp:state_normal()
|
||||||
if DEBUG_FN_NAME then print_dbg("state_normal") end
|
if DEBUG_FN_NAME then print_dbg("state_normal") end
|
||||||
|
-- print_dbg(">>>>>>>>>> state_normal")
|
||||||
self.frame=28
|
self.frame=28
|
||||||
self.wait=0
|
self.wait=0
|
||||||
self.step=0
|
self.step=0
|
||||||
@@ -567,7 +708,7 @@ end
|
|||||||
-- imp.next_frame()
|
-- imp.next_frame()
|
||||||
function imp:walking_next_frame()
|
function imp:walking_next_frame()
|
||||||
-- Selecció de frame
|
-- Selecció de frame
|
||||||
if self.wait==6 then
|
if self.wait>=6 then
|
||||||
self.wait=0
|
self.wait=0
|
||||||
self.step=(self.step+1)%4
|
self.step=(self.step+1)%4
|
||||||
self.frame=self.anim[self.step+1]
|
self.frame=self.anim[self.step+1]
|
||||||
|
|||||||
@@ -5,6 +5,13 @@ function print_dbg(...)
|
|||||||
print("[" .. nombre .. "]", ...)
|
print("[" .. nombre .. "]", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
hab1 = 1
|
||||||
|
tx1 = 1
|
||||||
|
ty1 = 1
|
||||||
|
hab2 = 1
|
||||||
|
tx2 = 1
|
||||||
|
ty2 = 1
|
||||||
|
|
||||||
require "pattern"
|
require "pattern"
|
||||||
|
|
||||||
imp = {}
|
imp = {}
|
||||||
@@ -17,6 +24,7 @@ function imp.new(_hab,_x,_y)
|
|||||||
name="imp",
|
name="imp",
|
||||||
hab=_hab,
|
hab=_hab,
|
||||||
x=world_x, y=world_y,
|
x=world_x, y=world_y,
|
||||||
|
x_old = 0, y_old = 0,
|
||||||
w=32, h=32,
|
w=32, h=32,
|
||||||
bb={x=8,y=0,w=16,h=32},
|
bb={x=8,y=0,w=16,h=32},
|
||||||
flip=true,
|
flip=true,
|
||||||
@@ -26,7 +34,7 @@ function imp.new(_hab,_x,_y)
|
|||||||
step=0,
|
step=0,
|
||||||
moods={stop=0, chase=1, avoid=2, neutral=4},
|
moods={stop=0, chase=1, avoid=2, neutral=4},
|
||||||
mood=0, --anterior fight_mode
|
mood=0, --anterior fight_mode
|
||||||
timers={mood=150,target=250, shot=2500, super=20000, flip_wait=50}, --anterior *_cooldown
|
timers={mood=150,target=250, shot=100, super=200, flip_wait=50}, --anterior *_cooldown
|
||||||
move_types={free=0, pattern=1, super=2},
|
move_types={free=0, pattern=1, super=2},
|
||||||
move_type=1, -- anterior movement_type
|
move_type=1, -- anterior movement_type
|
||||||
actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64, jumpfwd=128},
|
actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64, jumpfwd=128},
|
||||||
@@ -40,11 +48,14 @@ function imp.new(_hab,_x,_y)
|
|||||||
vmove_space = 1,
|
vmove_space = 1,
|
||||||
falling = 0,
|
falling = 0,
|
||||||
action_event = {},
|
action_event = {},
|
||||||
|
action = 0,
|
||||||
|
old_action = 0,
|
||||||
--
|
--
|
||||||
moure = noop,
|
moure = noop,
|
||||||
draw=imp.draw,
|
draw=imp.draw,
|
||||||
update=imp.update_normal,
|
update=imp.update_normal,
|
||||||
reduce_timers = imp.reduce_timers,
|
reduce_timers = imp.reduce_timers,
|
||||||
|
reset_timer = imp.reset_timer,
|
||||||
analyze_env = imp.analyze_env,
|
analyze_env = imp.analyze_env,
|
||||||
choose_action = imp.choose_action,
|
choose_action = imp.choose_action,
|
||||||
controller_input = imp.controller_input,
|
controller_input = imp.controller_input,
|
||||||
@@ -59,7 +70,13 @@ function imp.new(_hab,_x,_y)
|
|||||||
land = imp.land,
|
land = imp.land,
|
||||||
next_frame = imp.staying_next_frame,
|
next_frame = imp.staying_next_frame,
|
||||||
do_flip = imp.do_flip,
|
do_flip = imp.do_flip,
|
||||||
|
update_action_events = imp.update_action_events,
|
||||||
|
check_action_event = imp.check_action_event,
|
||||||
|
add_action_event = imp.add_action_event,
|
||||||
|
shot = imp.shot,
|
||||||
|
-- debug
|
||||||
_moure = imp._moure,
|
_moure = imp._moure,
|
||||||
|
_pause = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -94,6 +111,14 @@ function imp:draw() --OK
|
|||||||
draw.surf((self.frame&7)*self.w, (self.frame>>cxr2)*self.h, self.w, self.h, scr_x, scr_y, self.w, self.h, self.flip)
|
draw.surf((self.frame&7)*self.w, (self.frame>>cxr2)*self.h, self.w, self.h, scr_x, scr_y, self.w, self.h, self.flip)
|
||||||
pal.subpal(5)
|
pal.subpal(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
draw.rect(scr_x+self.bb.x,scr_y+self.bb.h, self.bb.w, 8,2)
|
||||||
|
local wtx, wty = coords.room_to_world(hab1, tx1, ty1)
|
||||||
|
local scr_x, scr_y = viewp:screen_coords( wtx, wty )
|
||||||
|
draw.rect(scr_x, scr_y, 16, 16, 15)
|
||||||
|
local wtx, wty = coords.room_to_world(hab2, tx2, ty2)
|
||||||
|
local scr_x, scr_y = viewp:screen_coords( wtx, wty )
|
||||||
|
draw.rect(scr_x, scr_y, 16, 16, 13)
|
||||||
end
|
end
|
||||||
|
|
||||||
function imp:hit() -- OK
|
function imp:hit() -- OK
|
||||||
@@ -129,12 +154,14 @@ function imp:update_hit()
|
|||||||
-- Que pasa quan "mor"
|
-- Que pasa quan "mor"
|
||||||
end
|
end
|
||||||
function imp:update_normal()
|
function imp:update_normal()
|
||||||
print("-------------------------------------------------")
|
-- print("")
|
||||||
print("")
|
|
||||||
-- if self.mood~=self.moods.stop then print("TARGET= "..self.pattern:target()) end
|
|
||||||
-- if self.mood~=self.moods.stop then print("ACTIONS= "..#self.pattern:actions()) end
|
|
||||||
-- print("TARGET TIMER= "..self.timers.target)
|
-- print("TARGET TIMER= "..self.timers.target)
|
||||||
|
|
||||||
|
if not self._pause then
|
||||||
|
-- print("-------------------------------------------------")
|
||||||
|
-- if self.mood~=self.moods.stop then print("TARGET= "..self.pattern:target()) end
|
||||||
|
-- if self.mood~=self.moods.stop then print("ACT/EV= "..self.pattern:action().." / "..self.pattern:event()) end
|
||||||
|
-- if self.mood~=self.moods.stop then print("ACTIONS= "..#self.pattern:actions()) end
|
||||||
self:reduce_timers()
|
self:reduce_timers()
|
||||||
|
|
||||||
-- Ajustar mood (emocions)
|
-- Ajustar mood (emocions)
|
||||||
@@ -144,16 +171,21 @@ print("")
|
|||||||
|
|
||||||
-- analisis
|
-- analisis
|
||||||
self:analyze_env()
|
self:analyze_env()
|
||||||
|
self:update_action_events()
|
||||||
|
-- print_analisis()
|
||||||
|
|
||||||
-- decisio
|
-- decisio
|
||||||
self:choose_action()
|
self:choose_action()
|
||||||
|
-- local str_aev = ""
|
||||||
|
-- for k,v in pairs(self.action_event) do str_aev=str_aev..", "..v end
|
||||||
|
-- if self.mood~=self.moods.stop then print("TARGET= "..self.pattern:target().." ACTION= "..self.pattern:action().." ACTION EVENT= "..self.pattern:event().." / "..str_aev) end
|
||||||
-- moviment
|
-- moviment
|
||||||
self:controller_input()
|
self:controller_input()
|
||||||
self:moure()
|
self:moure()
|
||||||
|
|
||||||
-- Logica per a selecció de frame
|
-- Logica per a selecció de frame
|
||||||
self:next_frame()
|
self:next_frame()
|
||||||
|
end
|
||||||
|
|
||||||
-- colisions en personatges
|
-- colisions en personatges
|
||||||
-- self:colisions()
|
-- self:colisions()
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ function pattern:draw()
|
|||||||
for k, v in pairs(self.node) do
|
for k, v in pairs(self.node) do
|
||||||
scr_x, scr_y = viewp:screen_coords( v.x, v.y )
|
scr_x, scr_y = viewp:screen_coords( v.x, v.y )
|
||||||
if self.path_idx==k or target==k then
|
if self.path_idx==k or target==k then
|
||||||
draw.rectf(scr_x, scr_y, 16, 16, 3)
|
draw.rectf(scr_x, scr_y, 16, 16, 13)
|
||||||
else
|
else
|
||||||
draw.rectf(scr_x, scr_y, 16, 16, 16)
|
draw.rectf(scr_x, scr_y, 16, 16, 16)
|
||||||
draw.rect(scr_x, scr_y, 16, 16, 3)
|
draw.rect(scr_x, scr_y, 16, 16, k)
|
||||||
end
|
end
|
||||||
if target ~= nil and target==k then
|
if target ~= nil and target==k then
|
||||||
draw.rectf(scr_x, scr_y, 16, 16, 2)
|
draw.rectf(scr_x, scr_y, 16, 16, 15)
|
||||||
end
|
end
|
||||||
draw.text(k, scr_x+4, scr_y+4, 14)
|
draw.text(k, scr_x+4, scr_y+4, k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Necessite saber quina estrategia aplicar abans de moure al següent target
|
-- Necessite saber quina estrategia aplicar abans de moure al següent target
|
||||||
@@ -128,7 +128,7 @@ end
|
|||||||
-- return pattern:action()
|
-- return pattern:action()
|
||||||
-- end
|
-- end
|
||||||
function pattern:next_action ( )
|
function pattern:next_action ( )
|
||||||
print_dbg("")
|
-- print_dbg("")
|
||||||
local num_actions = 0
|
local num_actions = 0
|
||||||
-- index a la següent acció
|
-- index a la següent acció
|
||||||
self.action_idx = self.action_idx+1
|
self.action_idx = self.action_idx+1
|
||||||
@@ -148,7 +148,7 @@ end
|
|||||||
|
|
||||||
-- [OK] Canvia al següent target segons el path o al que se li pase
|
-- [OK] Canvia al següent target segons el path o al que se li pase
|
||||||
function pattern:next_target( target )
|
function pattern:next_target( target )
|
||||||
print_dbg("")
|
-- print_dbg("")
|
||||||
target = target or self:target()
|
target = target or self:target()
|
||||||
-- Si hi ha una entrada manual eliminar-la
|
-- Si hi ha una entrada manual eliminar-la
|
||||||
if not empty_table(self.manual_path) then
|
if not empty_table(self.manual_path) then
|
||||||
|
|||||||
Reference in New Issue
Block a user