I am making a text-based adventure game. How should I go about changing to another scene if the player wants to e.g. go to the house or walk down the road?
I am using Objective C, but C will work also. Here is my code so far:
printf("Welcome to Kingdom Quest! This is a text game.\nYou will be shown what is going on ");
printf("and it is up to you to decide what to do. Use words like get, go and pick up.\nDo not use any upper case letters.");
printf("\n\nYou are in a feild and it is almost nighttime. You are facing north. The only thing you have is an empty ruksak.");
printf("\nWhere do you want to go");
printf("\n>");
while (true) {
char string[256];
fgets(string, 255, stdin);
if (strcmp(string, "go north\n") == 0 || (strcmp(string, "go n\n") == 0))
{
printf("There is a rusty old sword on the ground.");
printf("\n>");
}
else if (strcmp(string, "get sword\n") == 0 || (strcmp(string, "pick up sword\n") == 0))
{
printf("Sword taken.");
printf("\n>");
}
else if (strcmp(string, "go south\n") == 0 || (strcmp(string, "go s\n") == 0))
{
printf("Nothing is this way.");
printf("\n>");
}
else if (strcmp(string, "go east\n") == 0 || (strcmp(string, "go e\n") == 0))
{
printf("There is a dirt road here.");
printf("\n>");
}
else if (strcmp(string, "go west\n") == 0 || (strcmp(string, "go w\n") == 0))
{
printf("There is a small mountain up ahead, with a house on top of it.");
printf("\n>");
}
else
{
printf("What?");
printf("\n>");
}