"Error
Syntax error: src/level.lua:8: unexpected symbol near '='
"
My Code looks like this
Code: Select all
Level = {}
Level.__index = Level
function Level.new(x, y, map_width, map_height,tile_width , tile_height, image, tiles, collision, entities)
local instance = setmetatable({}, Level)
instance.x = x
instance.y = y
instance.map = {}
instance.map.width = map_width
instance.map.height = map_height
instance.map.tile_width = tile_width
instance.map.tile_height = tile_height
instance.map.tiles = tiles
instance.map.spritbatch = love.graphics.newSpriteBatch(image)
instance.map.image = image
instance.map.quads = {}
for y=0, instance.map.image:getWidth() / instance.map.tile_height do
for x=0, instance.map.image:getHeight() / instance.map.tile_width do
q = love.graphics.newQuad((x-1)*instance.map.tile_width, (y-1)*instance.map.tile_height, instance.map.tile_height, instance.map.tile_width, instance.map.image.getWidth(), instance.map.image.getHeight())
table.insert(instance.map.quads, q)
end
end
for y, xs in ipairs(instance.map.tiles) do
for x, value in ipairs(xs) do
instance.map.spriteBatch:add(instance.tile.quads[instance.map.table[y][x]], ( x-1) * instance.map.tile_width, (y-1) * instance.map.tile_height )
end
end
return instance
end
function Level:draw()
love.graphics.draw(self.spritbatch)
end