Help with first text based game

Hi,
I've just started a course in Computer Games Programming
So far I've been doing fine but I just need a bit more help adding characters and keeping track of them in the game.

My game is a text based space adventure game.

I would like to add a character to the game and give the option for the player to be able to choose what character they would like to be. I would also like to be able to keep track of that character, either via a visual add e.g. an ASCII map that stays on screen constantly or just have it running in the background.

Also, I have seen a lot of controversy on the forums about using the system clear screen. What should I use instead of it? as I want my screen to be cleared after each answer is given which gives a nice new slate for a new question.

Here is the code I have so far. It's been fiddled around with a lot so it may be wrong, feel free to correct me on any of it as I am new to this and need to learn.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "stdafx.h"
#include <iostream>
#include <string>

//a1 start
//b1 turrets //b2 dodge //b3 forward //b4 scream

int _tmain()
{
	using namespace std;

	string myname;
	string ans1;

	cout     << "\t\t\t*----------------------------*\n"
		 << "\t\t\t*    Space Game: Welcome     *\n"
		 << "\t\t\t*----------------------------*\n";

	cout << "\n\nWhat's your name, co-pilot?\n\n";

	cin >> myname;

	cout << "\n\nWell, the pilot's dead and you need to take charge " << myname << ". Your ship is falling apart and both your turrets have been taken out. I doubt we could take another shot from the enemy. You've got a few choices, either you could send men to fix the (turrets) and try to fight the enemy, you could try using evasive piloting and (dodge) the enemies attack, you could just keep going (forward) and possibly suffer more damage to your ship, or run up and down the ship (scream)ing\n\n";

	cin >> ans1;

	if (ans1 == "turrets")
	{
		cout << "\nYour men failed to fix the turrets, they're too heavily damaged, you also took more damage from the enemy ship.\n"
		     << "\n(1). Attempt to fix turrets again\n\n(2). Attempt to fix damage\n\n";
		
	}
	else if (ans1 == "dodge")
	{
		cout << "\nYou're piloting skills are paying off. You're starting to lose the enemy.\n"
			 << "\nYou see ship up ahead, do you risk trying to communicate with the it?\n"
			 << "\n1. COMMUNICATE\n\n2. DO NOT COMMUNICATE\n\n";
		
	}
	else if (ans1 == "forward")
	{
		cout << "\nYou're one lucky son of a b***h. The enemies ship seems to be slowing down.\n"
			 << "\nYou see ship up ahead, do you risk trying to communicate with the it?\n"
			 << "\n(1). COMMUNICATE\n\n(2). DO NOT COMMUNICATE\n\n";
		
	}
	else if (ans1 == "scream")
	{
		cout << "\nWhat the f**k are you doing? Your crew members are scared of you. One of them just pissed his pants because you screamed in his face. Dude, wtf.\n"
		     << "\nThe enemy ship seems to be charging up for a HUGE shot. DO NOT get hit by this\n"
			 << "\n(1). Attempt to dodge\n\n.(2). Stay still and hope they have Stevie Wonders eyesight\n\n";
		
	}
		
	

	system ("PAUSE");

	return 0;
}


Also how should I approach adding more questions to the ones I already have? As I understand, it's bad to use if statements constantly.
Thanks in advance for whoever can get back to me.
Last edited on
http://stackoverflow.com/questions/1508490/how-can-i-erase-the-current-line-printed-on-console-in-c-i-am-working-on-a-lin

When I made a game with a map, I just used system("clear");
Then printed the updated map.

But if you aren't allowed to clear, try the above.
Topic archived. No new replies allowed.