Add huge matrix support

This commit is contained in:
Racoonicorn 2017-01-03 21:24:52 +01:00 committed by GitHub
parent 230d58e9c3
commit 00e6eddabe
1 changed files with 28 additions and 6 deletions

View File

@ -1,14 +1,13 @@
#define VERSION "0.01" #define VERSION "0.10"
#define N 512 #define N 512
#define SPEED 50000 // less is more #define SPEED 30000 // less is more
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ncurses.h> #include <ncurses.h>
#include <unistd.h>
void printm(); void printm();
void play(); void play();
@ -269,13 +268,36 @@ void move_ptr(int direction) {
} }
void printm() { void printm() {
int i, j; int i, j, a = 1, b = 1;
int left = 0, right = 0, up = 0, down = 0;
clear(); clear();
printw("Level %d.%d: %s. Moves: %d. Use arrows to move.\nRetry [r]. Quit [q]\n\n", level[selected.pos].world, level[selected.pos].num, level[selected.pos].name, moves); printw("Level %d.%d: %s. Moves: %d. Use arrows to move.\nRetry [r]. Quit [q]\n\n", level[selected.pos].world, level[selected.pos].num, level[selected.pos].name, moves);
if (level[selected.pos].height > 9 || level[selected.pos].width > 9) if (level[selected.pos].height > 9 || level[selected.pos].width > 9)
printw("Warning! Keep this window in fullscreen mode please\n\n\n"); printw("Warning! Keep this window in fullscreen mode please\n\n\n");
for (i = 0; i < level[selected.pos].height; i++) { while (left + right < 18 && (a == 1 || a == 2)) {
for (j = 0; j < level[selected.pos].width; j++) { a = 0;
if (ptr.x - left - 1 > 0) {
left++;
a++;
}
if (ptr.x + right + 1 < level[selected.pos].width) {
right++;
a++;
}
}
while (up + down < 18 && (b == 1 || b == 2)) {
b = 0;
if (ptr.y - up - 1 > 0) {
up++;
b++;
}
if (ptr.y + down + 1 < level[selected.pos].height) {
down++;
b++;
}
}
for (i = ptr.y - up - 1; i <= ptr.y + down; i++) {
for (j = ptr.x - left - 1; j <= ptr.x + right; j++) {
if (i == ptr.y && j == ptr.x) { if (i == ptr.y && j == ptr.x) {
printw("YOU"); printw("YOU");
} else { } else {