local module = {}

local NoteClass = {}
NoteClass.__index = NoteClass

local sprites = {
    "purple",
    "blue",
    "green",
    "red"
}

function module.note(raw, mustHitSection)

    local newNote = setmetatable({
        position = raw[1],
        character = nil,
        mustPress = mustHitSection and raw[2] <= 3 or not mustHitSection and raw[2] > 3,
        direction = raw[2] <= 3 and raw[2] + 1 or raw[2] - 3,
        spawned = false,
        sprite = nil -- For unspawned notes
    }, NoteClass)

    return newNote
end

function NoteClass:spawn()
    local sprite = module.types.Rect("sprites/NOTE_assets.png", "sprites/NOTE_assets.json")

    self.sprite = sprite

    sprite:Frame(sprites[self.direction], 0)

    self.spawned = true
end

function NoteClass:destroy()
    if self.sprite then
        self.sprite:Destroy()
    end
    self = nil
end


return module