Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

pourtant j’ai fais un truc assez simple :

local function IA_Scritps(self)
  local human = players[1]

  -- shoot ?
  if self.readyShoot then
    if human.l == self.l then
      if human.c < self.c then
        self:shoot("right")
      elseif human.c > self.c then
        self:shoot("left")
      end
    end
    local rand = love.math.random(100)
    if rand >= 98 then
      local dir = {"left","right"}
      self:shoot(dir[love.math.random(#dir)])
    end
  else
    self:timerUpdate()
  end

  -- move
  if self.timerMove(self) then
    local lstMove = {}
    if testPositionMapAndPlayer(self.l,self.c-1) then -- left
      table.insert(lstMove, {l=self.l, c=self.c-1} )
    end
    if testPositionMapAndPlayer(self.l,self.c+1) then -- right
      table.insert(lstMove, {l=self.l, c=self.c+1} )
    end
    if testPositionMapAndPlayer(self.l-1,self.c) then -- up
      table.insert(lstMove, {l=self.l-1, c=self.c} )
    end
    if testPositionMapAndPlayer(self.l+1,self.c) then -- down
      table.insert(lstMove, {l=self.l+1, c=self.c} )
    end
    --
    local oldPos = {}
    oldPos.l = self.l
    oldPos.c = self.c
    --
    local newPos = lstMove[love.math.random(#lstMove)]
    self.l = newPos.l
    self.c = newPos.c
    --
    local dir = "horiz"
    if oldPos.l ~= self.l then dir = "verti" end
    if oldPos.l ~= self.l or oldPos.c ~= self.c then
      soundManager.play(dir)
    end
  end
end
--