game.js
třída
JavaScript
// game.js
var game = new Object();
game.fps = 60;
game.canvas = document.getElementById('canvas');
game.canvasContext = this.canvas.getContext('2d');
game.objects = Array();
game.setFPS = function (fps){
this.fps = fps;
};
game.createObjects = function () {
this.objects.push(new board(0, (this.canvas.height - BOARD_HEIGHT) / 2 ,this.canvasContext));
this.objects.push(new board(this.canvas.width - 10, (this.canvas.height - BOARD_HEIGHT) / 2 ,this.canvasContext));
this.objects.push(new ball(this.canvas.width / 2, this.canvas.height / 2 ,this.canvasContext));
};
game.start = function () {
this.createObjects();
};
game.play = function () {
console.log("called");
this.move();
this.render();
};
game.move = function () {
this.objects[2].move();
};
game.render = function () {
this.canvasContext.fillStyle = 'black';
this.canvasContext.fillRect(0,0, this.canvas.width, this.canvas.height);
this.objects.forEach(function (t) { t.render() });
};
Neformátovaný
Přidáno: 17.8.2017
Expirace: Neuvedeno