import {MapManagerInterface, MapManager} from "./MapManager";
import {GameManagerInterface} from "./GameManager";
+export enum Textures {
+ Rock = 'rock',
+}
+
export interface GameSceneInterface extends Phaser.Scene {
RoomId : string;
sharedUserPosition(data : []): void;
//hook preload scene
preload(): void {
+ this.load.image(Textures.Rock, 'resources/objects/rockSprite.png');
this.load.image('tiles', 'maps/tiles.png');
this.load.tilemapTiledJSON('map', 'maps/map2.json');
this.load.spritesheet('player',
import {CameraManager, CameraManagerInterface} from "./CameraManager";
import {RESOLUTION} from "../../Enum/EnvironmentVariable";
import {Player} from "../Player/Player";
-import {GameScene, GameSceneInterface} from "./GameScene";
-import {UserInputManager} from "../UserInput/UserInputManager";
+import {Rock} from "../Rock/Rock";
+import {GameSceneInterface} from "./GameScene";
+import {UserInputEvent, UserInputManager} from "../UserInput/UserInputManager";
export interface MapManagerInterface {
Map: Phaser.Tilemaps.Tilemap;
startX = (window.innerWidth / 2) / RESOLUTION;
startY = (window.innerHeight / 2) / RESOLUTION;
userInputManager: UserInputManager;
+ private rock: Rock;
constructor(scene: GameSceneInterface){
this.Scene = scene;
this
);
this.CurrentPlayer.initAnimation();
+ this.rock = new Rock(
+ this.Scene,
+ 100,
+ 300,
+ );
+ //this.rock.set()
}
update() : void {
let activeEvents = this.userInputManager.getEventListForGameTick();
this.CurrentPlayer.move(activeEvents);
+
+ /*if (activeEvents.get(UserInputEvent.Interact)) {
+
+ }*/
}
}
\ No newline at end of file
--- /dev/null
+import {GameSceneInterface, Textures} from "../Game/GameScene";
+import {CameraManagerInterface} from "../Game/CameraManager";
+import {MapManagerInterface} from "../Game/MapManager";
+
+export class Rock extends Phaser.GameObjects.Image {
+ private isMoving: boolean;
+
+ constructor(
+ Scene : GameSceneInterface,
+ x : number,
+ y : number,
+ ) {
+ super(Scene, x, y, Textures.Rock);
+ Scene.add.existing(this);
+ this.isMoving = false;
+ }
+
+ push() {
+ console.log("the rock is pushed!")
+ }
+
+ move() {
+ if(!this.isMoving) {
+ return;
+ }
+ }
+
+}
\ No newline at end of file
MoveRight,
MoveDown,
SpeedUp,
+ Interact,
}
//we cannot the map structure so we have to create a replacment
{keyCode: Phaser.Input.Keyboard.KeyCodes.RIGHT, event: UserInputEvent.MoveRight, keyInstance: null},
{keyCode: Phaser.Input.Keyboard.KeyCodes.SHIFT, event: UserInputEvent.SpeedUp, keyInstance: null},
+
+ {keyCode: Phaser.Input.Keyboard.KeyCodes.E, event: UserInputEvent.Interact, keyInstance: null},
];
constructor(Scene : GameSceneInterface) {
parent: "game",
scene: gameManager.GameScenes,
zoom: RESOLUTION,
+ physics: {
+ default: 'impact'
+ },
};
let game = new Phaser.Game(config);