 
 createPlugins = require 'voxel-plugins'
 
+# plugins
 createOculus = require 'voxel-oculus'
 createHighlight = require 'voxel-highlight'
 createPlayer = require 'voxel-player'

defaultSetup = (game, avatar) ->
  console.log "entering setup"

  debug = createDebug(game)
  debug.axis([0, 0, 0], 10)

  game.mode = GAME_MODE_SURVIVAL
  controlsTarget = game.controls.target()

  game.flyer = createFly(game, {physical: controlsTarget, flySpeed: 0.8, enabled: false})

  walk = createWalk(game, { 
    skin: controlsTarget.playerSkin
    bindGameEvents: true
    shouldStopWalking: () =>
      vx = Math.abs(controlsTarget.velocity.x)
      vz = Math.abs(controlsTarget.velocity.z)
      return vx > 0.001 || vz > 0.001
    })

  reach = createReach(game, { reachDistance: REACH_DISTANCE })
  mine = createMine(game, {
    instaMine: false
    reach: reach
    progressTexturesBase: "ProgrammerArt/textures/blocks/destroy_stage_"
    progressTexturesCount: 9
  })

  console.log "configuring highlight "
  # highlight blocks when you look at them, hold <Ctrl> for block placement
  highlight = createHighlight game, { 
    color:  0xff0000
    distance: REACH_DISTANCE
    adjacentActive: () -> false
    }

  # toggle between first and third person 
  window.addEventListener 'keydown', (ev) ->


  # create the player from a minecraft skin file and tell the
  # game to use it as the main player
  avatar = game.plugins.load "voxel-player", {image: 'player.png'}
  avatar.pov('first');
  avatar.possess()
  home(avatar)
