diff --git a/data/abad.lua b/data/abad.lua index 7a177d3..a90d81e 100644 --- a/data/abad.lua +++ b/data/abad.lua @@ -133,7 +133,7 @@ end function abad_hurt(howmuch) - -- howmuch = 0 + howmuch = 0 if abad.hurting == 0 and abad.respawning==0 then sound.play(audio_abad_hit) abad.energia=abad.energia-howmuch diff --git a/data/game.lua b/data/game.lua index 6bf5a4d..d30f2d0 100644 --- a/data/game.lua +++ b/data/game.lua @@ -257,8 +257,8 @@ function update_game() score.draw() - if DEBUG then special_keys() + if DEBUG then debug_info() end end @@ -334,7 +334,55 @@ function update_pause() 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() + 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 -- -- abad prev room -- local hab = abad.hab-1 diff --git a/data/helpers.lua b/data/helpers.lua index fb8d594..5a94a96 100644 --- a/data/helpers.lua +++ b/data/helpers.lua @@ -18,6 +18,13 @@ function in_table(tabla, valor) return false 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) 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) diff --git a/data/imp3-functions.lua b/data/imp3-functions.lua index 564222d..f527bfc 100644 --- a/data/imp3-functions.lua +++ b/data/imp3-functions.lua @@ -1,10 +1,10 @@ function imp:_moure( foo, name ) - name = name or "anonymous" - if not foo then - print_dbg(name.." not found") - else - print_dbg(name) - end + -- name = name or "anonymous" + -- if not foo then + -- print_dbg(name.." not found") + -- else + -- print_dbg(name) + -- end self.moure = foo end @@ -24,6 +24,23 @@ if DEBUG_FN_NAME then print_dbg("reduce_timers") 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 -- 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 @@ -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) x1_check = self.x+self.bb.x 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 - local hab1, tx1, ty1 = coords.world_to_tile(x1_check, y_check) - local hab2, tx2, ty2 = coords.world_to_tile(x2_check, y_check) + hab1, tx1, ty1 = coords.world_to_tile(x1_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) 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 + -- 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? 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 + if not self.analisis.falling then + local step_length = self.step_length + + -- default movent-se cap a la dreta + x1_check = self.x+self.bb.x+(self.bb.w/2) + 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 -- 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 -- 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: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.action.." / "..k) end +-- 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 + if (self.action == self.actions.right or + self.action == self.actions.left) then + if self.moure == imp.state_normal or self.moure == imp.state_walking then + self:_moure(imp.state_walking, "") + end + elseif (self.action == self.actions.jump) then + if self.moure == imp.state_normal or self.moure == imp.state_walking then + self:jump() + end + elseif (self.action == self.actions.jumpfwd) then + if self.moure == imp.state_normal or self.moure == imp.state_walking then + self:jump(true) + end + 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 + elseif (self.action == self.actions.super) then + 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_event = {} end ------------------------------- @@ -171,6 +255,28 @@ if DEBUG_FN_NAME then print_dbg("fight") end self.mood=self.moods.chase 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 ------------------------------- @@ -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[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[4] = point.new(54, 5, 4, 0, 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[6] = point.new(55, 8, 4, 0, 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") @@ -200,7 +306,8 @@ function imp:load_pattern_paths() --OK {target=3, actions= {{action="right" , event="prefall"}, {action="jumpfwd", event="land"}, {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"}}}, {target=4, actions= {{action="right" , event="prefall"}, {action="jumpfwd", event="land"}, @@ -221,11 +328,21 @@ function imp:load_pattern_paths() --OK {target=3, actions= {{action="left" , event="prefall"}, {action="jumpfwd", event="land"}, {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"}}}, {target=6, actions= {{action="left" , event="prefall"}, {action="jumpfwd", event="land"}, {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"}, {action="jumpfwd", event="land"}, {action="left" , event="target"}}}, @@ -276,21 +393,30 @@ function imp:load_pattern_paths() --OK {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"}}} + {target=10,actions={{action="" , event="land"}, + {action="left" , event="land"}, + {action="left" , event="prefall"}, + {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] = { {target=5, actions={{action="right" , event="prefall"}, {action="jumpfwd" , event="land"}, {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="right" , event="target"}}}, {target=1, actions={{action="jump" , event="target"}}} } self.pattern.path[9] = { + {target=6, actions={{action="right" , event="target"}}}, {target=5, actions={{action="right" , event="target"}}}, {target=1, actions={{action="left" , event="prefall"}, {action="jumpfwd" , event="land"}, @@ -301,10 +427,12 @@ function imp:load_pattern_paths() --OK 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"}}} + {action="jumpfwd" , event="land"}, + {action="right" , event="prefall"}, + {action="jump" , event="target"}}}, + {target=6, actions={{action="right" , event="target"}}}, + {target=6, actions={{action="left" , event="land"}, + {action="right" , event = "target"}}} } self.pattern.path[11] = { {target=4, actions={{action="left", event="target"}}} @@ -330,12 +458,10 @@ 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 + if self.timers.shot<=0 and h_collision(self, self.shot_target) then + next_action = "shot" end - + -- Resta d'accions if next_action==self.actions.no_action then if self.move_type==self.move_types.free then @@ -343,40 +469,43 @@ function imp:next_action() -- 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 + local action_event_done = self:check_action_event(self.pattern:event()) + -- local str_aev = "" + -- 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() - print("TARGET => "..next_action) + -- print_dbg("NEXT ACTION "..next_action) else next_action=self.pattern:action() - print("ON WAY => "..next_action) + -- print_dbg("HOLD ACTION "..next_action) end elseif self.move_type==self.move_types.super then -- SUPER -- end end + self.action_event = {} -- next_action es text, traduir return self.actions[next_action] end -function imp:do_jump ( jumpfwd ) +function imp: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="" + self:_moure(imp.state_jumping,"") + -- 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 +-- print_dbg(">>>>>>>>>> state_jumping") -- ?? self.wait=self.wait+1 self.wait=0 @@ -384,7 +513,7 @@ if DEBUG_FN_NAME then print_dbg("state_jumping") end -- Pujar o caure if self.jump_height0 then + self.old_y = self.y self.y=self.y-vspace self.jump_in_half_block = self.jump_in_half_block-1 self.jump_in_half_block_used = true @@ -440,57 +571,67 @@ if DEBUG_FN_NAME then print_dbg("jump") end end -- Registrar el desplaçament - self.jump_height = self.jump_height+1 + self.jump_height = self.jump_height+vspace 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 + local step_length=self.step_length; --lo que avança el imp cada pas + local x_check = 0 + local y_check = self.y+self.bb.h-1 - -- 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 + if (self.old_action == self.actions.right or + self.old_action == self.actions.left) then + -- orientació des de control + if self.old_action == self.actions.left 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 + 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 - local y_check = self.y+self.bb.h-4 - if arc_check_tile(x_check, y_check)>>>>>>>>> state_falling") + -- 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)") + self.jumpfwd = false return end --- print_dbg("FALLING!") + -- Seguir caiguent + self.old_y = self.y self.y=self.y+1 self.jump_height = self.jump_height-1 self.falling=self.falling+1 @@ -501,7 +642,6 @@ 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 @@ -521,7 +661,7 @@ if DEBUG_FN_NAME then print_dbg("land") end if can_land then self.jump_in_half_block_used = false self.jump_height = 0 - table.insert(self.action_event, "land") + self:add_action_event("land") end -- if can_land then print_dbg ("LANDED") end return can_land @@ -529,8 +669,8 @@ 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) +if DEBUG_FN_NAME then print("state_walking") end +-- print_dbg(">>>>>>>>>> state_walking") -- Limitar la velocitat de moviment 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) 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 self:_moure(imp.state_falling, "state_falling (states-walking)") return end @@ -556,6 +696,7 @@ end function imp:state_normal() if DEBUG_FN_NAME then print_dbg("state_normal") end + -- print_dbg(">>>>>>>>>> state_normal") self.frame=28 self.wait=0 self.step=0 @@ -567,7 +708,7 @@ end -- imp.next_frame() function imp:walking_next_frame() -- Selecció de frame - if self.wait==6 then + if self.wait>=6 then self.wait=0 self.step=(self.step+1)%4 self.frame=self.anim[self.step+1] diff --git a/data/imp3.lua b/data/imp3.lua index 46ec2a2..f098021 100644 --- a/data/imp3.lua +++ b/data/imp3.lua @@ -5,6 +5,13 @@ function print_dbg(...) print("[" .. nombre .. "]", ...) end +hab1 = 1 +tx1 = 1 +ty1 = 1 +hab2 = 1 +tx2 = 1 +ty2 = 1 + require "pattern" imp = {} @@ -17,6 +24,7 @@ function imp.new(_hab,_x,_y) name="imp", hab=_hab, x=world_x, y=world_y, + x_old = 0, y_old = 0, w=32, h=32, bb={x=8,y=0,w=16,h=32}, flip=true, @@ -26,7 +34,7 @@ function imp.new(_hab,_x,_y) step=0, moods={stop=0, chase=1, avoid=2, neutral=4}, 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_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}, @@ -40,11 +48,14 @@ function imp.new(_hab,_x,_y) vmove_space = 1, falling = 0, action_event = {}, + action = 0, + old_action = 0, -- moure = noop, draw=imp.draw, update=imp.update_normal, reduce_timers = imp.reduce_timers, + reset_timer = imp.reset_timer, analyze_env = imp.analyze_env, choose_action = imp.choose_action, controller_input = imp.controller_input, @@ -59,7 +70,13 @@ function imp.new(_hab,_x,_y) land = imp.land, next_frame = imp.staying_next_frame, 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, + _pause = false, } 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) pal.subpal(5) 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 function imp:hit() -- OK @@ -129,12 +154,14 @@ function imp:update_hit() -- Que pasa quan "mor" end function imp:update_normal() -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("") -- 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() -- Ajustar mood (emocions) @@ -144,16 +171,21 @@ print("") -- analisis self:analyze_env() + self:update_action_events() +-- print_analisis() -- decisio 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 self:controller_input() self:moure() -- Logica per a selecció de frame self:next_frame() + end -- colisions en personatges -- self:colisions() diff --git a/data/pattern.lua b/data/pattern.lua index 1e2e5f7..65b1134 100644 --- a/data/pattern.lua +++ b/data/pattern.lua @@ -30,15 +30,15 @@ function pattern:draw() for k, v in pairs(self.node) do scr_x, scr_y = viewp:screen_coords( v.x, v.y ) 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 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 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 - draw.text(k, scr_x+4, scr_y+4, 14) + draw.text(k, scr_x+4, scr_y+4, k) end end -- Necessite saber quina estrategia aplicar abans de moure al següent target @@ -128,7 +128,7 @@ end -- return pattern:action() -- end function pattern:next_action ( ) -print_dbg("") +-- print_dbg("") local num_actions = 0 -- index a la següent acció 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 function pattern:next_target( target ) -print_dbg("") +-- print_dbg("") target = target or self:target() -- Si hi ha una entrada manual eliminar-la if not empty_table(self.manual_path) then