use tiles to improve perf

This commit is contained in:
evanpelle
2024-08-10 19:35:31 -07:00
parent f7b0441f41
commit dd94bb4c65
8 changed files with 64 additions and 54 deletions
+6 -6
View File
@@ -56,12 +56,12 @@ class Client {
this.lobbiesContainer.appendChild(button);
});
// Join first lobby
if (!this.hasJoined && lobbies.length > 0) {
this.hasJoined = true
console.log(`joining lobby ${lobbies[0].id}`)
this.joinLobby(lobbies[0].id)
}
// // Join first lobby
// if (!this.hasJoined && lobbies.length > 0) {
// this.hasJoined = true
// console.log(`joining lobby ${lobbies[0].id}`)
// this.joinLobby(lobbies[0].id)
// }
}
async fetchLobbies() {
+2 -2
View File
@@ -95,7 +95,7 @@ export class ClientGame {
this.renderer.initialize()
this.input.initialize()
this.executor.spawnBots(500)
this.executor.spawnBots(1000)
setInterval(() => this.tick(), 10);
@@ -148,7 +148,7 @@ export class ClientGame {
const owner = tile.owner()
const targetID = owner.isPlayer() ? owner.id() : null
if (tile.owner() != this.myPlayer) {
if (this.myPlayer.sharesBorderWith(tile.owner())) {
if (this.myPlayer.sharesBorderWith(tile.owner())) {
this.sendAttackIntent(targetID, cell)
} else {
// TODO verify on ocean
+3 -3
View File
@@ -193,15 +193,15 @@ export class GameRenderer {
tileUpdate(event: TileEvent) {
this.paintTile(event.tile)
this.gs.neighbors(event.tile.cell()).forEach(c => this.paintTile(this.gs.tile(c)))
event.tile.neighbors().forEach(t => this.paintTile(t))
}
playerEvent(event: PlayerEvent) {
}
boatEvent(event: BoatEvent) {
this.paintCell(event.boat.cell(), new Colord({r: 255, g: 255, b: 255}))
this.gs.neighbors(event.boat.cell()).map(c => this.gs.tile(c)).forEach(t => this.paintTile(t))
this.paintCell(event.boat.tile().cell(), new Colord({r: 255, g: 255, b: 255}))
this.gs.neighbors(event.boat.tile()).forEach(t => this.paintTile(t))
}
resize(width: number, height: number): void {