mirror of
https://github.com/ProgramSnail/rts_game_backend.git
synced 2026-01-25 21:07:08 +00:00
some additional functions
This commit is contained in:
parent
8553878b4a
commit
5173f4f2a9
23 changed files with 214 additions and 24 deletions
|
|
@ -1,21 +1,8 @@
|
|||
#include "draw.hpp"
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <curses.h>
|
||||
#include "draw.hpp"
|
||||
|
||||
namespace draw {
|
||||
|
||||
enum Color {
|
||||
black = 0,
|
||||
red = 1,
|
||||
green = 2,
|
||||
yellow = 3,
|
||||
blue = 4,
|
||||
magneta = 5,
|
||||
cyan = 6,
|
||||
white = 7,
|
||||
};
|
||||
|
||||
void initColorPairs() {
|
||||
init_pair(ColorScheme::simple, COLOR_BLACK, COLOR_WHITE);
|
||||
init_pair(ColorScheme::active, COLOR_WHITE, COLOR_BLACK);
|
||||
|
|
@ -25,24 +12,19 @@ namespace draw {
|
|||
init_pair(ColorScheme::player3, COLOR_BLACK, COLOR_YELLOW);
|
||||
init_pair(ColorScheme::neutral, COLOR_WHITE, COLOR_GREEN);
|
||||
init_pair(ColorScheme::enviroment, COLOR_BLACK, COLOR_WHITE);
|
||||
init_pair(ColorScheme::damaged, COLOR_RED, COLOR_WHITE);
|
||||
}
|
||||
|
||||
void begin() {
|
||||
initscr();
|
||||
noecho();
|
||||
curs_set(false);
|
||||
start_color();
|
||||
initColorPairs();
|
||||
}
|
||||
|
||||
void step() {
|
||||
refresh();
|
||||
usleep(STEP_DELAY_USEC);
|
||||
}
|
||||
|
||||
void end() {
|
||||
endwin();
|
||||
}
|
||||
void end() {}
|
||||
|
||||
void clearAll() {
|
||||
clear();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <cstdint>
|
||||
#include <curses.h>
|
||||
|
||||
#pragma ONCE
|
||||
|
||||
namespace draw {
|
||||
|
||||
|
|
@ -11,6 +12,7 @@ namespace draw {
|
|||
player2,
|
||||
player3,
|
||||
neutral,
|
||||
damaged,
|
||||
enviroment
|
||||
};
|
||||
|
||||
|
|
@ -23,8 +25,6 @@ namespace draw {
|
|||
unit = '#'
|
||||
};
|
||||
|
||||
const uint32_t STEP_DELAY_USEC = 30000;
|
||||
|
||||
void begin();
|
||||
|
||||
void step();
|
||||
|
|
|
|||
27
src/out_api/init.cpp
Normal file
27
src/out_api/init.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <curses.h>
|
||||
#include "init.hpp"
|
||||
#include "draw.hpp"
|
||||
#include "input.hpp"
|
||||
|
||||
namespace init {
|
||||
void begin() {
|
||||
initscr();
|
||||
noecho();
|
||||
curs_set(false);
|
||||
draw::begin();
|
||||
input::begin();
|
||||
}
|
||||
|
||||
void step() {
|
||||
draw::step();
|
||||
usleep(STEP_DELAY_USEC);
|
||||
}
|
||||
|
||||
void end() {
|
||||
draw::end();
|
||||
input::end();
|
||||
endwin();
|
||||
}
|
||||
}
|
||||
14
src/out_api/init.hpp
Normal file
14
src/out_api/init.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <cstdint>
|
||||
|
||||
#pragma ONCE
|
||||
|
||||
namespace init {
|
||||
|
||||
const uint32_t STEP_DELAY_USEC = 30000;
|
||||
|
||||
void begin();
|
||||
|
||||
void step();
|
||||
|
||||
void end();
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#include <cstdlib>
|
||||
#include <curses.h>
|
||||
#include "input.hpp"
|
||||
|
||||
namespace input {
|
||||
void begin() {
|
||||
|
||||
}
|
||||
|
||||
void step() {
|
||||
|
||||
}
|
||||
|
||||
void end() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#include <cstdint>
|
||||
|
||||
#pragma ONCE
|
||||
|
||||
namespace input {
|
||||
|
||||
void begin();
|
||||
|
||||
void step();
|
||||
|
||||
void end();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue