added input, some changes

This commit is contained in:
ProgramSnail 2021-04-19 20:03:12 +03:00
parent 733bcbd99d
commit 76c85016d8
10 changed files with 54 additions and 4 deletions

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": true
}

View file

@ -2,4 +2,21 @@
#include "game_map.hpp"
Game::Game(size_t playersNum, std::pair<size_t, size_t> sz) :
playersNum(playersNum), gameMap(sz) {}
playersNum(playersNum), gameMap(sz) {}
void Game::begin() {
// init map
// create basic units
}
void Game::step() {
// gameMap.step();
for (size_t i = 0; i < units.size(); ++i) {
units[i].step();
}
// all game step
}
void Game::end() {
// end all
}

View file

@ -16,4 +16,7 @@ private:
public:
// may be more than one map sizes ??
Game(size_t playersNum, std::pair<size_t, size_t> sz);
void begin();
void step();
void end();
};

View file

@ -45,4 +45,8 @@ namespace map {
}
return way;
}
void generate() {
}
}

View file

@ -26,5 +26,6 @@ namespace map {
std::pair<size_t, size_t> start,
std::pair<size_t, size_t> end);
void generate();
};
}

View file

@ -1,14 +1,19 @@
#include <curses.h>
#include <cstdlib>
#include "game/game.hpp"
#include "out_api/init.hpp"
#include "out_api/menu_draw.hpp"
#include "out_api/game_draw.hpp"
int main() {
Game game(2, {100, 100});
game.begin();
init::begin();
while (!init::stop()) {
game_draw::drawAll();
game.step();
init::step();
}
init::end();
init::end();
game.end();
}

View file

@ -6,10 +6,13 @@
#include "input.hpp"
namespace init {
WINDOW* stdscr;
void begin() {
initscr();
stdscr = initscr();
noecho();
curs_set(false);
nodelay(stdscr, true);
draw::begin();
input::begin();
}

View file

@ -14,7 +14,7 @@ namespace input {
}
void step() {
lastInput = getch();
}
void end() {

View file

@ -1,8 +1,10 @@
#include <cstdint>
#include <curses.h>
#pragma once
namespace input {
char lastInput = ERR;
void begin();

View file

@ -0,0 +1,12 @@
#include <set>
#pragma once
// add keyboard to keys rebinding for each InputController
class InputController {
private:
public:
InputController()
};