Skip to content

Commit

Permalink
Merge pull request #29 from saurabh-prosoft/feature/re-design-2
Browse files Browse the repository at this point in the history
Feature/re design 2
  • Loading branch information
bhagatsaurabh committed Apr 2, 2024
2 parents 373e2d8 + fe0a2b7 commit 2e5c0f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/game/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { GameRoom } from '@/rooms/GameRoom';
import { physicsEngine } from '@/app.config';
import { Player } from '@/rooms/schema/RoomState';
import { IMessageInput } from '@/types/interfaces';
import { port } from '@/index';

export class World {
private static timeStep = 1 / 60;
Expand Down Expand Up @@ -58,7 +59,7 @@ export class World {
private static async importPlayerMesh(instance: World) {
const { meshes } = await SceneLoader.ImportMeshAsync(
null,
'http://localhost:2567/assets/models/',
`http://localhost:${port}/assets/models/`,
'Panzer_I.glb',
instance.scene
);
Expand Down
3 changes: 2 additions & 1 deletion src/game/models/ground.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { port } from '@/index';
import { Scene } from '@babylonjs/core';
import { MeshBuilder, type GroundMesh } from '@babylonjs/core/Meshes';
import { PhysicsAggregate, PhysicsShapeType } from '@babylonjs/core/Physics';
Expand All @@ -15,7 +16,7 @@ export class Ground {
private static createMesh(scene: Scene) {
const ground = new Ground();
return new Promise<Ground>((resolve, reject) => {
loadImage('http://localhost:2567/assets/map/desert/height.png').then((image) => {
loadImage(`http://localhost:${port}/assets/map/desert/height.png`).then((image) => {
const canvas = createCanvas(2048, 2048);
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0, 2048, 2048);
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ let port = 2567;
if (['string', 'number'].includes(typeof process.env.PORT)) {
port = typeof process.env.PORT === 'number' ? process.env.PORT : parseInt(process.env.PORT);
}

export { port };

listen(app, port);
4 changes: 2 additions & 2 deletions src/rooms/GameRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class GameRoom extends Room<RoomState> {
}
}
onDispose() {
this.monitor.stop();
this.world.destroy();
this.monitor?.stop();
this.world?.destroy();

console.log('Room', this.roomId, 'disposed');
}
Expand Down

0 comments on commit 2e5c0f8

Please sign in to comment.