diff --git a/src/format.h b/src/format.h index 25165319..e5c578e2 100644 --- a/src/format.h +++ b/src/format.h @@ -818,9 +818,7 @@ namespace TR { uint16 puzzleSet; } extra; - Level(const char *name, bool demo) { - Stream stream(name); - + Level(Stream &stream, bool demo) { tiles4 = NULL; Tile8 *tiles8 = NULL; cluts = NULL; diff --git a/src/game.h b/src/game.h index 034acd42..d9e7abd6 100644 --- a/src/game.h +++ b/src/game.h @@ -10,23 +10,34 @@ namespace Game { Level *level; - void init() { - Core::init(); - //level = new Level("LEVEL2_DEMO.PHD", true, false); - //level = new Level("GYM.PSX", false, true); - //level = new Level("LEVEL3A.PHD", false, false); - level = new Level("LEVEL2.PSX", false, false); + void startLevel(Stream &stream, bool demo, bool home) { + delete level; + level = new Level(stream, demo, home); #ifndef __EMSCRIPTEN__ //Sound::play(Sound::openWAD("05_Lara's_Themes.wav"), 1, 1, 0); Sound::play(new Stream("05.ogg"), vec3(0.0f), 1, 1, Sound::Flags::LOOP); //Sound::play(new Stream("03.mp3"), 1, 1, 0); - #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() { delete level; - Core::free(); } diff --git a/src/level.h b/src/level.h index cbca4623..34cd529a 100644 --- a/src/level.h +++ b/src/level.h @@ -216,7 +216,7 @@ struct Level { } } 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 Debug::init(); #endif diff --git a/src/platform/web/index.html b/src/platform/web/index.html index 3c468c9e..a04c2480 100644 --- a/src/platform/web/index.html +++ b/src/platform/web/index.html @@ -4,7 +4,6 @@ Starting...
- OpenLara on github
controls:
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)
gamepad: PSX controls on XBox controller
FullScreen: Alt + Enter
+ + + + + (.PHD, .PSX) + +

+ OpenLara on github
+ controls:
+ 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)
+ gamepad: PSX controls on XBox controller
+ FullScreen: Alt + Enter +
\ No newline at end of file diff --git a/src/platform/web/main.cpp b/src/platform/web/main.cpp index 297a1cf7..37ec7630 100644 --- a/src/platform/web/main.cpp +++ b/src/platform/web/main.cpp @@ -16,6 +16,11 @@ extern "C" { void EMSCRIPTEN_KEEPALIVE snd_fill(Sound::Frame *frames, int 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) {