unibutton/common/game_basic.js

38 lines
871 B
JavaScript
Raw Normal View History

2024-09-29 03:55:22 -04:00
import Player from "./player.js";
class GameBasic {
2024-10-07 10:24:04 -04:00
constructor(width = 7500, height = 7500) {
2024-10-18 19:30:00 -04:00
let player = new Player(false, true, this);
let entities = [player];
2024-09-29 04:11:47 -04:00
/*for (let i = 0; i < 50; i++) {
2024-09-29 03:16:15 -04:00
entities.push(new Player(false,false))
2024-09-29 04:11:47 -04:00
}*/
this.player = player;
this.entities = entities;
2024-09-29 21:20:56 -04:00
2024-10-07 10:24:04 -04:00
this.width = width;
this.height = height;
this.intCount = 8;
}
2024-10-07 10:24:04 -04:00
main(j) {
let { entities } = this;
let that = this;
2024-10-07 10:24:04 -04:00
for (let i = j; i < entities.length; i += this.intCount) {
let ent = entities[i];
ent.handleTick(that)
}
}
init() {
let that = this;
2024-10-07 10:24:04 -04:00
for (let i = 0; i < that.intCount; i++) {
setInterval(function () { that.main(i) }, 1000 / 60);
}
}
2024-09-29 03:55:22 -04:00
}
export default GameBasic;