Got a really terrible map in the middle of a two panel UI. Next step is to get the dijkstra algorithm working and make a real map with it.

main
Zed A. Shaw 2 months ago
parent 6afb13a50b
commit d7b1cf0bf9
  1. 6
      Makefile
  2. 70
      main.cpp
  3. 8
      status.txt

@ -9,10 +9,8 @@ build:
test: build test: build
./builddir/runtests ./builddir/runtests
install: build test run: build test
powershell "cp ./builddir/subprojects/libgit2-1.8.1/liblibgit2package.dll ." ./builddir/roguish
powershell "cp ./builddir/subprojects/efsw/libefsw.dll ."
powershell "cp builddir/escape_turings_tarpit.exe ."
clean: clean:
meson compile --clean -C builddir meson compile --clean -C builddir

@ -8,40 +8,60 @@
#include <string> // for string, operator<< #include <string> // for string, operator<<
#include <thread> // for sleep_for #include <thread> // for sleep_for
#include "ftxui/dom/elements.hpp" // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element #include <ftxui/dom/elements.hpp> // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element
#include "ftxui/dom/node.hpp" // for Render #include <ftxui/dom/node.hpp> // for Render
#include "ftxui/screen/box.hpp" // for ftxui #include <ftxui/screen/box.hpp> // for ftxui
#include <ftxui/component/component.hpp>
using namespace std::chrono_literals; using namespace std::chrono_literals;
std::array<std::string, 6> tiles = {
"##########",
"# #",
"# #",
"# |",
"# #",
"##########",
};
int main() { int main() {
using namespace ftxui; using namespace ftxui;
std::string p =
R"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
std::string reset_position; std::string reset_position;
auto c = Canvas(100, 100);
// A triangle following the mouse, using braille characters.
auto map = Renderer([&] {
for(size_t i = 0; i < tiles.size(); ++i) {
c.DrawText(50, 50+i*4, tiles[i]);
}
for(size_t i = 0; i < tiles[0].size() - 2; i++) {
for(size_t j = 0; j < tiles.size() - 2; j++) {
c.DrawText(52+i*2, 54+j*4, ".", Color::Yellow);
}
}
c.DrawText(50+3*4, 50+3*4, "@", Color::Blue);
return canvas(c);
});
while (true) { while (true) {
auto document = vbox({ auto document = hbox({
hflow(paragraph(p)), hflow(
separator(), vbox(
hflow(paragraph(p)), gauge(0.5) | border,
separator(), text("STATUS") | border
hbox({ ) | xflex_grow
hflow(paragraph(p)), ),
separator(), separator(),
hflow(paragraph(p)), hflow(map->Render()),
}), }) | border;
}) |
border;
document = vbox(filler(), document);
// auto screen = Screen::Create(Dimension::Fit(document));
// Render(screen, document);
// screen.Print();
// getchar();
auto screen = Screen::Create(Dimension::Full()); auto screen = Screen::Create(Dimension::Full());
Render(screen, document); Render(screen, document);
std::cout << reset_position; std::cout << reset_position;
screen.Print(); screen.Print();
reset_position = screen.ResetPosition(); reset_position = screen.ResetPosition();

@ -0,0 +1,8 @@
* Research how hard to create a non-terminal/graphic backend to FTXUI.
* Look into font rendering libraries.
* Get a basic UI in FTX with a stat panel and map.
* Fill the map with something.
* Dijkstra's algorithm for the map.
* https://github.com/HenrYxZ/dijkstra-map/blob/main/dijkstra_map.py
* Look at a few more rogue games
* Lua integration
Loading…
Cancel
Save