-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsketch.js
More file actions
62 lines (54 loc) · 1.13 KB
/
sketch.js
File metadata and controls
62 lines (54 loc) · 1.13 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
60
61
62
// Daniel Shiffman
// http://codingrainbow.com
// http://patreon.com/codingrainbow
// Code for: https://youtu.be/hacZU523FyM
var laserSoundEffect = [];
var explosionSoundEffects = [];
var world;
var uimanager;
var localplayerentity;
function playSoundEffect(sound) {
if (!sound.isPlaying()) {
sound.play();
}
}
function preload() {
for (var i = 0; i < 3; i++) {
laserSoundEffect[i] = loadSound('audio/pew-' + i + '.mp3');
}
for (var i = 0; i < 3; i++) {
explosionSoundEffects[i] = loadSound('audio/explosion-' + i + '.mp3');
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
world = new World(2000, 2000, {
left: -640,
right: 640,
bottom: -360,
top: 360,
near: 0,
far: 500
});
uimanager = new UIManager(world, {
left: 160,
right: 160,
bottom: 90,
top: 90,
near: 0,
far: 500
});
world.initialize();
localplayerentity = world.getLocalPlayer().getEntity();
uimanager.create(Hud);
uimanager.create(PlayerControls);
}
function draw() {
push();
background(0);
world.update();
uimanager.update();
world.render();
uimanager.render();
pop();
}