Quick code review to refresh my memory.
This commit is contained in:
parent
ee9f8c7c4b
commit
517de91a5b
8 changed files with 27 additions and 18 deletions
|
|
@ -21,6 +21,8 @@ namespace boss {
|
||||||
FSM_STATE(State, END, ev, data);
|
FSM_STATE(State, END, ev, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_systems();
|
||||||
|
|
||||||
return in_state(State::END);
|
return in_state(State::END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,9 +63,6 @@ namespace boss {
|
||||||
case BOSS_START:
|
case BOSS_START:
|
||||||
state(State::END);
|
state(State::END);
|
||||||
break;
|
break;
|
||||||
case TICK:
|
|
||||||
run_systems();
|
|
||||||
break;
|
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
$ui.status(L"PLAYER TURN");
|
$ui.status(L"PLAYER TURN");
|
||||||
state(State::PLAYER_TURN);
|
state(State::PLAYER_TURN);
|
||||||
|
|
@ -83,6 +82,7 @@ namespace boss {
|
||||||
break;
|
break;
|
||||||
case ATTACK: {
|
case ATTACK: {
|
||||||
$ui.status(L"PLAYER TURN");
|
$ui.status(L"PLAYER TURN");
|
||||||
|
$ui.move_player(run % 10 < 5 ? "player1" : "player2");
|
||||||
int attack_id = std::any_cast<int>(data);
|
int attack_id = std::any_cast<int>(data);
|
||||||
boss::System::combat(attack_id);
|
boss::System::combat(attack_id);
|
||||||
state(State::PLAYER_TURN);
|
state(State::PLAYER_TURN);
|
||||||
|
|
@ -103,6 +103,7 @@ namespace boss {
|
||||||
break;
|
break;
|
||||||
case ATTACK: {
|
case ATTACK: {
|
||||||
$ui.status(L"BOSS TURN");
|
$ui.status(L"BOSS TURN");
|
||||||
|
$ui.move_boss(run % 10 < 5 ? "boss1" : "boss3");
|
||||||
int attack_id = std::any_cast<int>(data);
|
int attack_id = std::any_cast<int>(data);
|
||||||
boss::System::combat(attack_id);
|
boss::System::combat(attack_id);
|
||||||
state(State::BOSS_TURN);
|
state(State::BOSS_TURN);
|
||||||
|
|
@ -120,6 +121,10 @@ namespace boss {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fight::run_systems() {
|
void Fight::run_systems() {
|
||||||
|
run++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fight::render(sf::RenderWindow& window) {
|
||||||
|
$ui.render(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,7 @@ namespace boss {
|
||||||
void BOSS_TURN(gui::Event ev, std::any data);
|
void BOSS_TURN(gui::Event ev, std::any data);
|
||||||
void PLAYER_TURN(gui::Event ev, std::any data);
|
void PLAYER_TURN(gui::Event ev, std::any data);
|
||||||
void END(gui::Event ev, std::any data);
|
void END(gui::Event ev, std::any data);
|
||||||
|
void render(sf::RenderWindow& window);
|
||||||
void render(sf::RenderWindow& window) {
|
|
||||||
$ui.render(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
void run_systems();
|
void run_systems();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
17
boss/ui.cpp
17
boss/ui.cpp
|
|
@ -35,8 +35,8 @@ namespace boss {
|
||||||
"[floor4|player5|player6|player7|player8|_]"
|
"[floor4|player5|player6|player7|player8|_]"
|
||||||
);
|
);
|
||||||
|
|
||||||
position_sprite($boss_sprite, $scene.boss["start_pos"], $scene.boss["scale"], $scene.boss["mid_cell"]);
|
move_boss($scene.boss["start_pos"]);
|
||||||
position_sprite($player_sprite, $scene.player["start_pos"], $scene.player["scale"], $scene.player["mid_cell"]);
|
move_player($scene.player["start_pos"]);
|
||||||
position_sprite($floor_sprite, $scene.floor_pos, 1.0, false);
|
position_sprite($floor_sprite, $scene.floor_pos, 1.0, false);
|
||||||
|
|
||||||
$arena.init();
|
$arena.init();
|
||||||
|
|
@ -60,8 +60,8 @@ namespace boss {
|
||||||
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
|
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::position_sprite(textures::SpriteTexture& st, const std::string& name, float scale, bool at_mid) {
|
void UI::position_sprite(textures::SpriteTexture& st, const std::string& cell_name, float scale, bool at_mid) {
|
||||||
auto& cell = $arena.cell_for(name);
|
auto& cell = $arena.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);
|
||||||
|
|
||||||
|
|
@ -91,4 +91,13 @@ namespace boss {
|
||||||
$arena.show_text("status", msg);
|
$arena.show_text("status", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UI::move_boss(const std::string& cell_name) {
|
||||||
|
dbc::log(cell_name);
|
||||||
|
position_sprite($boss_sprite, cell_name, $scene.boss["scale"], $scene.boss["mid_cell"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI::move_player(const std::string& cell_name) {
|
||||||
|
dbc::log(cell_name);
|
||||||
|
position_sprite($player_sprite, cell_name, $scene.player["scale"], $scene.player["mid_cell"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@ namespace boss {
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderWindow& window);
|
||||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||||
void position_sprite(SpriteTexture& st, const std::string& name, float scale, bool at_mid=false);
|
void position_sprite(SpriteTexture& st, const std::string& cell_name, float scale, bool at_mid=false);
|
||||||
void status(const std::wstring& msg);
|
void status(const std::wstring& msg);
|
||||||
|
void move_boss(const std::string& cell_name);
|
||||||
|
void move_player(const std::string& cell_name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ inline void add_neighbors(PointList &neighbors, Matrix &closed, size_t y, size_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Used https://github.com/HenrYxZ/dijkstra-map as a reference.
|
|
||||||
*/
|
|
||||||
void Pathing::compute_paths(Matrix &walls) {
|
void Pathing::compute_paths(Matrix &walls) {
|
||||||
INVARIANT();
|
INVARIANT();
|
||||||
dbc::check(walls[0].size() == $width,
|
dbc::check(walls[0].size() == $width,
|
||||||
|
|
@ -66,7 +63,6 @@ void Pathing::compute_paths(Matrix &walls) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pathing::set_target(const Point &at, int value) {
|
void Pathing::set_target(const Point &at, int value) {
|
||||||
// FUTURE: I'll eventually allow setting this to negatives for priority
|
|
||||||
$input[at.y][at.x] = value;
|
$input[at.y][at.x] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ void System::pickup() {
|
||||||
} else if(world.has<Device>(entity)) {
|
} else if(world.has<Device>(entity)) {
|
||||||
System::device(world, level.player, entity);
|
System::device(world, level.player, entity);
|
||||||
} else {
|
} else {
|
||||||
// Bug #81 is related to this
|
dbc::log("BUG: is this a bug in pickup?!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ using namespace components;
|
||||||
|
|
||||||
void WorldBuilder::stylize_rooms() {
|
void WorldBuilder::stylize_rooms() {
|
||||||
auto& tiles = $map.tiles();
|
auto& tiles = $map.tiles();
|
||||||
auto style_config = settings::get("styles");
|
auto style_config = settings::get("room_themes");
|
||||||
json& styles = style_config.json();
|
json& styles = style_config.json();
|
||||||
|
|
||||||
for(auto& room : $map.rooms()) {
|
for(auto& room : $map.rooms()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue