-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
56 lines (41 loc) · 1.24 KB
/
main.js
File metadata and controls
56 lines (41 loc) · 1.24 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
// game resources
var g_resources = [];
var jsApp = {
/* --- Initialize the jsApp --- */
onload: function() {
// init the video
if (!me.video.init('jsapp', 640, 480, false, 1.0)) {
alert("Sorry but your browser does not support html 5 canvas.");
return;
}
// initialize the "audio"
me.audio.init("mp3,ogg");
// set all resources to be loaded
me.loader.onload = this.loaded.bind(this);
// set all resources to be loaded
me.loader.preload(g_resources);
// load everything & display a loading screen
me.state.change(me.state.LOADING);
},
/* --- callback when everything is loaded --- */
loaded: function() {
// set the "Play/Ingame" Screen Object
me.state.set(me.state.PLAY, new PlayScreen());
// start the game
me.state.change(me.state.PLAY);
}
};
// jsApp
/* the in game stuff*/
var PlayScreen = me.ScreenObject.extend({
onResetEvent: function() {
// stuff to reset on state change
},
/* --- action to perform when game is finished (state change) --- */
onDestroyEvent: function() {
}
});
//bootstrap :)
window.onReady(function() {
jsApp.onload();
});