added a few more pieces to the framework, overhauled main.cc

This commit is contained in:
2024-07-03 11:08:55 -04:00
parent 97ff14cd26
commit 6cbeb42144
17 changed files with 416 additions and 61 deletions

View File

@ -1,52 +1,23 @@
#include <iostream>
#include <cstdlib>
#include <memory>
#include <string>
#include <stdio.h>
#include <time.h>
#include <ncurses.h>
#include "map.h"
#include "races.h"
#include "game.h"
#include "cursor.h"
#include "display.h"
#include "rng.h"
using namespace std;
// The way things are designed to work:
// 1. initializes a new ncurses wrapper c
// Note: This is done the first thing in main because ncurses
// are from procedural programming and may break otherwise (unlikely)
// 2. bind c to a new display c (that handles all output)
// 3. bind d to g for graphics
RNG rng;//{(unsigned int)time(0)};
int main(int argc, char **argv) {
cursor c;
// binds a ncurses cursor to display
display d(c);
// binds display to the game
game g(d, argc, argv);
int main() {
display display;
unique_ptr<game_map> mmap(new game_map{default_map, 0});
unique_ptr<class shade>
player(new shade{mmap->get_available_positions()});
while (g.run() != game_status::terminated)
d.render();
for (char ch = ' '; ch != 'q'; ch = getchar()) {
//system("CLS");
cout << "\033[2J";
display.clear();
mmap->print(display);
display.print_position(player->get_position(), '@');
display.print(cout);
cout << "Command: " << ch << endl;
auto available_positions = mmap->get_available_positions();
switch (ch) {
case 'w':
player->move(direction::north, available_positions);
break;
case 'a':
player->move(direction::west, available_positions);
break;
case 's':
player->move(direction::south, available_positions);
break;
case 'd':
player->move(direction::east, available_positions);
break;
}
}
return 0;
}