split up game code using new es5 syntax or whatever
This commit is contained in:
parent
b237b857c7
commit
506e6be65d
5 changed files with 93 additions and 82 deletions
common
24
common/game_basic.js
Normal file
24
common/game_basic.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
class GameBasic {
|
||||
constructor() {
|
||||
let player = new Player(true);
|
||||
let entities = [player];
|
||||
|
||||
for (let i = 0; i < 50; i++) {
|
||||
entities.push(new Player())
|
||||
}
|
||||
|
||||
this.player = player;
|
||||
this.entities = entities;
|
||||
}
|
||||
main() {
|
||||
let { entities } = this;
|
||||
|
||||
for (let ent of entities) {
|
||||
ent.handleTick(this);
|
||||
}
|
||||
}
|
||||
init() {
|
||||
let that = this;
|
||||
setInterval(function () { that.main() }, 1000 / 60);
|
||||
}
|
||||
}
|
Reference in a new issue