From 241cbd720ab5e3062381b16d7d5724cef8406c20 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Sat, 11 Apr 2020 18:17:36 +0200 Subject: [PATCH] added a rock --- front/dist/resources/objects/rockSprite.png | Bin 0 -> 3659 bytes front/src/Phaser/Game/GameScene.ts | 5 ++++ front/src/Phaser/Game/MapManager.ts | 16 ++++++++-- front/src/Phaser/Rock/Rock.ts | 28 ++++++++++++++++++ .../src/Phaser/UserInput/UserInputManager.ts | 3 ++ front/src/index.ts | 3 ++ 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 front/dist/resources/objects/rockSprite.png create mode 100644 front/src/Phaser/Rock/Rock.ts diff --git a/front/dist/resources/objects/rockSprite.png b/front/dist/resources/objects/rockSprite.png new file mode 100644 index 0000000000000000000000000000000000000000..40820abd0ee4564498e779462128d879c48dae1e GIT binary patch literal 3659 zcmb_fhgXx?)4p#Cgqk4IO9HG)i4<25xUx6^Kyw)v{$&`E&GnVV`L<051)a1x0E#Kp9lvH#tB@oyI_Wvot9cDI>tdPj-Fj@rK6r?;6vm3K13v|PFyLq}(N>Ie9 zhf(F+uwxgCY|Q6$bh`^8^EoH!)BVrRzIe2|P8ie3Y7Xrpqhm+KC_o$drLX_J@Gb0L z@C#>sXddu?NTQM<1}GgkSv_DG)#h9h8wt6Oem%Xp!(O3u>?%d_Ka}!`+F&c#b5?w> zAR)kHrcG4)P2Gt#4>;*M6Hq|mp1`&UhT?y4A9bdH_ZSeWfL-EOzkIp&rD?89>_$Lw z&excAE^CNmsUKR>xZ=0`E!8F=Cnx$!nP8n<#~FCg15oSy(Plw`T~5sRTf@+uptz>% zc(B5+n;BwF&_la&%>3jNd_*m%RjUnRF{t(F>5Cg9|K5Fdoy(Wh-YN;*$pbP?+ka@S z00J%cM~6fCzTNxhqao6DJUMpt``G&818xG|Ex zM1hf2eL+JT^?}-ozFWjJ)qF*UhgtaeA^?j;bOiy;s-7+UvC|u#33a7SFG?P%0bE>c z*y7iDZIJC8b%?Eb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+UD)Q$@RdIgSOVi2i$4@0|kzR_y7O^ literal 0 HcmV?d00001 diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index d3abfd1..faf1961 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1,6 +1,10 @@ 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; @@ -18,6 +22,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ //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', diff --git a/front/src/Phaser/Game/MapManager.ts b/front/src/Phaser/Game/MapManager.ts index 3f8521d..e6a82dc 100644 --- a/front/src/Phaser/Game/MapManager.ts +++ b/front/src/Phaser/Game/MapManager.ts @@ -1,8 +1,9 @@ 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; @@ -21,6 +22,7 @@ export class MapManager implements MapManagerInterface{ startX = (window.innerWidth / 2) / RESOLUTION; startY = (window.innerHeight / 2) / RESOLUTION; userInputManager: UserInputManager; + private rock: Rock; constructor(scene: GameSceneInterface){ this.Scene = scene; @@ -44,11 +46,21 @@ export class MapManager implements MapManagerInterface{ 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 diff --git a/front/src/Phaser/Rock/Rock.ts b/front/src/Phaser/Rock/Rock.ts new file mode 100644 index 0000000..8892f10 --- /dev/null +++ b/front/src/Phaser/Rock/Rock.ts @@ -0,0 +1,28 @@ +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 diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index c362bd9..e05eccb 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -13,6 +13,7 @@ export enum UserInputEvent { MoveRight, MoveDown, SpeedUp, + Interact, } //we cannot the map structure so we have to create a replacment @@ -43,6 +44,8 @@ export class UserInputManager { {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) { diff --git a/front/src/index.ts b/front/src/index.ts index 650fd52..f74c9fa 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -12,6 +12,9 @@ const config: GameConfig = { parent: "game", scene: gameManager.GameScenes, zoom: RESOLUTION, + physics: { + default: 'impact' + }, }; let game = new Phaser.Game(config); -- 2.25.1