-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
67 lines (56 loc) · 1.76 KB
/
script.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**@type {import("../typings/phaser")} */
import { PreloadScene } from "./PreloadScene.js";
import { PlayScene } from "./PlayScene.js";
const play_fullscreenBtn = document.getElementById("play_fullscreenBtn");
play_fullscreenBtn.addEventListener('click', toggleFullscreen);
function toggleFullscreen(){
if(!document.fullscreenElement){
document.documentElement.requestFullscreen();
screen.orientation.lock("landscape");
}else if(document.exitFullscreen){
document.exitFullscreen();
}
}
const GAME_WIDTH = 1024;
const GAME_HEIGHT = 576;
const ZOOM_FACTOR = 2
const SHARED_CONFIG = {
width: GAME_WIDTH,
height: GAME_HEIGHT,
zoomFactor: ZOOM_FACTOR,
topLeft: {
x: ( GAME_WIDTH - (GAME_WIDTH/ZOOM_FACTOR) ) / 2,
y: ( GAME_HEIGHT - (GAME_HEIGHT/ZOOM_FACTOR) ) / 2,
},
topRight: {
x: ( ( GAME_WIDTH - (GAME_WIDTH/ZOOM_FACTOR) ) / 2 ) + (GAME_WIDTH/ZOOM_FACTOR),
y: ( GAME_HEIGHT - (GAME_HEIGHT/ZOOM_FACTOR) ) / 2,
},
bottomRight: {
x: ( ( GAME_WIDTH - (GAME_WIDTH/ZOOM_FACTOR) ) / 2 ) + (GAME_WIDTH/ZOOM_FACTOR),
y: ( (GAME_HEIGHT - (GAME_HEIGHT/ZOOM_FACTOR) ) / 2 ) + (GAME_HEIGHT/ZOOM_FACTOR),
},
debug: false
};
const config= {
type: Phaser.AUTO,
...SHARED_CONFIG,
parent: "gameWrapper",
scale: {
mode: Phaser.Scale.Fit,
//autoCenter: Phaser.Scale.CENTER_BOTH,
},
pixelArt: true,
physics:{
default: 'arcade',
arcade:{
debug: SHARED_CONFIG.debug,
},
matter:{
debug: SHARED_CONFIG.debug,
},
},
scene: [new PreloadScene(SHARED_CONFIG),
new PlayScene(SHARED_CONFIG)],
};
const game = new Phaser.Game(config);