unibutton/common/game_basic.js
2024-10-18 19:30:00 -04:00

38 lines
No EOL
871 B
JavaScript

import Player from "./player.js";
class GameBasic {
constructor(width = 7500, height = 7500) {
let player = new Player(false, true, this);
let entities = [player];
/*for (let i = 0; i < 50; i++) {
entities.push(new Player(false,false))
}*/
this.player = player;
this.entities = entities;
this.width = width;
this.height = height;
this.intCount = 8;
}
main(j) {
let { entities } = this;
let that = this;
for (let i = j; i < entities.length; i += this.intCount) {
let ent = entities[i];
ent.handleTick(that)
}
}
init() {
let that = this;
for (let i = 0; i < that.intCount; i++) {
setInterval(function () { that.main(i) }, 1000 / 60);
}
}
}
export default GameBasic;