Floor is now just a fixture.
This commit is contained in:
parent
23f54bd4fe
commit
e5fa76b03c
6 changed files with 20 additions and 25 deletions
|
|
@ -194,5 +194,19 @@
|
|||
"stationary": true,
|
||||
"toggled": false,
|
||||
"looped": true
|
||||
},
|
||||
"test_floor": {
|
||||
"_type": "Animation",
|
||||
"easing": 0,
|
||||
"ease_rate": 0.5,
|
||||
"scale_x": 1.0,
|
||||
"scale_y": 1.0,
|
||||
"max_scale": 0.4,
|
||||
"simple": true,
|
||||
"frames": 1,
|
||||
"speed": 1.0,
|
||||
"stationary": true,
|
||||
"toggled": false,
|
||||
"looped": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,9 +261,9 @@
|
|||
"frame_height": 832
|
||||
},
|
||||
"test_floor":
|
||||
{"path": "assets/boss2/boss_fight_scene_1_floor.png",
|
||||
"frame_width": 1080,
|
||||
"frame_height": 720
|
||||
{"path": "assets/bossfights/test_floor.png",
|
||||
"frame_width": 1920,
|
||||
"frame_height": 1080
|
||||
},
|
||||
"test_player":
|
||||
{"path": "assets/bossfights/test_player.png",
|
||||
|
|
|
|||
|
|
@ -83,8 +83,6 @@ namespace components {
|
|||
|
||||
struct AnimatedScene {
|
||||
std::string background;
|
||||
std::optional<std::string> floor;
|
||||
std::string floor_pos;
|
||||
json actors;
|
||||
json fixtures;
|
||||
};
|
||||
|
|
@ -151,7 +149,7 @@ namespace components {
|
|||
using ComponentMap = std::unordered_map<std::string, ReflFuncSignature>;
|
||||
|
||||
ENROLL_COMPONENT(Tile, display, foreground, background);
|
||||
ENROLL_COMPONENT(AnimatedScene, background, floor, floor_pos, actors, fixtures);
|
||||
ENROLL_COMPONENT(AnimatedScene, background, actors, fixtures);
|
||||
ENROLL_COMPONENT(Sprite, name, scale);
|
||||
ENROLL_COMPONENT(Curative, hp);
|
||||
ENROLL_COMPONENT(LightSource, strength, radius);
|
||||
|
|
|
|||
16
scene.cpp
16
scene.cpp
|
|
@ -20,6 +20,7 @@ namespace scene {
|
|||
float x = config["x"];
|
||||
float y = config["y"];
|
||||
|
||||
// BUG: need to make animation optional
|
||||
auto anim = animation::load(sprite_name);
|
||||
if(and_play) anim.play();
|
||||
anim.scale_x = scale_x;
|
||||
|
|
@ -42,11 +43,6 @@ namespace scene {
|
|||
$actor_name_ids.try_emplace(element.name, $actors.size() - 1);
|
||||
}
|
||||
|
||||
// floor is std::optional
|
||||
if($scene.floor) {
|
||||
$floor_sprite = textures::get_sprite(*$scene.floor);
|
||||
}
|
||||
|
||||
for(auto& fixture : $scene.fixtures) {
|
||||
auto element = config_scene_element(fixture, true, true);
|
||||
$fixtures.push_back(element);
|
||||
|
|
@ -68,10 +64,6 @@ namespace scene {
|
|||
"[floor4|player5|player6|player7|player8|_]"
|
||||
);
|
||||
|
||||
if($scene.floor) {
|
||||
position_sprite($floor_sprite, $scene.floor_pos, 1.0f, 1.0f, false);
|
||||
}
|
||||
|
||||
for(auto& actor : $actors) {
|
||||
actor.pos = position_sprite(actor.st, actor.cell,
|
||||
actor.scale_x, actor.scale_y, false, actor.x, actor.y);
|
||||
|
|
@ -88,10 +80,6 @@ namespace scene {
|
|||
}
|
||||
|
||||
void Engine::render(sf::RenderWindow& window) {
|
||||
if($floor_sprite.sprite) {
|
||||
window.draw(*$floor_sprite.sprite);
|
||||
}
|
||||
|
||||
$ui.render(window);
|
||||
|
||||
for(auto& fixture : $fixtures) {
|
||||
|
|
@ -99,7 +87,7 @@ namespace scene {
|
|||
}
|
||||
|
||||
for(auto& actor : $actors) {
|
||||
window.draw(*actor.st.sprite);
|
||||
window.draw(*actor.st.sprite);
|
||||
}
|
||||
|
||||
if(DEBUG) $ui.debug_layout(window);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ namespace scene {
|
|||
|
||||
struct Engine {
|
||||
guecs::UI $ui;
|
||||
SpriteTexture $floor_sprite;
|
||||
components::AnimatedScene& $scene;
|
||||
std::unordered_map<std::string, int> $actor_name_ids;
|
||||
std::vector<Element> $fixtures;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ TEST_CASE("make sure json_mods works", "[components]") {
|
|||
for(auto& comp_data : config["RAT_KING"]["components"]) {
|
||||
if(comp_data["_type"] == "AnimatedScene") {
|
||||
auto comp = components::convert<components::AnimatedScene>(comp_data);
|
||||
// the boss fight for the rat king doesn't have a stage so false=optional
|
||||
REQUIRE(comp.floor == std::nullopt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +47,5 @@ TEST_CASE("make sure json_mods works", "[components]") {
|
|||
auto rat_king = world.entity();
|
||||
|
||||
components::configure_entity(world, rat_king, config["RAT_KING"]["components"]);
|
||||
|
||||
auto boss = world.get<AnimatedScene>(rat_king);
|
||||
REQUIRE(boss.floor == std::nullopt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue