Wasn't quite done afterall. Realized that I was still using all uppercase but was no longer targetting the pre-//e machines so updated all text. Also, clear the keyboard buffer after animations to prevent accidental moves

This commit is contained in:
Jeremy Rand 2014-07-25 21:45:44 -05:00
parent 467610fd93
commit c9a2ab0abe

44
ui.c
View File

@ -50,27 +50,27 @@ void printInstructions(void)
printf( printf(
// 0000000001111111111222222222233333333334 // 0000000001111111111222222222233333333334
// 1234567890123456789012345678901234567890 // 1234567890123456789012345678901234567890
" APPLE 2048\n" " Apple 2048\n"
"\n" "\n"
"USE I-J-K-M OR THE ARROW KEYS TO SLIDE\n" "Use I-J-K-M or the arrow keys to slide\n"
"ALL TILES IN A DIRECTION. MATCHING\n" "all tiles in a direction. Matching\n"
"TILES ARE ADDED TOGETHER TO MAKE A NEW\n" "tiles are added together to make a new\n"
"TILE. ON EVERY MOVE, ONE MORE TILE IS\n" "tile. On every move, one more tile is\n"
"ADDED WITH A RANDOM VALUE OF EITHER 2\n" "added with a random value of either 2\n"
"OR 4.\n" "or 4.\n"
"\n" "\n"
"PLAY ENDS WHEN ALL TILES ARE OCCUPIED\n" "Play ends when all tiles are occupied\n"
"AND NO MORE MOVES ARE POSSIBLE. TRY\n" "and no more moves are possible. Try\n"
"TO GET THE LARGEST TILE YOU CAN!\n" "to get the largest tile you can!\n"
"\n" "\n"
"PRESS ESCAPE OR Q TO QUIT AT ANY TIME.\n" "Press escape or Q to quit at any time.\n"
"PRESS R TO START A NEW GAME.\n" "Press R to start a new game.\n"
"PRESS S TO TOGGLE SOUND.\n" "Press S to toggle sound.\n"
"PRESS H TO SEE THIS INFO AGAIN.\n" "Press H to see this info again.\n"
"\n" "\n"
"\n" "\n"
"\n" "\n"
" PRESS ANY KEY TO START"); " Press any key to start");
// The amount of time the user waits to read the in // The amount of time the user waits to read the in
while (!kbhit()) while (!kbhit())
@ -132,12 +132,12 @@ static void printScore(void)
tScore highestTile = highestTarget(); tScore highestTile = highestTarget();
gotoxy(0,20); gotoxy(0,20);
printf("SCORE: %10ld HI-SCORE: %10ld\n", currentScore(), highScore()); printf("Score: %-9ld High Score: %-9ld\n", currentScore(), highScore());
if (highestTile == 0) { if (highestTile == 0) {
printf("TRY TO GET THE %ld TILE!\n", nextTarget()); printf("Try to get the %ld tile!\n", nextTarget());
} else { } else {
printf("GOT %ld! NOW GET %ld!\n", highestTile, nextTarget()); printf("Got %ld! Now get %ld!\n", highestTile, nextTarget());
} }
} }
@ -145,6 +145,10 @@ static void printScore(void)
void printBoard(void) void printBoard(void)
{ {
performAnimations(); performAnimations();
if (kbhit())
cgetc();
printGrid(); printGrid();
printValues(); printValues();
printScore(); printScore();
@ -154,7 +158,7 @@ void printBoard(void)
void gameWon(void) void gameWon(void)
{ {
gotoxy(0, 22); gotoxy(0, 22);
printf("YOU HAVE WON THE GAME! PRESS SPACE...\n"); printf("You have won the game! Press space...\n");
while (cgetc() != ' ') while (cgetc() != ' ')
; ;
clrscr(); clrscr();
@ -165,7 +169,7 @@ void gameWon(void)
void gameLost(void) void gameLost(void)
{ {
gotoxy(0, 22); gotoxy(0, 22);
printf("SORRY, NO MORE MOVES. PRESS SPACE..."); printf("Sorry, no more moves. Press space...");
while (cgetc() != ' ') while (cgetc() != ' ')
; ;
clrscr(); clrscr();