       menu.attach menuItem
       menuItem
 
-    selected = 0
+    @selected = 0
 
-    selectionChar = Crafty.e('2D, DOM, Text')
+    @selectionChar = Crafty.e('2D, DOM, Text')
       .attr(
         x: menu.x + 20
         w: 40

        weight: 'bold'
        family: 'Press Start 2P'
      )
    menu.attach selectionChar

    updateSelection = ->
      selectionChar.attr(
        y: optionEntities[selected].y
      )

    updateSelection()
    executeSelection = ->
      setTimeout ->
        if selected is 0
          Game.togglePause()
        if selected is 1
          Crafty.audio.toggleMute()
          optionEntities[selected].text soundText()
        if selected is 2
          Game.togglePause()
          Game.resetCredits()
          Crafty('Player').each -> @softReset()
          Crafty.enterScene Game.firstLevel
        if selected is 3
          Game.togglePause()
          Crafty('Player').each -> @reset()
          Crafty.enterScene 'Intro'

    Crafty('Player').each ->
      @bind 'Up', ->
        selected = (options.length + selected - 1) % options.length
        updateSelection()
      @bind 'Down', ->
        selected = (options.length + selected + 1) % options.length
        updateSelection()
      @bind 'Fire', ->
        executeSelection()

  showPlayers: ->
    Crafty('Player').each ->

      else
        @remove()

  soundText: ->
    if Crafty.audio.muted
      'Sound [off]'
    else
      'Sound [on]'

  createMenu: ->
    @options = ['Resume', @soundText(), 'Restart', 'Quit']

    menu = Crafty.e('2D, DOM, Color, PauseMenu')
      .attr(
        x: - Crafty.viewport.x + (.35 * Crafty.viewport.width),
        y: (Crafty.viewport.height * .3) - Crafty.viewport.y,
        w: (.3 * Crafty.viewport.width)
        h: (@options.length + 2) * 32
        z: 100
        alpha: .3
      )
