Created
November 3, 2015 00:40
-
-
Save Aaeeschylus/ae84ae75ffe432b41e03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In the enemy class: | |
var totalTime = 0; | |
NormEnemy.prototype.update = function(deltaTime) | |
{ | |
totalTime = totalTime + deltaTime; | |
var mathsSin = (100*(Math.sin(totalTime*3))); | |
if (this.ZigZagMovement == true) | |
{ | |
this.position.x = this.zigZagMean + mathsSin; | |
this.position.y += 1; | |
} | |
} | |
//The spawning of the enemy: | |
function NenemySpawnZigZag(zigZagPosition) | |
{ | |
var NZZenemy = new NormEnemy (); | |
NZZenemy.zigZagMean = zigZagPosition; | |
NZZenemy.position.set(zigZagPosition, 10); | |
NZZenemy.ZigZagMovement = true; | |
enemies.push(NZZenemy); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment