import Game from '../cgt'
import Scene from '../cgt/scene'
import Menu from '../menu'
import App from '../app'

export default class StartScene extends Scene {

    start() {
        this.menu = Menu.get('start')

        this.lastItemSelected = null

        this.lastWorldLoaded = 'new'

        this.world = App.getWorld()
        this.world.loadNew(180)
        this.world.angle.setOptions(.1, 0)
    }

    onMouseClick() {
        const menuItem = this.menu.getHovered()
        if (menuItem) {
            if (menuItem.action == 'new') {
                Game.scene('play')
            }
        }
    }

    onMouseMove(x, y) {
        this.menu.mouse(x, y)
    }

    update(dt) {
        this.world.angle.inc(10)
        this.world.update(dt)
    }

    draw(ctx) {
        this.world.draw(ctx)
        this.menu.draw(ctx)
    }
}
