moving repo
This commit is contained in:
12
src/arguments.h
Normal file
12
src/arguments.h
Normal 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
|
18
src/cursor.h
18
src/cursor.h
@ -1,7 +1,23 @@
|
||||
#ifndef __CURSOR_H__
|
||||
#define __CURSOR_H__
|
||||
#include <string>
|
||||
#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
|
||||
|
@ -16,10 +16,10 @@
|
||||
class display final {
|
||||
private:
|
||||
std::vector<std::string> contents;
|
||||
cursor &curs;
|
||||
cursor &curse;
|
||||
public:
|
||||
display();
|
||||
display(cursor &s);
|
||||
display(cursor&new_curse,int argc, char **argv);
|
||||
|
||||
void clear();
|
||||
// use this instead of overloading for clarity
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
#include "constants.h"
|
||||
#include "display.h"
|
||||
#include "cursor.h"
|
||||
#include "rng.h"
|
||||
#include "characters.h"
|
||||
#include "map.h"
|
||||
@ -11,14 +12,17 @@
|
||||
|
||||
class game final {
|
||||
private:
|
||||
display &d;
|
||||
display &out;
|
||||
cursor &curse;
|
||||
feature features;
|
||||
std::unique_ptr<RNG> rng;
|
||||
std::unique_ptr<character> player;
|
||||
std::vector<level> levels;
|
||||
public:
|
||||
game(display &new_display, int argc, char **argv);
|
||||
game(cursor&new_curse,display &new_display, int argc, char **argv);
|
||||
game_status run();
|
||||
private:
|
||||
int getcmd() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
11
src/input.h
Normal file
11
src/input.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __INPUT_H__
|
||||
#define __INPUT_H__
|
||||
#include <string>
|
||||
#include "cursor.h"
|
||||
|
||||
class input{
|
||||
public:
|
||||
input(cursor &new_curse);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,6 +1,6 @@
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
|
||||
class log;
|
||||
class logger;
|
||||
|
||||
#endif
|
||||
|
33
src/main.cc
33
src/main.cc
@ -1,23 +1,32 @@
|
||||
#include "game.h"
|
||||
#include "cursor.h"
|
||||
#include "display.h"
|
||||
#include "input.h"
|
||||
#include "arguments.h"
|
||||
|
||||
// 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
|
||||
// 1. out initializes a new display (this is a virtual one)
|
||||
// 2. out initializes output based on given args
|
||||
// This is when curse is initialized (curse.init())
|
||||
// 3. game_proc binds output to out and curses (if needed)
|
||||
|
||||
// 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) {
|
||||
cursor c;
|
||||
// binds a ncurses cursor to display
|
||||
display d(c);
|
||||
// binds display to the game
|
||||
game g(d, argc, argv);
|
||||
logger log;
|
||||
cursor curse;
|
||||
input in(curse);
|
||||
feature enabled_features = proc_args(argc,argv,curse,in,log);
|
||||
display out(curse, enabled_features);
|
||||
|
||||
while (g.run() != game_status::terminated)
|
||||
d.render();
|
||||
// binds display to the game
|
||||
game game_proc(in, out, argc, argv);
|
||||
|
||||
while (game_proc.run() != game_status::terminated)
|
||||
out.render();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user