Created
November 20, 2017 07:03
-
-
Save writingdeveloper/de4fe65fe67b3187cd43020bdb6c640f to your computer and use it in GitHub Desktop.
Udacity Project
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
Enemy_Rock.prototype.update = function(dt) { | |
this.x += this.speed * dt; | |
if (this.x >= 505) { | |
this.x = 0; | |
} | |
checkCollision(this); | |
}; | |
Enemy_Rock.prototype.render = function() { | |
ctx.drawImage(Resources.get(this.sprite), this.x, this.y); | |
}; | |
// Update the enemy's position, required method for game | |
// Parameter: dt, a time delta between ticks | |
Enemy.prototype.update = function(dt) { | |
// You should multiply any movement by the dt parameter | |
// which will ensure the game runs at the same speed for | |
// all computers. | |
this.x += this.speed * dt; | |
// 505 defines the width of the Canvas. | |
// The code that initializes the left end again when the enemy is struck at the right end. | |
if (this.x >= 505) { | |
this.x = 0; | |
} | |
checkCollision(this); | |
}; | |
// * Draw the enemy on the screen, required method for game | |
Enemy.prototype.render = function() { | |
ctx.drawImage(Resources.get(this.sprite), this.x, this.y); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment