-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
74 lines (58 loc) · 2.38 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
import * as me from 'melonjs';
import resources from './resources.js';
/**
*
* Initialize the application
*/
export default function onload() {
// init the video
if (!me.video.init(800, 600, {parent : "screen", scaleMethod : "flex-width", renderer : me.video.WEBGL, preferWebGL1 : false, depthTest: "z-buffer", subPixel : false})) {
alert("Your browser does not support HTML5 canvas.");
return;
}
// // register the debug plugin
// me.plugin.register(DebugPanelPlugin, "debugPanel");
// initialize the "sound engine"
me.audio.init("mp3,ogg");
// allow cross-origin for image/texture loading
me.loader.crossOrigin = "anonymous";
// set all ressources to be loaded
me.loader.preload(resources, () => {
// set the "Play/Ingame" Screen Object
me.state.set(me.state.PLAY, new PlayScreen());
// set the fade transition effect
// me.state.transition("fade", "#FFFFFF", 250);
// register our objects entity in the object pool
// me.pool.register("mainPlayer", PlayerEntity);
// me.pool.register("SlimeEntity", SlimeEnemyEntity);
// me.pool.register("FlyEntity", FlyEnemyEntity);
// me.pool.register("CoinEntity", CoinEntity, true);
// load the texture atlas file
// this will be used by renderable object later
// game.texture = new me.TextureAtlas(
// me.loader.getJSON("texture"),
// me.loader.getImage("texture")
// );
// // add some keyboard shortcuts
// me.event.on(me.event.KEYDOWN, (action, keyCode /*, edge */) => {
// // change global volume setting
// if (keyCode === me.input.KEY.PLUS) {
// // increase volume
// me.audio.setVolume(me.audio.getVolume()+0.1);
// } else if (keyCode === me.input.KEY.MINUS) {
// // decrease volume
// me.audio.setVolume(me.audio.getVolume()-0.1);
// }
// // toggle fullscreen on/off
// if (keyCode === me.input.KEY.F) {
// if (!me.device.isFullscreen()) {
// me.device.requestFullscreen();
// } else {
// me.device.exitFullscreen();
// }
// }
// });
// switch to PLAY state
me.state.change(me.state.PLAY);
});
}