-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursesMatrix.cpp
45 lines (40 loc) · 1.14 KB
/
cursesMatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "cursesMatrix.h"
#include "logger.h"
#include <ncurses.h>
#include <unistd.h>
using namespace std;
void cursDisplayPattern(int yOffset, int xOffset,
const uint64_t pattern[8][8]) {
for (int y = yOffset; y <= 14 + yOffset; y += 2) {
for (int x = xOffset; x <= 28 + xOffset; x += 4) {
attron(pattern[(y - yOffset) / 2][(x - xOffset) / 4]);
mvprintw(y, x, " ");
attroff(pattern[(y - yOffset) / 2][(x - xOffset) / 4]);
}
}
refresh();
}
void cursUpdateLevel(int yOffset, int xOffset, float xa, float ya) {
cursDisplayPattern(yOffset, xOffset, patterns[1]);
int x = (int)(xa * -30.0 + 4);
int y = (int)(ya * -30.0 + 4);
if (x < 0) {
x = 0;
} else if (x > 6) {
x = 6;
}
if (y < 0) {
y = 0;
} else if (y > 6) {
y = 6;
}
int virtualY = ((y * 2) + yOffset);
int virtualX = ((x * 4) + xOffset);
attron(CYELLOW);
mvprintw(virtualY, virtualX, " ");
mvprintw(virtualY, virtualX + 4, " ");
mvprintw(virtualY + 2, virtualX, " ");
mvprintw(virtualY + 2, virtualX + 4, " ");
// printw("(%d, %d), virtual(%d, %d)", x, y, virtualX, virtualY);
attroff(CYELLOW);
}