Add player and game loop
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "prettynames.h"
|
||||
#include "player.h"
|
||||
#include "random.h"
|
||||
#include "world.h"
|
||||
|
||||
int main() {
|
||||
uint32_t seed;
|
||||
printf("Enter seed: ");
|
||||
scanf("%u", &seed);
|
||||
if (scanf("%u", &seed) != 1) {
|
||||
printf("Invalid seed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ch = 0;
|
||||
while ((ch = getchar()) != '\n' && ch != EOF) {}
|
||||
|
||||
set_random_seed(seed);
|
||||
|
||||
world_t world;
|
||||
@@ -33,5 +42,16 @@ int main() {
|
||||
centre->is_discovered ? "true" : "false"
|
||||
);
|
||||
|
||||
player_t player = player_create(x, y);
|
||||
char action[128];
|
||||
for (;;) {
|
||||
printf(">");
|
||||
fflush(stdout);
|
||||
if (fgets(action, sizeof(action), stdin) == NULL) break;
|
||||
|
||||
action[strcspn(action, "\n")] = '\0';
|
||||
player_process_action(&player, action);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user