summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2021-07-23 13:03:19 +0200
committerMike Vink <mike1994vink@gmail.com>2021-07-23 13:03:19 +0200
commiteaff86546eca516d51c27eb9d63ea33a96576e90 (patch)
tree6af16df4b45b2944c41adf865905240da75612c7
parent0148ea0de6aa06306fd973694e313b98a777c136 (diff)
info(): moved a bunch of files
-rw-r--r--client/src/GameState.ts11
-rw-r--r--client/src/akkamon/client/Client.ts (renamed from client/src/client.ts)0
-rw-r--r--client/src/akkamon/client/Events.ts (renamed from client/src/events.ts)0
-rw-r--r--client/src/akkamon/client/Session.ts (renamed from client/src/session.ts)0
-rw-r--r--client/src/akkamon/client/Socket.ts (renamed from client/src/socket.ts)0
-rw-r--r--client/src/akkamon/render/Direction.ts (renamed from client/src/Direction.ts)0
-rw-r--r--client/src/akkamon/render/GridControls.ts (renamed from client/src/GridControls.ts)17
-rw-r--r--client/src/akkamon/render/UIControls.ts2
-rw-r--r--client/src/akkamon/render/engine/GridPhysics.ts (renamed from client/src/GridPhysics.ts)0
-rw-r--r--client/src/akkamon/render/engine/RemotePlayerEngine.ts (renamed from client/src/RemotePlayerEngine.ts)0
-rw-r--r--client/src/akkamon/render/model/PlayerSprite.ts (renamed from client/src/sprite.ts)0
-rw-r--r--client/src/akkamon/render/model/RemotePlayerSprite.ts (renamed from client/src/RemotePlayerSprite.ts)0
-rw-r--r--client/src/akkamon/scenes/DemoScene.ts (renamed from client/src/scene.ts)3
-rw-r--r--client/src/akkamon/scenes/UIScene.ts (renamed from client/src/uiScene.ts)7
-rw-r--r--client/src/app.ts29
-rw-r--r--client/src/messageTypes.ts4
-rw-r--r--client/src/player.ts24
17 files changed, 41 insertions, 56 deletions
diff --git a/client/src/GameState.ts b/client/src/GameState.ts
deleted file mode 100644
index f1d8ce9..0000000
--- a/client/src/GameState.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import type { Player } from './player';
-
-export class GameState {
-
- localPlayerState?: Player;
- remoteTrainerIdToPlayerState: { [trainerid: string]: Player } = {};
-
- getLocalMutablePlayerState(): Player {
- return this.localPlayerState!;
- }
-}
diff --git a/client/src/client.ts b/client/src/akkamon/client/Client.ts
index 8f9115f..8f9115f 100644
--- a/client/src/client.ts
+++ b/client/src/akkamon/client/Client.ts
diff --git a/client/src/events.ts b/client/src/akkamon/client/Events.ts
index 1954fd7..1954fd7 100644
--- a/client/src/events.ts
+++ b/client/src/akkamon/client/Events.ts
diff --git a/client/src/session.ts b/client/src/akkamon/client/Session.ts
index bbefd66..bbefd66 100644
--- a/client/src/session.ts
+++ b/client/src/akkamon/client/Session.ts
diff --git a/client/src/socket.ts b/client/src/akkamon/client/Socket.ts
index 4e83f89..4e83f89 100644
--- a/client/src/socket.ts
+++ b/client/src/akkamon/client/Socket.ts
diff --git a/client/src/Direction.ts b/client/src/akkamon/render/Direction.ts
index a173585..a173585 100644
--- a/client/src/Direction.ts
+++ b/client/src/akkamon/render/Direction.ts
diff --git a/client/src/GridControls.ts b/client/src/akkamon/render/GridControls.ts
index 9986b1f..d7feef2 100644
--- a/client/src/GridControls.ts
+++ b/client/src/akkamon/render/GridControls.ts
@@ -2,20 +2,23 @@ import { Direction } from './Direction';
import type { GridPhysics } from './GridPhysics';
export class GridControls {
+ private cursors: Phaser.Types.Input.Keyboard.CursorKeys;
+
constructor(
private input: Phaser.Input.InputPlugin,
- private gridPhysics: GridPhysics
- ) { }
+ private gridPhysics: GridPhysics,
+ ) {
+ this.cursors = this.input.keyboard.createCursorKeys();
+ }
update() {
- const cursors = this.input.keyboard.createCursorKeys();
- if (cursors.left.isDown) {
+ if (this.cursors.left.isDown) {
this.gridPhysics.movePlayerSprite(Direction.LEFT);
- } else if (cursors.right.isDown) {
+ } else if (this.cursors.right.isDown) {
this.gridPhysics.movePlayerSprite(Direction.RIGHT);
- } else if (cursors.up.isDown) {
+ } else if (this.cursors.up.isDown) {
this.gridPhysics.movePlayerSprite(Direction.UP);
- } else if (cursors.down.isDown) {
+ } else if (this.cursors.down.isDown) {
this.gridPhysics.movePlayerSprite(Direction.DOWN);
}
}
diff --git a/client/src/akkamon/render/UIControls.ts b/client/src/akkamon/render/UIControls.ts
new file mode 100644
index 0000000..d402cf3
--- /dev/null
+++ b/client/src/akkamon/render/UIControls.ts
@@ -0,0 +1,2 @@
+export class UIControls {
+}
diff --git a/client/src/GridPhysics.ts b/client/src/akkamon/render/engine/GridPhysics.ts
index b1fe459..b1fe459 100644
--- a/client/src/GridPhysics.ts
+++ b/client/src/akkamon/render/engine/GridPhysics.ts
diff --git a/client/src/RemotePlayerEngine.ts b/client/src/akkamon/render/engine/RemotePlayerEngine.ts
index 5d85f24..5d85f24 100644
--- a/client/src/RemotePlayerEngine.ts
+++ b/client/src/akkamon/render/engine/RemotePlayerEngine.ts
diff --git a/client/src/sprite.ts b/client/src/akkamon/render/model/PlayerSprite.ts
index 948d8d9..948d8d9 100644
--- a/client/src/sprite.ts
+++ b/client/src/akkamon/render/model/PlayerSprite.ts
diff --git a/client/src/RemotePlayerSprite.ts b/client/src/akkamon/render/model/RemotePlayerSprite.ts
index 6103d09..6103d09 100644
--- a/client/src/RemotePlayerSprite.ts
+++ b/client/src/akkamon/render/model/RemotePlayerSprite.ts
diff --git a/client/src/scene.ts b/client/src/akkamon/scenes/DemoScene.ts
index b6924d4..c301457 100644
--- a/client/src/scene.ts
+++ b/client/src/akkamon/scenes/DemoScene.ts
@@ -7,6 +7,8 @@ import { Direction } from './Direction';
import { RemotePlayerEngine } from './RemotePlayerEngine';
+import { UIControls } from './uiControls';
+
import { akkamonClient } from './app';
export default class AkkamonStartScene extends Phaser.Scene
@@ -116,7 +118,6 @@ export default class AkkamonStartScene extends Phaser.Scene
camera.roundPixels = true;
camera.setBounds(0, 0, map.widthInPixels, map.heightInPixels);
- this.scene.launch('AkkamonUI');
}
diff --git a/client/src/uiScene.ts b/client/src/akkamon/scenes/UIScene.ts
index 8b92954..3dc7ee9 100644
--- a/client/src/uiScene.ts
+++ b/client/src/akkamon/scenes/UIScene.ts
@@ -1,17 +1,20 @@
+import { UIControls } from './uiControls';
export class AkkamonUI extends Phaser.Scene
{
+
+ private uiControls: UIControls;
+
constructor ()
{
super('AkkamonUI');
}
preload() {
-
}
create () {
-
+ this.uiControls = new UIControls(this.input);
}
}
diff --git a/client/src/app.ts b/client/src/app.ts
index 79b0814..c6bad67 100644
--- a/client/src/app.ts
+++ b/client/src/app.ts
@@ -1,5 +1,6 @@
// import Phaser from 'phaser';
import AkkamonStartScene from './scene';
+import { AkkamonUI } from './uiScene';
import { Client } from './client';
const serviceUrl = 'ws://localhost:8080';
@@ -12,13 +13,27 @@ const config: Phaser.Types.Core.GameConfig & Phaser.Types.Core.RenderConfig = {
width: 800,
height: 600,
pixelArt: true,
- scene: AkkamonStartScene,
- physics: {
- default: "arcade",
- arcade: {
- gravity: { y: 0 }
- }
- }
+ scene: [AkkamonStartScene, AkkamonUI]
};
const game: Phaser.Game = new Phaser.Game(config);
+
+
+import Phaser from 'phaser';
+import gameConfig from './app/gameConfig.js';
+
+function newGame () {
+ if (game) return;
+ game = new Phaser.Game(gameConfig);
+}
+
+function destroyGame () {
+ if (!game) return;
+ game.destroy(true);
+ game.runDestroy();
+ game = null;
+}
+
+let game;
+
+if (!game) newGame();
diff --git a/client/src/messageTypes.ts b/client/src/messageTypes.ts
deleted file mode 100644
index eae45dc..0000000
--- a/client/src/messageTypes.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface Message {
- type: 'login'
-}
-
diff --git a/client/src/player.ts b/client/src/player.ts
deleted file mode 100644
index 20a93fd..0000000
--- a/client/src/player.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type Phaser from 'phaser';
-
-type Sprite = Phaser.Types.Physics.Arcade.SpriteWithDynamicBody;
-
-type PlayerConfig = {
- trainerId: string,
- position: Phaser.Math.Vector2;
-}
-
-type Input = {
- cursors: Phaser.Types.Input.Keyboard.CursorKeys,
-}
-
-export class Player
-{
- trainerId: string
- position: Phaser.Math.Vector2
-
- constructor({trainerId, position}: PlayerConfig) {
- this.trainerId = trainerId;
- this.position = position
- }
-
-}