-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.js
89 lines (80 loc) · 2.9 KB
/
System.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function System()
{
var self = this;
self.fullscreen = false;
self.height = 600;
self.width = 800;
self.debug = false;
self.collision = false;
self.lights = true;
self.logging = true;
self.lightEntityInteraction = true;
self.designMode = false;
self.browser = BrowserDetect.browser;
self.OS = BrowserDetect.OS;
self.pauseWorld = true;
self.particleLevel = 5;
self.maxParticleLevel = 5;
self.cameraX = 1024;
self.cameraY = 1024;
self.techno_speed = 2;
this.update = function()
{
self.checkScreenSizeChange();
self.systemKeyCheck();
self.updateGameState();
}
this.updateGameState = function()
{
if(gm.guiMode){self.pauseWorld = true;} else {self.pauseWorld = false;}
}
this.systemKeyCheck = function()
{
if(input.key['f2'] == 2){self.debug = !self.debug;}
if(input.key['f4'] == 2){self.collision = !self.collision;}
if(input.key['f7'] == 2){self.lights = !self.lights;}
if(input.key['f8'] == 2){self.lightEntityInteraction = !self.lightEntityInteraction;}
if(input.key['f9'] == 2){self.designMode = !self.designMode;}
if(input.key['l'] == 2){ self.techno_speed += self.techno_speed == 20 ? 0 : 1; }
if(input.key['k'] == 2){ self.techno_speed -= self.techno_speed == 1 ? 0 : 1; }
if(!self.designMode){
if(input.key['0'] == 2){lighting.resChange = true; lighting.resolution++;}
if(input.key['9'] == 2){lighting.resChange = true; lighting.resolution -= lighting.resolution - 1 > 0 ? 1 : 0;}
if(input.key['8'] == 2){map.checkpoint.moveEntityToActiveCheckpoint(world.player);}
if(input.key['7'] == 2){ if(asset.allAssetsLoaded){asset.playRandomBGMFromMapList();} else {system.log('All assets not loaded. Not playing random song.');} }
if(input.key['6'] == 2){ g.get('move')('player', 500, 0); }
}
}
this.log = function(out)
{
if(self.logging) {
console.log(out);
}
}
this.initSystemWindow = function()
{
self.log("System Dimensions: " + self.width + " x " + self.height);
document.write('<canvas id="canvas" width="' + self.width + '" height="' + self.height + '"></canvas>');
self.initializeCanvas();
}
this.initializeCanvas = function()
{
system.log("Initializing 2d canvas context...");
_canvas = document.getElementById('canvas');
canvas = _canvas.getContext('2d');
}
this.checkScreenSizeChange = function()
{
if(self.width != window.innerWidth || self.height != window.innerHeight){ self.resize_canvas(); }
}
this.resize_canvas = function()
{
_canvas.height = self.height = window.innerHeight < 1 ? 600 : window.innerHeight;
_canvas.width = self.width = window.innerWidth < 1 ? 800 : window.innerWidth;
canvas = _canvas.getContext('2d');
lighting.resChange = true;
self.log("Resizing Canvas to " + self.width + " x " + self.height);
}
self.log("Constructing System...");
self.log("User Agent: " + BrowserDetect.browser + " v." + BrowserDetect.version + " Operating System: " + BrowserDetect.OS);
}