 class Enemy extends Entity
 
   constructor: (@game)->
-    super 0, 0, 100, 100, 5, @game
+    super 0, 0, 100, 100, 10, @game
     @y =  @height
-    @x = -@width
+    @x =  @game.width + @width
     @move @x, @y
 
   render: ->
     @game.ctx.drawImage @game.assets.enemyShip, @x, @y, @width, @height
 
   update: ->
-    @move(@x + @speed)
-    @move(-@width) if @x > @game.width+@width
+    @move(@x - @speed)
+    @move(@game.width + @width) if @x < -@width
 
   move: (x)->
     super x, @y

    for projectile of @projectiles
      @projectiles[projectile].render()

  addProjectile: (projectile)->
    @projectiles.push projectile


    @ctx              = @canvas.getContext '2d'

    @projectiles      = []
    @enemies          = [new Enemy @]

    $('body').append @canvas

    @controller = new Controller @
    @player     = new Player @

  timestamp: ->
    window.performance.now()

  update: ->
    @player.update()
    @updateEnemies()
    @updateProjectiles()
    @handleCollisions()

  render: ->
    @renderBackground()
    @player.render()
    @renderEnemies()
    @renderProjectiles()

  frame: ->
