Home

This site was created for a single purpose. Fun! I want this page to be a simple page where i can create content you may enjoy.

function Player() {
this.x = 0;
this.y = 0;
}

Player.prototype.draw = function(context) {
context.fillRect(this.x, this.y, 32, 32);
};

Player.prototype.moveLeft = function() {
this.x -= 1;
};

Player.prototype.moveRight = function() {
this.x += 1;
};

Player.prototype.moveUp = function() {
this.y -= 1;
};

Player.prototype.moveRight = function() {
this.y += 1;
};
Game.start = function() {

Game.player = new Player();


};

Game.draw = function() {

Game.player.draw(Game.context);


};

window.addEventListener(‘keydown’, function(event) {
switch (event.keyCode) {
case 37: // Left
Game.player.moveLeft();
break;

case 38: // Up
Game.player.moveUp();
break;

case 39: // Right
Game.player.moveRight();
break;

case 40: // Down
Game.player.moveDown();
break;
}
}, false);