Skip to content

Commit a525a89

Browse files
committed
WIP refactoring
1 parent 43552f4 commit a525a89

File tree

10 files changed

+59
-27
lines changed

10 files changed

+59
-27
lines changed

.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"root": true,
33
"parser": "@typescript-eslint/parser",
4+
"env": {
5+
"browser": true,
6+
"es6": true,
7+
"node": true
8+
},
49
"plugins": [
510
"@typescript-eslint",
611
"jsdoc"

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
"lodash": "^4.17.20",
2727
"phaser": "~3.52.0",
2828
"protobufjs": "^6.10.2",
29-
"rhea": "^1.0.24"
29+
"rhea": "^1.0.24",
30+
"uuid": "^8.3.2"
3031
},
3132
"devDependencies": {
3233
"@types/html-webpack-plugin": "^3.2.4",
3334
"@types/lodash": "^4.14.168",
35+
"@types/uuid": "^8.3.0",
3436
"@typescript-eslint/eslint-plugin": "^4.15.1",
3537
"@typescript-eslint/parser": "^4.15.1",
3638
"browser-sync": "^2.26.14",

src/game.ts renamed to src/Game.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export default class Game extends Phaser.Game {
99
* Construct by calling the parent constructor for Phaser.Game with our config
1010
*/
1111
constructor() {
12-
super(config);
12+
super(config.PHASER_GAME_CONFIG);
1313
}
1414
}

src/assets/images/spacepod.png

1.55 KB
Loading

src/config.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import 'phaser';
2-
import PreloadScene from './scenes/preloadScene';
3-
import MenuScene from './scenes/menuScene';
4-
import MainScene from './scenes/mainScene';
2+
import PreloadScene from './scenes/PreloadScene';
3+
import MenuScene from './scenes/MenuScene';
4+
import MainScene from './scenes/MainScene';
55

66
const config = {
7-
type : Phaser.WEBGL,
8-
backgroundColor: '#ffffff',
9-
scale : {
10-
parent: 'phaser-game',
11-
mode : Phaser.Scale.RESIZE,
12-
},
13-
physics: {
14-
default: 'arcade',
15-
arcade : {
16-
gravity: { y: 200 },
7+
// Network config
8+
BROKER_ENDPOINT : '10.88.0.21',
9+
FORCE_MULTIPLIER: 200,
10+
11+
// Phaser config object to pass when creating the game
12+
PHASER_GAME_CONFIG: {
13+
type : Phaser.WEBGL,
14+
backgroundColor: '#ffffff',
15+
scale : {
16+
parent: 'phaser-game',
17+
mode : Phaser.Scale.RESIZE,
18+
},
19+
physics: {
20+
default: 'arcade',
21+
arcade : {
22+
debug: true,
23+
},
1724
},
25+
scene: [PreloadScene, MenuScene, MainScene],
1826
},
19-
scene: [PreloadScene, MenuScene, MainScene],
2027
};
2128

2229
export default config;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'phaser';
2-
import Game from './game';
2+
import Game from './Game';
33

44
window.addEventListener('load', () => {
55
// Launch the game once the page loads
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
import config from '../config';
2+
import { v4 as uuidv4 } from 'uuid';
3+
14
/**
25
* MainScene is the main scene of the game where game play happens
36
*/
47
export default class MainScene extends Phaser.Scene {
5-
private tickNum:number; // TODO: remove this, just and example to see the game loop running
8+
private players:any; // TODO: Define the players Type
9+
private myuuid:string;
10+
private player_uuid:string;
11+
private force_multiplier:number;
612

713
/**
814
* construct passing the unique key to the game instance
915
*/
1016
constructor() {
1117
super({ key: 'MainScene' });
12-
this.tickNum = 0;
18+
19+
// Initialize properties
20+
this.players = {};
21+
this.myuuid = uuidv4();
22+
this.player_uuid = '';
23+
this.force_multiplier = config.FORCE_MULTIPLIER;
1324
}
1425

1526
/**
@@ -35,12 +46,7 @@ export default class MainScene extends Phaser.Scene {
3546
/**
3647
* Main game loop
3748
*/
38-
update():void {
39-
this.tickNum++;
40-
41-
if (this.tickNum % 100 === 0) {
42-
// TODO: remove this, just an example to see the main game loop updating
43-
console.log('ticks:', this.tickNum);
44-
}
45-
}
49+
// update():void {
50+
//
51+
// }
4652
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class PreloadScene extends Phaser.Scene {
2020

2121
// Load images
2222
this.load.image('starfield', 'images/starfield.jpg');
23+
this.load.image('spacepod', 'images/spacepod.png');
2324

2425
// Load audio
2526
this.load.audio('gameplay_track_1', [

0 commit comments

Comments
 (0)