small optimization

This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent 4f4328e163
commit 77071c2e49

View file

@ -1,7 +1,7 @@
import Player from "./player.js";
class GameBasic {
constructor() {
constructor(width = 7500, height = 7500) {
let player = new Player(false, true);
let entities = [player];
@ -12,21 +12,26 @@ class GameBasic {
this.player = player;
this.entities = entities;
this.width = this.height = 7500;
this.width = width;
this.height = height;
this.intCount = 8;
}
main() {
main(j) {
let { entities } = this;
let that = this;
for (let ent of entities) {
(async function() {
ent.handleTick(that)
})();
for (let i = j; i < entities.length; i += this.intCount) {
let ent = entities[i];
ent.handleTick(that)
}
}
init() {
let that = this;
setInterval(function () { that.main() }, 1000 / 60);
for (let i = 0; i < that.intCount; i++) {
setInterval(function () { that.main(i) }, 1000 / 60);
}
}
}