-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
195 lines (164 loc) · 5.84 KB
/
index.html
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html>
<head>
<title>The Everything Building</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta property="og:url" content="http://oletus.github.io/elevator/">
<meta property="og:title" content="The Everything Building">
<meta property="og:image" content="http://oletus.github.io/elevator/ogimage2.png">
<!-- output -->
<script src="src/lib/hsl.js"></script>
<script src="src/sprite.js"></script>
<script src="src/animatedsprite.js"></script>
<script src="src/lib/howler.core.js"></script>
<script src="src/audio.js"></script>
<script src="src/commonui.js"></script>
<script>
GJS.Audio.defaultExtensions = ['ogg', 'mp3'];
GJS.Audio.audioPath = 'assets/audio/';
</script>
<script src="src/canvasresizer.js"></script>
<script src="src/loadingbar.js"></script>
<script src="src/particle.js"></script>
<!--<script src="src/canvasui.js"></script>-->
<script src="src/lib/dat.gui.js"></script>
<script src="src/gameparameters.js"></script>
<!-- input -->
<script src="src/lib/mousetrap.js"></script>
<script src="src/lib/mousetrap-global-bind.js"></script>
<script src="src/gamepad.js"></script>
<script src="src/inputmapper.js"></script>
<script src="src/mainloop.js"></script>
<script src="src/util2d.js"></script>
<script src="src/utiljs.js"></script>
<script src="src/tilemap.js"></script>
<script src="src/monospacebitmapfont.js"></script>
<script src="src/elevator.js"></script>
<script src="src/level.js"></script>
<script src="src/character.js"></script>
<script src="src/gamedata.js"></script>
<script src="src/floor.js"></script>
<script>
'use strict';
var Game = function(resizer) {
this.canvas = resizer.getCanvas();
this.realCtx = this.canvas.getContext('2d');
/*this.canvasUI = new CanvasUI({
element: this.canvas,
getCanvasPositionFromEvent: function(event) {
return resizer.getCanvasPosition(event);
}
});*/
this.time = 0;
this.level = new Level();
this.input = new InputMapper(this, 1);
this.input.addListener(Gamepad.BUTTONS.UP_OR_ANALOG_UP, ['up', 'w'], this.upPress, this.upRelease);
this.input.addListener(Gamepad.BUTTONS.DOWN_OR_ANALOG_DOWN, ['down', 's'], this.downPress, this.downRelease);
this.input.addListener(Gamepad.BUTTONS.START, ['enter', 'space'], this.startPress, this.startRelease);
};
Game.prototype.render = function(ctx) {
// CanvasResizer passes a wrapped 2D context to use here when run in FIXED_COORDINATE_SYSTEM mode,
// where ctx.canvas.width/height are set to the coordinate system width/height.
// Otherwise the context initialized here is used.
if (ctx === undefined) {
ctx = this.realCtx;
}
ctx.textBaseline = 'top';
this.level.render(ctx);
return ctx;
};
Game.prototype.isWaitingStartPress = function() {
if (this.level.stateTime < 0.5) {
return false;
}
return this.level.state !== Level.State.IN_PROGRESS;
};
Game.prototype.startPress = function(playerNumber) {
if (!this.isWaitingStartPress()) {
return;
}
if (this.level.state === Level.State.FAIL) {
this.level = new Level();
} else if (this.level.state === Level.State.TITLE_SCREEN) {
this.level.goToState(Level.State.IN_PROGRESS);
}
};
Game.prototype.startRelease = function(playerNumber) {
};
Game.prototype.downPress = function(playerNumber) {
this.level.downPress(playerNumber);
};
Game.prototype.upPress = function(playerNumber) {
this.level.upPress(playerNumber);
};
Game.prototype.downRelease = function(playerNumber) {
this.level.downRelease(playerNumber);
};
Game.prototype.upRelease = function(playerNumber) {
this.level.upRelease(playerNumber);
};
Game.prototype.canvasPress = function(pos) {
if (this.isWaitingStartPress) {
this.startPress();
}
this.level.canvasPress(pos);
};
Game.prototype.canvasRelease = function(pos) {
if (this.isWaitingStartPress) {
this.startPress();
}
this.level.canvasRelease(pos);
};
Game.prototype.canvasMove = function(pos) {
};
Game.prototype.update = function(deltaTime) {
this.time += deltaTime;
this.level.update(deltaTime);
this.input.update();
GJS.Audio.muteAll(Game.parameters.get('muteAudio'));
};
var DEV_MODE = (window.location.href.indexOf("?devMode") != -1);
var blackBitmapFont = new MonospaceBitmapFont({color: 'black'});
var whiteBitmapFont = new MonospaceBitmapFont({color: 'white'});
var bigBitmapFont = new MonospaceBitmapFont({spriteSrc: 'bitmapfont-medium.png', characterWidth: 8, characterHeight: 13});
Game.music = new GJS.Audio('elevator_music');
Game.gameOverSound = new GJS.Audio('gameover');
Game.parameters = new GameParameters({
'initialSpawnInterval': {initial: 4, min: 0.5, max: 10},
'spawnIntervalRandomness': {initial: 1, min: 0, max: 2},
'floorCapacity': {initial: 22, min: 3, max: 50},
'bandUnionDuration': {initial: 0.5, min: 0.1, max: 2},
'muteAudio': false
});
var game;
var resizer;
var coordinatesDown = [
];
var coordinateIndices = {
mouse: -1
};
window['start'] = function() {
var DEBUG_MAIN_LOOP = DEV_MODE && true; // Set to true to allow fast-forwarding main loop with 'f'
Game.parameters.set('muteAudio', (DEV_MODE && true)); // Set to true if sounds annoy developers
if (DEV_MODE) {
Game.parameters.initGUI();
}
GJS.commonUI.createUI({
parent: document.body,
fullscreenElement: document.body,
twitterAccount: 'Oletus',
fillStyle: '#ffffff',
opacity: 0.4,
scale: 0.8
});
resizer = new CanvasResizer({mode: CanvasResizer.Mode.MINIMUM_HEIGHT, width: 192, height: 312});
game = new Game(resizer);
resizer.createPointerEventListener(game, true);
startMainLoop([resizer, game, new LoadingBar(), resizer.pixelator()], {debugMode: DEBUG_MAIN_LOOP});
};
</script>
</head>
<body onload="start()" style="background: black;">
</body>
</html>