This commit is contained in:
Racoonicorn 2017-01-06 18:14:10 +01:00 committed by GitHub
parent 194ec47ba8
commit 7835fd73af
1 changed files with 8 additions and 16 deletions

View File

@ -1,7 +1,7 @@
#define VERSION "0.10" #define VERSION "0.11"
#define N 512 #define N 512
#define SPEED 30000 // less is more #define DELAY 25 // milliseconds
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
@ -12,7 +12,6 @@
void printm(); void printm();
void play(); void play();
void move_ptr(int direction); void move_ptr(int direction);
void waitfor(int delay);
void menu(); void menu();
void readfiles(); void readfiles();
void ranking(); void ranking();
@ -164,6 +163,7 @@ void play() {
ptr.x = level[selected.pos].start.x; ptr.x = level[selected.pos].start.x;
ptr.y = level[selected.pos].start.y; ptr.y = level[selected.pos].start.y;
do { do {
flushinp();
printm(); printm();
refresh(); refresh();
direction = getch(); direction = getch();
@ -222,7 +222,7 @@ void move_ptr(int direction) {
if (checkwin() == 1) { if (checkwin() == 1) {
break; break;
} else { } else {
waitfor(SPEED); napms(DELAY);
} }
} break; } break;
case KEY_RIGHT: case KEY_RIGHT:
@ -234,7 +234,7 @@ void move_ptr(int direction) {
if (checkwin() == 1) { if (checkwin() == 1) {
break; break;
} else { } else {
waitfor(SPEED); napms(DELAY);
} }
} break; } break;
case KEY_UP: case KEY_UP:
@ -246,7 +246,7 @@ void move_ptr(int direction) {
if (checkwin() == 1) { if (checkwin() == 1) {
break; break;
} else { } else {
waitfor(SPEED); napms(DELAY);
} }
} break; } break;
case KEY_DOWN: case KEY_DOWN:
@ -258,7 +258,7 @@ void move_ptr(int direction) {
if (checkwin() == 1) { if (checkwin() == 1) {
break; break;
} else { } else {
waitfor(SPEED); napms(DELAY);
} }
} break; } break;
default: return; default: return;
@ -377,7 +377,7 @@ void ranking() {
struct dataresult temp; struct dataresult temp;
char *time_string[N]; char *time_string[N];
readfiles(); readfiles();
// reord data // sort data
for (i = 0; data[i].moves != 0; i++) { for (i = 0; data[i].moves != 0; i++) {
for (j = i + 1; data[j].moves != 0; j++) { for (j = i + 1; data[j].moves != 0; j++) {
if (data[i].moves > data[j].moves) { if (data[i].moves > data[j].moves) {
@ -432,11 +432,3 @@ int checkwin() {
} }
else return 0; else return 0;
} }
void waitfor(int delay) {
int time_a, time_b;
time_a = clock();
do {
time_b = clock();
} while (time_b < time_a + delay);
}