p1 = { -- Pushed values to this object on update (self.xxx) -- x,y (in) : top left corner of the entity -- vx,vy (in) : Velocity -- width (in), height : dimensions of the map<->entity hitbox -- points (in) : scored points -- intent (in-out) : Intended direction of the entity when it'll can. -- Editing intent will impact the AI's deplacement. -- The game structure -- The map is stored as 8*8pixel tiles. -- The map has a dimension of 224*248 pixels (borders included). -- To push the IA to move to another direction when it can, edit self. -- The game structure stores the players' and ghosts' position (in pixel) and velocity -- gamestructure.p1.x -- gamestructure.p2.y -- gamestructure.blinky == red -- gamestructure.inky == cyan -- gamestructure.pinky == huh -- gamestructure.clyde == orange -- gamestate functions -- Note : All of those functions needs gamestate.data as first argument -- collide(gamestate.data, x,y,w,h) checks if a rectangle defined by its left corner and its dimensions collides with the walls. -- get_tile(gamestate.data, x, y) returns the tile on the map with tile coordinates. Returns a tbale with a has_gum integer and is_solid boolean init = function(self) end, update = function(self) self.intent = math.random(0, 4) local pos = self:get_tile_coords_at_center() end, -- This one wil just be called from update or init as such: -- self:get_tile_coords_at_center -- Returns a table {x = tile_pos_y, y = tile_pos_y} or nil when the Pacman is out of bounds, so to use the variables -- do something like this: -- local pos = self:get_tile_coords_at_center() -- print("x : "..pos.x.." y : "..pos["x"]) get_tile_coords_at_center = function(self) if self.x < 0 or self.x > 224-16 or self.y < 0 or self.y > 248-16 then return nil else return {x=math.floor((self.x+4)/8), y=math.floor((self.y+4)/8)} end end }