moving repo

This commit is contained in:
2024-07-04 19:58:19 -04:00
parent 6cbeb42144
commit c67dbcc62a
7 changed files with 70 additions and 18 deletions

12
src/arguments.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef __ARGUMENTS_H__
#define __ARGUMENTS_H__
#include "log.h"
#include "cursor.h"
#include "display.h"
#include "input.h"
#include "constants.h"
feature proc_args(int argc, char ** argv, cursor &curse, input &in, logger& log);
#endif

View File

@ -1,7 +1,23 @@
#ifndef __CURSOR_H__ #ifndef __CURSOR_H__
#define __CURSOR_H__ #define __CURSOR_H__
#include <string>
#include <ncurses.h> #include <ncurses.h>
#include "position.h"
class cursor; class cursor{
private:
public:
cursor();
~cursor();
int getcmd() const;
void show() const;
void print_char(const position &pos) const;
void print_str(const position &head, const std::string str) const;
};
#endif #endif

View File

@ -16,10 +16,10 @@
class display final { class display final {
private: private:
std::vector<std::string> contents; std::vector<std::string> contents;
cursor &curs; cursor &curse;
public: public:
display(); display();
display(cursor &s); display(cursor&new_curse,int argc, char **argv);
void clear(); void clear();
// use this instead of overloading for clarity // use this instead of overloading for clarity

View File

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "constants.h" #include "constants.h"
#include "display.h" #include "display.h"
#include "cursor.h"
#include "rng.h" #include "rng.h"
#include "characters.h" #include "characters.h"
#include "map.h" #include "map.h"
@ -11,14 +12,17 @@
class game final { class game final {
private: private:
display &d; display &out;
cursor &curse;
feature features; feature features;
std::unique_ptr<RNG> rng; std::unique_ptr<RNG> rng;
std::unique_ptr<character> player; std::unique_ptr<character> player;
std::vector<level> levels; std::vector<level> levels;
public: public:
game(display &new_display, int argc, char **argv); game(cursor&new_curse,display &new_display, int argc, char **argv);
game_status run(); game_status run();
private:
int getcmd() const;
}; };
#endif #endif

11
src/input.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef __INPUT_H__
#define __INPUT_H__
#include <string>
#include "cursor.h"
class input{
public:
input(cursor &new_curse);
};
#endif

View File

@ -1,6 +1,6 @@
#ifndef __LOG_H__ #ifndef __LOG_H__
#define __LOG_H__ #define __LOG_H__
class log; class logger;
#endif #endif

View File

@ -1,23 +1,32 @@
#include "game.h" #include "game.h"
#include "cursor.h" #include "cursor.h"
#include "display.h" #include "display.h"
#include "input.h"
#include "arguments.h"
// The way things are designed to work: // The way things are designed to work:
// 1. initializes a new ncurses wrapper c // 1. out initializes a new display (this is a virtual one)
// Note: This is done the first thing in main because ncurses // 2. out initializes output based on given args
// are from procedural programming and may break otherwise (unlikely) // This is when curse is initialized (curse.init())
// 2. bind c to a new display c (that handles all output) // 3. game_proc binds output to out and curses (if needed)
// 3. bind d to g for graphics
// Notes:
// 1. game sends all output to display and gets all input from input
// 2. display either renders to file (console) or curse
// 3.
int main(int argc, char **argv) { int main(int argc, char **argv) {
cursor c; logger log;
// binds a ncurses cursor to display cursor curse;
display d(c); input in(curse);
// binds display to the game feature enabled_features = proc_args(argc,argv,curse,in,log);
game g(d, argc, argv); display out(curse, enabled_features);
while (g.run() != game_status::terminated) // binds display to the game
d.render(); game game_proc(in, out, argc, argv);
while (game_proc.run() != game_status::terminated)
out.render();
return 0; return 0;
} }