small optimization

This commit is contained in:
biglyderv 2024-10-07 10:24:04 -04:00
parent 151187d40e
commit 30fcf97b6b
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954

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);
}
}
}