mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-21 12:21:33 +02:00
#15 WebGL level selector
This commit is contained in:
@@ -818,9 +818,7 @@ namespace TR {
|
|||||||
uint16 puzzleSet;
|
uint16 puzzleSet;
|
||||||
} extra;
|
} extra;
|
||||||
|
|
||||||
Level(const char *name, bool demo) {
|
Level(Stream &stream, bool demo) {
|
||||||
Stream stream(name);
|
|
||||||
|
|
||||||
tiles4 = NULL;
|
tiles4 = NULL;
|
||||||
Tile8 *tiles8 = NULL;
|
Tile8 *tiles8 = NULL;
|
||||||
cluts = NULL;
|
cluts = NULL;
|
||||||
|
25
src/game.h
25
src/game.h
@@ -10,12 +10,9 @@
|
|||||||
namespace Game {
|
namespace Game {
|
||||||
Level *level;
|
Level *level;
|
||||||
|
|
||||||
void init() {
|
void startLevel(Stream &stream, bool demo, bool home) {
|
||||||
Core::init();
|
delete level;
|
||||||
//level = new Level("LEVEL2_DEMO.PHD", true, false);
|
level = new Level(stream, demo, home);
|
||||||
//level = new Level("GYM.PSX", false, true);
|
|
||||||
//level = new Level("LEVEL3A.PHD", false, false);
|
|
||||||
level = new Level("LEVEL2.PSX", false, false);
|
|
||||||
|
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
//Sound::play(Sound::openWAD("05_Lara's_Themes.wav"), 1, 1, 0);
|
//Sound::play(Sound::openWAD("05_Lara's_Themes.wav"), 1, 1, 0);
|
||||||
@@ -24,9 +21,23 @@ namespace Game {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startLevel(const char *name, bool demo, bool home) {
|
||||||
|
Stream stream(name);
|
||||||
|
startLevel(stream, demo, home);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
Core::init();
|
||||||
|
level = NULL;
|
||||||
|
|
||||||
|
//lstartLevel("LEVEL2_DEMO.PHD", true, false);
|
||||||
|
//lstartLevel("GYM.PSX", false, true);
|
||||||
|
//lstartLevel("LEVEL3A.PHD", false, false);
|
||||||
|
startLevel("LEVEL2.PSX", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
void free() {
|
void free() {
|
||||||
delete level;
|
delete level;
|
||||||
|
|
||||||
Core::free();
|
Core::free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -216,7 +216,7 @@ struct Level {
|
|||||||
}
|
}
|
||||||
} lightCache;
|
} lightCache;
|
||||||
*/
|
*/
|
||||||
Level(const char *name, bool demo, bool home) : level(name, demo), lara(NULL), time(0.0f) {
|
Level(Stream &stream, bool demo, bool home) : level(stream, demo), lara(NULL), time(0.0f) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
Debug::init();
|
Debug::init();
|
||||||
#endif
|
#endif
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<span id="status">Starting...</span>
|
<span id="status">Starting...</span>
|
||||||
<canvas id="canvas" width="854" height="480" oncontextmenu="event.preventDefault()"></canvas><br>
|
<canvas id="canvas" width="854" height="480" oncontextmenu="event.preventDefault()"></canvas><br>
|
||||||
<span id="info"><a target="_blank" href="https://github.com/XProger/OpenLara">OpenLara on github</a><br>controls:<br>keyboad: move - WASD / arrows, jump - Space, action - E/Ctrl, draw weapon - Q, change weapon - 1-4, walk - Shift, side steps - ZX/walk+direction, camera - MouseR)<br>gamepad: PSX controls on XBox controller<br>FullScreen: Alt + Enter</span>
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var statusElement = document.getElementById('status');
|
var statusElement = document.getElementById('status');
|
||||||
@@ -101,8 +100,31 @@
|
|||||||
return "Really want to quit the game?";
|
return "Really want to quit the game?";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function readLevel(event, home) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function(){
|
||||||
|
var size = reader.result.byteLength;
|
||||||
|
var data = Module._malloc(size);
|
||||||
|
Module.writeArrayToMemory(new Uint8Array(reader.result), data);
|
||||||
|
Module.ccall('game_level_load', 'null', ['number', 'number', 'number'], [data, size, home]);
|
||||||
|
};
|
||||||
|
reader.readAsArrayBuffer(event.target.files[0]);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<audio autoplay loop><source src="05.ogg" type="audio/ogg"></audio>
|
<audio autoplay loop><source src="05.ogg" type="audio/ogg"></audio>
|
||||||
|
|
||||||
|
<span id="info">
|
||||||
|
<input type="file" id="browseFile" style="display:none" accept=".phd,.psx" onchange="readLevel(event, document.getElementById('isHome').checked)" />
|
||||||
|
<!-- <label for="browseFile">Browse Level</label> -->
|
||||||
|
<input type="button" value="Browse Level" onclick="document.getElementById('browseFile').click();" /> (.PHD, .PSX)
|
||||||
|
<input type="checkbox" id="isHome"><label>alternative model (home suit, gold etc.)</label>
|
||||||
|
<br><br>
|
||||||
|
<a target="_blank" href="https://github.com/XProger/OpenLara">OpenLara on github</a><br>
|
||||||
|
controls:<br>
|
||||||
|
keyboad: move - WASD / arrows, jump - Space, action - E/Ctrl, draw weapon - Q, change weapon - 1-4, walk - Shift, side steps - ZX/walk+direction, camera - MouseR)<br>
|
||||||
|
gamepad: PSX controls on XBox controller<br>
|
||||||
|
FullScreen: Alt + Enter
|
||||||
|
</span>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@@ -16,6 +16,11 @@ extern "C" {
|
|||||||
void EMSCRIPTEN_KEEPALIVE snd_fill(Sound::Frame *frames, int count) {
|
void EMSCRIPTEN_KEEPALIVE snd_fill(Sound::Frame *frames, int count) {
|
||||||
Sound::fill(frames, count);
|
Sound::fill(frames, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EMSCRIPTEN_KEEPALIVE game_level_load(char *data, int size, int home) {
|
||||||
|
Stream stream(data, size);
|
||||||
|
Game::startLevel(stream, false, home);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InputKey joyToInputKey(int code) {
|
InputKey joyToInputKey(int code) {
|
||||||
|
Reference in New Issue
Block a user