1     /**
2         The ApplicationManager is used to manage the application itself.
3         @author <a href="mailto:matthewcasperson@gmail.com">Matthew Casperson</a>
4         @class
5     */
6     function ApplicationManager()
7 {
8 this.canvasWidth = 0;
9 this.canvasHeight = 0;
10 11 /** 12 Initialises this object 13 @param canvasWidth The width of the canvas 14 @param canvasHeight The height of the canvas 15 @return A reference to the initialised object 16 17 */ 18 this.startupApplicationManager = function(canvasWidth, canvasHeight)
19 {
20 g_ApplicationManager = this;
21 this.canvasWidth = canvasWidth;
22 this.canvasHeight = canvasHeight;
23 24 this.openMainMenu();
25 26 return this;
27 }
28 29 this.startLevel = function()
30 {
31 g_GameObjectManager.shutdownAll();
32 this.level = new Level().startupLevel(this.canvasWidth, this.canvasHeight);
33 this.background3 = new RepeatingGameObject().startupRepeatingGameObject(g_ResourceManager.background2, 0, 100, 3, 600, 320, 0.75);
34 this.background2 = new RepeatingGameObject().startupRepeatingGameObject(g_ResourceManager.background1, 0, 100, 2, 600, 320, 0.5);
35 this.background = new RepeatingGameObject().startupRepeatingGameObject(g_ResourceManager.background0, 0, 0, 1, 600, 320, 0.25);
36 g_player = new Player().startupPlayer(this.level);
37 this.updateScore();
38 }
39 40 this.openMainMenu = function()
41 {
42 g_GameObjectManager.shutdownAll();
43 g_GameObjectManager.xScroll = 0;
44 g_GameObjectManager.yScroll = 0;
45 g_score = 0;
46 this.mainMenu = new MainMenu().startupMainMenu();
47 }
48 49 this.updateScore = function()
50 {
51 var score = document.getElementById("Score");
52 score.innerHTML = String(g_score);
53 }
54 }
Top