-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
44 lines (38 loc) · 1.25 KB
/
Copy pathmain.ts
File metadata and controls
44 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import 'phaser';
import { GameConstants } from './GameConstants';
import { Scene } from './Scene';
import { StartScene } from './StartScene';
document.body.style.margin = '0';
document.body.style.padding = '0';
document.body.style.overflow = 'hidden';
document.body.style.backgroundColor = '#000000';
document.addEventListener('contextmenu', event => event.preventDefault());
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
backgroundColor: '#000000',
scene: [ StartScene, Scene ],
scale: {
mode: Phaser.Scale.RESIZE,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
physics: {
default: 'arcade',
arcade: {
debug: false,
// debugShowVelocity: true,
x: 0,
y: 0,
width: GameConstants.boundaryWidth,
height: GameConstants.boundaryHeight,
}
}
};
const game = new Phaser.Game(config);
if ('serviceWorker' in navigator) {
window.addEventListener('load', async () => {
const registration = await navigator.serviceWorker.register('/service-worker.js');
console.log('ServiceWorker registration successful with scope: ', registration.scope);
});
}