mirror of
https://github.com/jeremysrand/apple2048.git
synced 2025-04-10 12:39:18 +00:00
More basic gameplay work. Now we set a random seed based on the time the user looks at the instructions
This commit is contained in:
parent
0902ec0f79
commit
910b2aa1ad
39
apple2048.c
39
apple2048.c
@ -5,6 +5,43 @@
|
||||
#include "game.h"
|
||||
|
||||
|
||||
void printInstructions(void)
|
||||
{
|
||||
int seed = 0;
|
||||
|
||||
clrscr();
|
||||
printf(
|
||||
// 0000000001111111111222222222233333333334
|
||||
// 1234567890123456789012345678901234567890
|
||||
" APPLE 2048\n"
|
||||
"\n"
|
||||
"USE I-J-K-M OR THE ARROW KEYS TO SLIDE\n"
|
||||
"ALL TILES IN A DIRECTION. MATCHING\n"
|
||||
"TILES ARE ADDED TOGETHER TO MAKE A NEW\n"
|
||||
"TILE. ON EVERY MOVE, ONE MORE TILE IS\n"
|
||||
"ADDED WITH A RANDOM VALUE OF EITHER 2\n"
|
||||
"OR 4.\n"
|
||||
"\n"
|
||||
"PLAY ENDS WHEN ALL TILES ARE OCCUPIED\n"
|
||||
"AND NO MORE MOVES ARE POSSIBLE. TRY\n"
|
||||
"TO GET THE LARGEST TILE YOU CAN!\n"
|
||||
"\n"
|
||||
"PRESS ESCAPE OR Q TO QUIT AT ANY TIME.\n"
|
||||
"PRESS R TO START A NEW GAME.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" PRESS ANY KEY TO START");
|
||||
|
||||
while (!kbhit())
|
||||
seed++;
|
||||
|
||||
cgetc();
|
||||
srand(seed);
|
||||
}
|
||||
|
||||
|
||||
void printBoard(void)
|
||||
{
|
||||
tPos x;
|
||||
@ -103,6 +140,8 @@ void handleNextEvent(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printInstructions();
|
||||
|
||||
initGame();
|
||||
|
||||
while (true) {
|
||||
|
3
game.c
3
game.c
@ -167,6 +167,9 @@ void slideInDirection(tDir dir)
|
||||
// the same tile in a single turn. We set the value to a high
|
||||
// negative (< -1) and then flip the sign bit later.
|
||||
gTileValues[destPos] = -tileValue;
|
||||
|
||||
if (tileValue == gNextTarget)
|
||||
gNextTarget++;
|
||||
} else {
|
||||
gTileValues[destPos] = gTileValues[pos];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user