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