Tidied up method names

This commit is contained in:
Nathan Kunicki 2015-12-21 16:56:24 +00:00
parent 2eade7a21b
commit 2c88c9ce20
5 changed files with 11 additions and 10 deletions

2
dist/es5.js vendored

File diff suppressed because one or more lines are too long

2
dist/es5.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -42,7 +42,7 @@ window.onload = function () {
mainScene.addChildEntity(rightPaddle);
// Update and render the ball
// Update the ball position
ball.state.speed = new MomentumEngine.Classes.Vector2D(0.1, 0.05); // Current ball speed
ball.update = function () {
@ -60,7 +60,7 @@ window.onload = function () {
};
// Update and render the left paddle
// Update the left paddle according to keyboard input
leftPaddle.update = function () {
if (pong.inputs.keyboard.isPressed(KeyConsts.CHAR_Q) || pong.inputs.keyboard.isPressed(KeyConsts.UP)) {
@ -79,7 +79,7 @@ window.onload = function () {
leftPaddle.pos.y = baseSize;
}
if (leftPaddle.isColliding(ball) && ball.state.speed.x < 0) {
if (leftPaddle.isCollidingWith(ball) && ball.state.speed.x < 0) {
ball.state.speed.x = -ball.state.speed.x;
console.log(ball.state.speed.length());
}
@ -87,7 +87,7 @@ window.onload = function () {
};
// Render the right paddle
// Update the right paddle according to keyboard input
rightPaddle.update = function () {
if (pong.inputs.keyboard.isPressed(KeyConsts.CHAR_O)) {
@ -106,7 +106,7 @@ window.onload = function () {
rightPaddle.pos.y = baseSize;
}
if (rightPaddle.isColliding(ball) && ball.state.speed.x > 0) {
if (rightPaddle.isCollidingWith(ball) && ball.state.speed.x > 0) {
ball.state.speed.x = -ball.state.speed.x;
}

View File

@ -63,6 +63,7 @@ class Entity {
this._calculatedPos.x = this.pos.x + parentPos.x;
this._calculatedPos.y = this.pos.y + parentPos.y;
} else {
this._calculatedPos.x = this.pos.x;
this._calculatedPos.y = this.pos.y;
@ -90,6 +91,8 @@ class Entity {
_updateEntity () {
this._recalculatePos();
if ((this.update && this.update()) || (typeof this.update === "undefined")) {
this.children.forEach((child) => {

View File

@ -19,7 +19,7 @@ class Rect extends Entity {
}
isColliding (entity) {
isCollidingWith (entity) {
if (entity instanceof Rect) {
return CollisionMethods.AABB(this, entity);
@ -30,8 +30,6 @@ class Rect extends Entity {
render () {
this._recalculatePos();
if (this._game) {
this._game.context.fillStyle = this.color;