Creating simple text games???

Simo said:
I am interested in making some simple text games just as a novelty. I remember back from my school days things like this example:

'Do you enter cave' y/n
if y do this
if no do this etc etc

I am just after simple programming to start with as a bit of fun, things have probably changed a lot since I was at school and may not even be done like that anymore. Possible adding pictures may be easy now, I dont know. Where would be a good place to start learning as I am a complete novice?

Thank you.

Reminds me of the first game I tried to make in GWBasic (TRS-80).

If you want to add pictures, you can either read up on a lot of complex graphics stuff in C++, or go with a more graphical version (Visual C++ -- which is even MORE complex!, C#, or Visual Basic).

I would suggest C++ (get a free compilier if you can). Borland C++ 4.52 is decent, however it is older, and some code for modern systems may or may not work.

I'd also start off text-based.

For a yes/no type game, I'd probably use a structure with these variables (or something similar):

previous
next
currentText

and maybe room for any special options you might want. In this instance, this is a simple, linear yes/no game. If you wanted directions, you could do that too. Each variable would hold the array of the structure you want to look at next.

You could get the data 2 ways:

1 - By hard-coding it.
2 - By creating code to read from a file.

EDIT: Here's a *VERY* simple example:

Code:
#include <iostream.h>

struct DESCRIPT
{
char* desc;
int yes;
int no;
int endpoint;

}desc[3];

void main(void)
{
	int selection = 0;
	int gameover = 0;
	// Initialize Structure
	desc[0].desc = "You see a river in front of you.\nWhat do you do? 1 = swim - 2 = build a bridge.";
	desc[0].yes = 1;
	desc[0].no = 2;
	desc[0].endpoint = 0;

	desc[1].desc = "You have too much armor on and drown! Game over!";
	desc[1].yes = 0;
	desc[1].no = 0;
	desc[1].endpoint = 1;

	desc[2].desc = "You crossed the river and won! Congrats!";
	desc[2].yes = 0;
	desc[2].no = 0;
	desc[2].endpoint = 1;

	// Game loop -- VERY simplified. Do not enter a character (a-z, A-Z)
	// Or else an infinite loop may occur!
	while(!desc[selection].endpoint == 1)
	{
		cout << desc[selection].desc << endl;
		cin >> selection;
	}
	// It's the end of the game. Display the last message.
	cout << desc[selection].desc << endl;
}

Note that there's no error checking for non-digit values.
 
I made a kickass Jeopardy game on my TI-83. 20-odd questions, including three that you couldn't POSSIBLY know (Why is Paul so Uber? How many angels can fit on the head of a pin? During which chapter of TSR did Rand arrive at Alcair Dal?), just over 7k in size, and a lotta junk code in there. My TI-83 died though, so I'm going to have to make it all over again...
 
Back
Top Bottom