Fixed player showing up as an enemy and did better map centering.
This commit is contained in:
parent
e2bd61a1e4
commit
421cca308b
5 changed files with 13 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"PLAYER_TILE": {
|
"PLAYER_TILE": {
|
||||||
|
"placement": "fixed",
|
||||||
"components": [
|
"components": [
|
||||||
{"_type": "Tile", "display": "\ua66b",
|
{"_type": "Tile", "display": "\ua66b",
|
||||||
"foreground": [255, 200, 125],
|
"foreground": [255, 200, 125],
|
||||||
|
@ -8,7 +9,8 @@
|
||||||
{"_type": "Combat", "hp": 200, "damage": 15, "dead": false},
|
{"_type": "Combat", "hp": 200, "damage": 15, "dead": false},
|
||||||
{"_type": "Motion", "dx": 0, "dy": 0, "random": false},
|
{"_type": "Motion", "dx": 0, "dy": 0, "random": false},
|
||||||
{"_type": "LightSource", "strength": 70, "radius": 2},
|
{"_type": "LightSource", "strength": 70, "radius": 2},
|
||||||
{"_type": "EnemyConfig", "hearing_distance": 5}
|
{"_type": "EnemyConfig", "hearing_distance": 5},
|
||||||
|
{"_type": "Sprite", "name": "peasant_girl"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"KNIGHT": {
|
"KNIGHT": {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#include "dinkyecs.hpp"
|
|
||||||
#include "dbc.hpp"
|
|
||||||
#include <fmt/core.h>
|
|
20
gui.cpp
20
gui.cpp
|
@ -111,10 +111,8 @@ namespace gui {
|
||||||
|
|
||||||
$renderer.init_terminal();
|
$renderer.init_terminal();
|
||||||
$map_view.create_render();
|
$map_view.create_render();
|
||||||
|
|
||||||
$renderer.resize_grid(MAX_FONT_SIZE, $map_view);
|
$renderer.resize_grid(MAX_FONT_SIZE, $map_view);
|
||||||
$map_view.resize_canvas();
|
$map_view.resize_canvas();
|
||||||
|
|
||||||
state(State::IDLE);
|
state(State::IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +148,7 @@ namespace gui {
|
||||||
// just do 10 ticks
|
// just do 10 ticks
|
||||||
if($rotation_count % 10 == 0) {
|
if($rotation_count % 10 == 0) {
|
||||||
run_systems();
|
run_systems();
|
||||||
$rayview.$anim.play(true);
|
$rayview.$anim.play(false);
|
||||||
$rotation = -10.0f;
|
$rotation = -10.0f;
|
||||||
state(State::IDLE);
|
state(State::IDLE);
|
||||||
}
|
}
|
||||||
|
@ -195,6 +193,8 @@ namespace gui {
|
||||||
state(State::ROTATING);
|
state(State::ROTATING);
|
||||||
break;
|
break;
|
||||||
case FU::MAP_OPEN:
|
case FU::MAP_OPEN:
|
||||||
|
$renderer.resize_grid(MAX_FONT_SIZE, $map_view);
|
||||||
|
$map_view.resize_canvas();
|
||||||
state(State::MAPPING);
|
state(State::MAPPING);
|
||||||
break;
|
break;
|
||||||
case FU::ATTACK:
|
case FU::ATTACK:
|
||||||
|
@ -310,26 +310,26 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSM::render() {
|
void FSM::render() {
|
||||||
auto start = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
if(in_state(State::MAPPING)) {
|
if(in_state(State::MAPPING)) {
|
||||||
$window.clear();
|
$window.clear();
|
||||||
$map_view.render();
|
$map_view.render();
|
||||||
$renderer.draw($map_view);
|
$renderer.draw($map_view);
|
||||||
} else {
|
} else {
|
||||||
|
auto start = std::chrono::high_resolution_clock::now();
|
||||||
$rayview.draw($window);
|
$rayview.draw($window);
|
||||||
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
auto elapsed = std::chrono::duration<double>(end - start);
|
||||||
|
$stats.sample(1/elapsed.count());
|
||||||
|
|
||||||
|
draw_weapon();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
|
||||||
auto elapsed = std::chrono::duration<double>(end - start);
|
|
||||||
$stats.sample(1/elapsed.count());
|
|
||||||
|
|
||||||
draw_gui();
|
draw_gui();
|
||||||
draw_weapon();
|
|
||||||
$window.display();
|
$window.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSM::mouse() {
|
void FSM::mouse() {
|
||||||
|
// temporarily gutted
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSM::generate_map() {
|
void FSM::generate_map() {
|
||||||
|
|
|
@ -51,7 +51,6 @@ sources = [
|
||||||
'config.cpp',
|
'config.cpp',
|
||||||
'dbc.cpp',
|
'dbc.cpp',
|
||||||
'devices.cpp',
|
'devices.cpp',
|
||||||
'dinkyecs.cpp',
|
|
||||||
'gui.cpp',
|
'gui.cpp',
|
||||||
'inventory.cpp',
|
'inventory.cpp',
|
||||||
'levelmanager.cpp',
|
'levelmanager.cpp',
|
||||||
|
|
|
@ -235,10 +235,6 @@ void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config
|
||||||
int rand_entity = Random::uniform<int>(0, keys.size() - 1);
|
int rand_entity = Random::uniform<int>(0, keys.size() - 1);
|
||||||
std::string key = keys[rand_entity];
|
std::string key = keys[rand_entity];
|
||||||
// BUG: this may crash if PLAYER_TILE isn't first
|
// BUG: this may crash if PLAYER_TILE isn't first
|
||||||
if(key == "PLAYER_TITLE") {
|
|
||||||
key = keys[rand_entity + 1];
|
|
||||||
fmt::println("SKIPPING PLAYER and using {} instead", key);
|
|
||||||
}
|
|
||||||
auto entity_data = entity_db[key];
|
auto entity_data = entity_db[key];
|
||||||
|
|
||||||
// pass that to the config as it'll be a generic json
|
// pass that to the config as it'll be a generic json
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue