-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.js
More file actions
59 lines (47 loc) · 1.5 KB
/
game.js
File metadata and controls
59 lines (47 loc) · 1.5 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
let config = {
width: 480,
height: 270,
renderer: Phaser.AUTO,
antialias: false,
multiTexture: true,
state: {
preload: load.preload,
create: create,
update: update
}
}
let game = new Phaser.Game(config);
// Audio should be apart of each characters
// Each character needs to keep track of when the audio starts, stops, and is pause/resume
function create() {
// Start the simple physics
game.physics.startSystem(Phaser.Physics.ARCADE);
// Configure resolution and scale
screen.displayConfiguration();
// Setup audio
audio.prepAudio();
// Setup controls
controller.prepController();
controller.player1Controls();
controller.player2Controls();
controller.musicControls();
// Create groups
groups.createGroups();
// Display the title screen
screen.displayTitleScreen(displayScreensGroup);
// Start background music and on resume and pause callbacks
//audio.startMusic(); // Instead wait for prepaudio to finish
}
function update() {
// Starts game from title, starts game from reset, and detects game over
if (isGameOver && !isGameOverScreen) {
state.gameOver();
} else if (resetGameButton.isDown) {
state.startGameCheck();
}
// Colliders are loaded for overlap and physics collision
collisions.collide();
collisions.overlap();
// Accept controller input for players, checks every frame for keydowns
controller.controlAllPlayers(player1Group, player2Group);
}