The level number is now displayed on the next level screen.
This commit is contained in:
parent
b5c2fc3b5f
commit
bc0912e577
11 changed files with 84 additions and 46 deletions
|
|
@ -83,8 +83,13 @@
|
||||||
"frame_width": 1920,
|
"frame_width": 1920,
|
||||||
"frame_height": 1080
|
"frame_height": 1080
|
||||||
},
|
},
|
||||||
"test_story":
|
"intro_story":
|
||||||
{"path": "assets/stories/test_storyboard.png",
|
{"path": "assets/stories/intro_story.png",
|
||||||
|
"frame_width": 1280,
|
||||||
|
"frame_height": 720
|
||||||
|
},
|
||||||
|
"win_story":
|
||||||
|
{"path": "assets/stories/win_story.png",
|
||||||
"frame_width": 1280,
|
"frame_width": 1280,
|
||||||
"frame_height": 720
|
"frame_height": 720
|
||||||
}
|
}
|
||||||
|
|
@ -119,6 +124,6 @@
|
||||||
},
|
},
|
||||||
"game_play": {
|
"game_play": {
|
||||||
"levels_to_win": 4,
|
"levels_to_win": 4,
|
||||||
"help_text": "WASD moves\nQE rotates\nSpace attacks\nESC close\nRight-Click to heal\nClick on Ladders\nDev Tools:\nP: Debug\nZ: Mind Reader\nN: Next Level\nK: Die\nH/F1: Help\nF5: Screenshot\nReach Level 5 to Win\nAttack to Get Gud\nGet Hit to Get Tuff"
|
"help_text": "WASD moves\nQE rotates\nSpace attacks\nESC close\nRight-Click to heal\nClick on Ladders\nDev Tools:\nP: Debug\nZ: Mind Reader\nN: Next Level\nK: Die\nH/F1: Help\nF5: Screenshot\nExit Level 5 to Win\nAttack to Get Gud\nGet Hit to Get Tuff"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,10 @@
|
||||||
},
|
},
|
||||||
"NEXT_LEVEL": {
|
"NEXT_LEVEL": {
|
||||||
"layout": [
|
"layout": [
|
||||||
"[_|_|_|_|_|_]",
|
"[_]",
|
||||||
"[_|_|_|*%(200,100)buttons|_|_]"
|
"[_|_|_|*%(200,100)text|_|_]",
|
||||||
|
"[_|_|_|*%(200,200)buttons|_|_]",
|
||||||
|
"[_]"
|
||||||
],
|
],
|
||||||
"background": "next_level_scene",
|
"background": "next_level_scene",
|
||||||
"actors": [
|
"actors": [
|
||||||
|
|
@ -47,22 +49,11 @@
|
||||||
},
|
},
|
||||||
"STARTING": {
|
"STARTING": {
|
||||||
"layout": [
|
"layout": [
|
||||||
"[_|*%(200, 200)ag_bot|_|=*%(200,100)speech|_|_]",
|
"[_|_|_|_|_|_]",
|
||||||
"[_|_|_|*%(200,100)buttons|_|_]"
|
"[_|_|_|*%(200,100)buttons|_|_]"
|
||||||
],
|
],
|
||||||
"background": "starting_scene",
|
"background": "starting_scene",
|
||||||
"actors": [
|
"actors": [
|
||||||
{
|
|
||||||
"name": "ag_bot",
|
|
||||||
"sprite": "ag_bot",
|
|
||||||
"cell": "ag_bot",
|
|
||||||
"scale_x": 0.65,
|
|
||||||
"scale_y": 0.65,
|
|
||||||
"x": -40,
|
|
||||||
"y": 70,
|
|
||||||
"at_mid": false,
|
|
||||||
"flipped": false
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"fixtures": [
|
"fixtures": [
|
||||||
],
|
],
|
||||||
|
|
@ -70,7 +61,6 @@
|
||||||
"layout": [
|
"layout": [
|
||||||
"[_]",
|
"[_]",
|
||||||
"[_|=*%(300, 100)Start|_|_|_]",
|
"[_|=*%(300, 100)Start|_|_|_]",
|
||||||
"[_|=*%(300, 100)About|_|_|_]",
|
|
||||||
"[_|=*%(300, 100)Quit|_|_|_]",
|
"[_|=*%(300, 100)Quit|_|_|_]",
|
||||||
"[_]"
|
"[_]"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"intro_story":
|
"intro_story":
|
||||||
{"_type": "Storyboard",
|
{"_type": "Storyboard",
|
||||||
"image": "test_story",
|
"image": "intro_story",
|
||||||
"audio": "test_story",
|
"audio": "test_story",
|
||||||
"layout": [
|
"layout": [
|
||||||
"[a|b|c1]",
|
"[a|b|c1]",
|
||||||
|
|
@ -22,5 +22,19 @@
|
||||||
["00:13", "i","shake", "60"],
|
["00:13", "i","shake", "60"],
|
||||||
["00:14", "i","bounce", "60"]
|
["00:14", "i","bounce", "60"]
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"win_story":
|
||||||
|
{"_type": "Storyboard",
|
||||||
|
"image": "win_story",
|
||||||
|
"audio": "test_story",
|
||||||
|
"layout": [
|
||||||
|
"[a|b|c1]",
|
||||||
|
"[d|e|c2]",
|
||||||
|
"[g|h|i]"
|
||||||
|
],
|
||||||
|
"beats": [
|
||||||
|
["00:00", "a","pan", "60"],
|
||||||
|
["00:01", "b","shake", "30"]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
assets/stories/intro_story.png
Normal file
BIN
assets/stories/intro_story.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
assets/stories/win_story.png
Normal file
BIN
assets/stories/win_story.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
|
|
@ -31,7 +31,7 @@ namespace scene {
|
||||||
|
|
||||||
bool at_mid = config["at_mid"];
|
bool at_mid = config["at_mid"];
|
||||||
|
|
||||||
sf::Text text(*$ui.$font, "", 60);
|
sf::Text text(*$gui.$font, "", 60);
|
||||||
|
|
||||||
return {name, st, anim, cell, {scale_x, scale_y}, {x, y}, at_mid, flipped, nullptr, text};
|
return {name, st, anim, cell, {scale_x, scale_y}, {x, y}, at_mid, flipped, nullptr, text};
|
||||||
}
|
}
|
||||||
|
|
@ -60,12 +60,12 @@ namespace scene {
|
||||||
void Engine::init() {
|
void Engine::init() {
|
||||||
dbc::log($F("initialized scene with background {}", $scene.background));
|
dbc::log($F("initialized scene with background {}", $scene.background));
|
||||||
|
|
||||||
$ui.position(SCENE_VIEW_X, SCENE_VIEW_Y, SCENE_VIEW_WIDTH, SCENE_VIEW_HEIGHT);
|
$gui.position(SCENE_VIEW_X, SCENE_VIEW_Y, SCENE_VIEW_WIDTH, SCENE_VIEW_HEIGHT);
|
||||||
$ui.set<guecs::Background>($ui.MAIN, {$ui.$parser, guecs::THEME.TRANSPARENT});
|
$gui.set<guecs::Background>($gui.MAIN, {$gui.$parser, guecs::THEME.TRANSPARENT});
|
||||||
auto& background = $ui.get<guecs::Background>($ui.MAIN);
|
auto& background = $gui.get<guecs::Background>($gui.MAIN);
|
||||||
background.set_sprite($scene.background, true);
|
background.set_sprite($scene.background, true);
|
||||||
|
|
||||||
$ui.layout($layout);
|
$gui.layout($layout);
|
||||||
|
|
||||||
for(auto& actor : $actors) {
|
for(auto& actor : $actors) {
|
||||||
actor.pos = position_sprite(actor.st, actor.cell,
|
actor.pos = position_sprite(actor.st, actor.cell,
|
||||||
|
|
@ -76,6 +76,17 @@ namespace scene {
|
||||||
fixture.pos = position_sprite(fixture.st, fixture.cell,
|
fixture.pos = position_sprite(fixture.st, fixture.cell,
|
||||||
fixture.scale, fixture.at_mid, fixture.pos.x, fixture.pos.y);
|
fixture.scale, fixture.at_mid, fixture.pos.x, fixture.pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($gui.contains("text")) {
|
||||||
|
auto text_id = $gui.entity("text");
|
||||||
|
auto bg_color = guecs::THEME.DARK_DARK;
|
||||||
|
bg_color.a = 100;
|
||||||
|
// BUG: guecs should initialize anything added if it needs it
|
||||||
|
$gui.set<guecs::Rectangle>(text_id, {0, bg_color});
|
||||||
|
$gui.set<guecs::Text>(text_id, {L"", 55});
|
||||||
|
}
|
||||||
|
|
||||||
|
$gui.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::apply_effect(const std::string& actor, const std::string& shader) {
|
void Engine::apply_effect(const std::string& actor, const std::string& shader) {
|
||||||
|
|
@ -94,11 +105,11 @@ namespace scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Engine::mouse(float x, float y, guecs::Modifiers mods) {
|
bool Engine::mouse(float x, float y, guecs::Modifiers mods) {
|
||||||
return $ui.mouse(x, y, mods);
|
return $gui.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::render(sf::RenderTexture& view) {
|
void Engine::render(sf::RenderTexture& view) {
|
||||||
$ui.render(view);
|
$gui.render(view);
|
||||||
|
|
||||||
for(auto& fixture : $fixtures) {
|
for(auto& fixture : $fixtures) {
|
||||||
view.draw(*fixture.st.sprite, fixture.effect.get());
|
view.draw(*fixture.st.sprite, fixture.effect.get());
|
||||||
|
|
@ -110,7 +121,7 @@ namespace scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
$camera.render(view);
|
$camera.render(view);
|
||||||
if(DEBUG) $ui.debug_layout(view);
|
if(DEBUG) $gui.debug_layout(view);
|
||||||
|
|
||||||
// BUG: should I do this here or let the caller do it?
|
// BUG: should I do this here or let the caller do it?
|
||||||
view.display();
|
view.display();
|
||||||
|
|
@ -158,7 +169,7 @@ namespace scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Vector2f Engine::position_sprite(textures::SpriteTexture& st, const std::string& cell_name, sf::Vector2f scale, bool at_mid, float x_diff, float y_diff) {
|
sf::Vector2f Engine::position_sprite(textures::SpriteTexture& st, const std::string& cell_name, sf::Vector2f scale, bool at_mid, float x_diff, float y_diff) {
|
||||||
auto& cell = $ui.cell_for(cell_name);
|
auto& cell = $gui.cell_for(cell_name);
|
||||||
float x = float(at_mid ? cell.mid_x : cell.x);
|
float x = float(at_mid ? cell.mid_x : cell.x);
|
||||||
float y = float(at_mid ? cell.mid_y : cell.y);
|
float y = float(at_mid ? cell.mid_y : cell.y);
|
||||||
|
|
||||||
|
|
@ -203,4 +214,11 @@ namespace scene {
|
||||||
void Engine::reset(sf::RenderTexture& view) {
|
void Engine::reset(sf::RenderTexture& view) {
|
||||||
$camera.reset(view);
|
$camera.reset(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::set_text(const std::string& content) {
|
||||||
|
if($gui.contains("text")) {
|
||||||
|
auto el = $gui.get_if<guecs::Text>($gui.entity("text"));
|
||||||
|
el->text->setString(guecs::to_wstring(content));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace scene {
|
||||||
|
|
||||||
struct Engine {
|
struct Engine {
|
||||||
sf::Clock $clock;
|
sf::Clock $clock;
|
||||||
guecs::UI $ui;
|
guecs::UI $gui;
|
||||||
components::AnimatedScene& $scene;
|
components::AnimatedScene& $scene;
|
||||||
std::string $layout;
|
std::string $layout;
|
||||||
std::unordered_map<std::string, int> $actor_name_ids;
|
std::unordered_map<std::string, int> $actor_name_ids;
|
||||||
|
|
@ -46,7 +46,7 @@ namespace scene {
|
||||||
void attach_text(const std::string& actor, const std::string& text);
|
void attach_text(const std::string& actor, const std::string& text);
|
||||||
|
|
||||||
nlohmann::json& buttons() { return $scene.buttons; };
|
nlohmann::json& buttons() { return $scene.buttons; };
|
||||||
lel::Cell& button_cell() { return $ui.cell_for("buttons"); }
|
lel::Cell& button_cell() { return $gui.cell_for("buttons"); }
|
||||||
|
|
||||||
Element config_scene_element(nlohmann::json& config, bool duped);
|
Element config_scene_element(nlohmann::json& config, bool duped);
|
||||||
|
|
||||||
|
|
@ -60,5 +60,6 @@ namespace scene {
|
||||||
void zoom(float mid_x, float mid_y, const std::string& style, float scale);
|
void zoom(float mid_x, float mid_y, const std::string& style, float scale);
|
||||||
void reset(sf::RenderTexture& view);
|
void reset(sf::RenderTexture& view);
|
||||||
void set_end_cb(std::function<void()> cb);
|
void set_end_cb(std::function<void()> cb);
|
||||||
|
void set_text(const std::string& content);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -592,8 +592,9 @@ namespace gui {
|
||||||
auto config = settings::get("config");
|
auto config = settings::get("config");
|
||||||
size_t levels_to_win = config["game_play"]["levels_to_win"];
|
size_t levels_to_win = config["game_play"]["levels_to_win"];
|
||||||
|
|
||||||
if(level.index <= levels_to_win) {
|
if(level.index < levels_to_win) {
|
||||||
show_scene("NEXT_LEVEL");
|
show_scene("NEXT_LEVEL");
|
||||||
|
$cur_scene->set_text(fmt::format("ENTERING\nLEVEL\n{}", level.index+2));
|
||||||
state(State::NEXT_LEVEL_SCENE);
|
state(State::NEXT_LEVEL_SCENE);
|
||||||
} else {
|
} else {
|
||||||
show_scene("WIN");
|
show_scene("WIN");
|
||||||
|
|
|
||||||
|
|
@ -29,22 +29,26 @@ namespace gui {
|
||||||
|
|
||||||
auto& button_cell = $scene.button_cell();
|
auto& button_cell = $scene.button_cell();
|
||||||
|
|
||||||
$ui.position(button_cell.x, button_cell.y, button_cell.w, button_cell.h);
|
$gui.position(button_cell.x, button_cell.y, button_cell.w, button_cell.h);
|
||||||
$ui.layout(layout);
|
$gui.layout(layout);
|
||||||
|
|
||||||
for(auto& [name, cell] : $ui.cells()) {
|
for(auto& [name, cell] : $gui.cells()) {
|
||||||
auto ui_id = $ui.entity(name);
|
auto ui_id = $gui.entity(name);
|
||||||
$ui.set<guecs::Text>(ui_id, {guecs::to_wstring(name)});
|
$gui.set<guecs::Text>(ui_id, {guecs::to_wstring(name)});
|
||||||
$ui.set<guecs::Rectangle>(ui_id, {});
|
$gui.set<guecs::Rectangle>(ui_id, {5, guecs::THEME.DARK_MID});
|
||||||
$ui.set<guecs::Effect>(ui_id, {});
|
$gui.set<guecs::Effect>(ui_id, {});
|
||||||
|
|
||||||
if(actions.contains(name)) {
|
if(actions.contains(name)) {
|
||||||
auto event_id = actions[name];
|
auto event_id = actions[name];
|
||||||
$ui.set<guecs::Clickable>(ui_id, guecs::make_action(ui_id, event_id));
|
$gui.set<guecs::Clickable>(ui_id, guecs::make_action(ui_id, event_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ui.init();
|
$gui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneUI::set_text(const std::string& text) {
|
||||||
|
$scene.set_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneUI::render(sf::RenderTarget &target) {
|
void SceneUI::render(sf::RenderTarget &target) {
|
||||||
|
|
@ -52,8 +56,8 @@ namespace gui {
|
||||||
target.draw($view_sprite);
|
target.draw($view_sprite);
|
||||||
|
|
||||||
if(has_buttons) {
|
if(has_buttons) {
|
||||||
$ui.render(target);
|
$gui.render(target);
|
||||||
if(DEBUG) $ui.debug_layout(target);
|
if(DEBUG) $gui.debug_layout(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +67,7 @@ namespace gui {
|
||||||
|
|
||||||
bool SceneUI::mouse(float x, float y, guecs::Modifiers mods) {
|
bool SceneUI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||||
$scene.mouse(x, y, mods);
|
$scene.mouse(x, y, mods);
|
||||||
$ui.mouse(x, y, mods);
|
$gui.mouse(x, y, mods);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace gui {
|
||||||
AnimatedScene $scene_data{load_scene(name)};
|
AnimatedScene $scene_data{load_scene(name)};
|
||||||
scene::Engine $scene{$scene_data};
|
scene::Engine $scene{$scene_data};
|
||||||
bool has_buttons = false;
|
bool has_buttons = false;
|
||||||
guecs::UI $ui;
|
guecs::UI $gui;
|
||||||
|
|
||||||
AnimatedScene load_scene(const std::string& name);
|
AnimatedScene load_scene(const std::string& name);
|
||||||
void create_buttons(nlohmann::json& buttons);
|
void create_buttons(nlohmann::json& buttons);
|
||||||
|
|
@ -22,5 +22,6 @@ namespace gui {
|
||||||
void render(sf::RenderTarget &target);
|
void render(sf::RenderTarget &target);
|
||||||
void update();
|
void update();
|
||||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||||
|
void set_text(const std::string& text);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,16 @@ namespace gui {
|
||||||
for(auto& [name, cell] : $gui.cells()) {
|
for(auto& [name, cell] : $gui.cells()) {
|
||||||
auto gui_id = $gui.entity(name);
|
auto gui_id = $gui.entity(name);
|
||||||
|
|
||||||
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
|
||||||
|
|
||||||
if(name.starts_with("body_")) {
|
if(name.starts_with("body_")) {
|
||||||
auto& cell = $gui.cell_for(name);
|
auto& cell = $gui.cell_for(name);
|
||||||
$body_ui.init(cell.x, cell.y, cell.w, cell.h);
|
$body_ui.init(cell.x, cell.y, cell.w, cell.h);
|
||||||
} else {
|
} else {
|
||||||
|
// don't show inventory names
|
||||||
|
if(!name.starts_with("inv")) {
|
||||||
|
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||||
|
}
|
||||||
|
|
||||||
$gui.set<Rectangle>(gui_id, {});
|
$gui.set<Rectangle>(gui_id, {});
|
||||||
$gui.set<Clickable>(gui_id, {
|
$gui.set<Clickable>(gui_id, {
|
||||||
guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id})
|
guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue