local Entity = require "scenes.levels.entities.parent"

local Block = Entity:extend()

function Block:new(level, x , y, item)
  Block.super.new(self, level, "block", x, y, 16, 16)
  self.item = item or 0
end

function Block:draw(dt)
  self.level.assets.tileset["block"]:drawTile(1, self.x, self.y)
end

function Block:breakBlock()
  local x, y = self:getCenter()
  local spd = 250
  local dist = 0
  self.obj.Debris(self.level, x+dist, y-dist, spd, 270+45)
  self.obj.Debris(self.level, x+dist, y+dist, spd,     45)
  self.obj.Debris(self.level, x-dist, y+dist, spd, 180+45)
  self.obj.Debris(self.level, x-dist, y-dist, spd, 180-45)
  self.obj.GFX(self.level, self.x+8, self.y+8, "poof", 1)
  self.level.assets:playSFX("break")
  self.level.playermanager.score  = self.level.playermanager.score  + 10
  self:destroy()
end

return Block
