im working on a text based combat system

Pages: 12
and i would like to assign actions... to a button on the keyboard can any1 give me a hand with this?
if your doing console work using standard library, this will be at best turn based.
So pretty simple to set up, if input = 1, or if input = F1, do some action, if F5 do something else.
You can have a play around with something like this i whooped up quick. Will give you some ideas.

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <windows.h>

// Player structure
struct Player
{
	int x, y;						// player position
	char display;					// how the player will display in console
};

bool UpdateMovement(Player& p)
{
	// GetAsyncKeyState isn't the best function for input to you but it'll
	// give you a start into moving an object.
	if( GetAsyncKeyState('W') )
		if(p.y > 0)					// Boundry checking so we don't go out the array
			p.y--;

	if( GetAsyncKeyState('S'))
		if(p.y < 9)
			p.y++;

	if( GetAsyncKeyState('A') )
		if(p.x > 0)
			p.x--;

	if( GetAsyncKeyState('D') )
		if(p.x < 29)
			p.x++;

	if( GetAsyncKeyState('Q') )
		return false; // quit game

	return true;
}

bool DisplayMap(Player& p)
{
	// Reset the mouse cursor so we don't have to clear the screen
	COORD cursor = {0, 0};
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cursor);

	//        y   x
	char map[10][30];
	for( int y = 0; y < 10; y++ )
	{
		for( int x = 0; x < 30; x++ )
		{
			// Draw Map / terrain with ascii char 176
			map[y][x] = (char)176;
		}
	}
	// If UpdateMovement returns false then DisplayMap will return false.
	// Otherwise move on and display the map.
	if(!UpdateMovement(p))
		return false;

	// Change the position of the player on the map to the players image
	map[p.y][p.x] = p.display;

	// Display the map.
	for( int y = 0; y < 10; y++ )
	{
		for( int x = 0; x < 30; x++ )
		{
			std::cout << map[y][x];
		}
		std::cout << std::endl;
	}

	return true;
}

int main()
{
	// Hide The cursor so we don't see it flickering
	CONSOLE_CURSOR_INFO cci;
	cci.bVisible = false;
	cci.dwSize = 100;
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);

	Player player;
	player.x = 5;
	player.y = 5;
	player.display = (char)219; // player image

	// Value that checks if our game is still running
	bool running = true;
	while(running)
	{
		running = DisplayMap(player);
	}

	return 0;
}
Ugh

The console is a TERRIBLE medium for a game.

Get a basic game lib like SDL or something.

http://www.libsdl.org

Trying to finnagle the console into doing what you want is going to be 20x harder than using a lib designed to do exactly what you want.
Some people still find it fun though. I've seen a few full colored rpg's made in them which looked amazing. I'd agree it's easier using a lib, but some people still get a kick out of doing them in console.
I guess.

It is easier to output text to the console than using something like SDL... so that's one benefit.

But really, for a whole game, it's really impractical (that's not to say you can't do it .. just that it's a poor design decision). I guess you're right though, poor design decisions can be fun. =P

Personally I find console games to be dreadful. I can tolerate roguelikes like Moria and ADOM, but those are really really old games. Something in an actual Window is always much better, IMO.
I agree, but yeah it's as simple as they can still be fun :)
I don't think OP cares about that. It's more likely that OP cares about creating it. Not distributing it.

@OP, you should use the curses library: http://pdcurses.sourceforge.net/
Most of the TUI games Mythios are talking about probably use pd/ncurses.
Last edited on
Personally I find console games to be dreadful.


I like console games a lot because they generally have better gameplay (!?) because they don't have to focus on graphics as much. Same with 2d vs 3d games. Probably also to spite the idiots that think "graphics is the only thing that matters".
I like console games a lot because they generally have better gameplay (!?) because they don't have to focus on graphics as much. Same with 2d vs 3d games


What a load of crap.

Modern 3D games are more involved, complicated, thought out, and intricate than retro 2D games ever were. The improved graphics have not been anything but an additional perk.

The real problem is you're just getting too old for new games and you want something familiar.

I think there are some kids on your lawn you might want to yell at, grandpa. They're not wearing enough clothing and are using inappropriate language. ;D


(I tease, of course. No malice intended. However that really is a bogus argument)
Looking over the statement I just made, I actually have to agree that what I said *was* kind of stupid.

I don't think that modern 3D games are that much more complicated though. I can go and play a MUD and get just as good as of an RPG experience (IMO) then if I go pick up WoW.

I think there are some kids on your lawn you might want to yell at, grandpa. They're not wearing enough clothing and are using inappropriate language. ;D


ROFL! Gotta get out my 12-gauge!
Hey, hey, console games don't have to be shallow. The crappy ones are shallow. If you can find a good console game you will easily find that it is just as complicated, involved and thought out as ANY modern game. The graphics won't be as good but they have their own feel to them that is unique and pretty awesome IMO.
I supposed there's good and bad, shallow and deep in every genre, in every era.

You can pick out some key retro games that stand above the rest, but there were also TONS of really terrible games that you'll skip over in the process. Same goes for modern games.

On the whole, though, games have pretty consistently gotten "better" over time. I know "better" is a subjective term, but I stand by the general statement.

My previous point, though, was that "games these days focus too much on graphics and it detracts from the gameplay" is a stupid argument because it's not true, and the graphical quality does nothing but enhance the overall polish of the game.

Bringing this back to my original point in this thread: The console is a terrible medium for a game. I stand by that claim 150%.

Adding graphics is nothing but an improvement.

Something made in a console with different colored ASCII codes is ultimately going to be inferior and more awkward to use than something you could make just as easily with a graphical library.

I've played those old games too. I loved Moria and ADOM. But those games are from an era that's long gone. Hell even Angband had graphics.

It's 2010, people.
Last edited on
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Last edited on
My tip to the OP would be to go ahead and write the game either with console or SDL (if he is convinced by Disch already ;), but regardless whether he goes for console or graphics, he should try to structure the game in a way that changing to some other representation later doesn't completely throw everything out of structure.

If you are a programmer, you do not need to have the skills to draw beautifull graphics. And you may even get along when you don't have a clue how to work with libSDL, OpenGL, DirectX or whatever..

But if you are a programmer and you do NOT have the skill to separate graphic representation (whatever this may be) from pure background game logic, then you are in trouble ;). So that's a thing worth looking into it.

My 2 cents... ;-)

Ciao, Imi (who prefers Gothic over Manic Mansion over Zork because of the story improvments ;)
Last edited on
My previous point, though, was that "games these days focus too much on graphics and it detracts from the gameplay" is a stupid argument because it's not true, and the graphical quality does nothing but enhance the overall polish of the game.
Far Cry 2
I think you’re wrong Disch. Modern games are crap, older ones are better. Well, maybe not “ultra simple text based” games created 50 years ago, but still. Why this happened? It’s simple:

1) Modern games are much more complex/huge (I’m not talking about gameplay here, complexity is a result of audiovisual effects and realistic physics mostly), thus they’re more expensive. This effectively annihilates our chances to see revolutionary games in the future – nobody will take risk of creating such games. But we will see millions of watered-down clones of the existing, successful games.

2) Computer games are much more popular now than they were 10 or 20 years ago. This also decreases quality of games as nowadays, an average gamer just seeks for an easy and short entertainment. Notice that games with complex gameplay (RPGs or strategy games) practically died out long time ago.

Notice that these processes are not limited to the game industry only. Similar things happen for movies/music.

Sorry for offtopic:)
(RPGs or strategy games) practically died out long time ago.

Oh really?

Released in recent years:
Oblivion
Dawn of War 2
Company of Heroes
Fallout
Sins of a Solar Empire
Supreme Commander
Mass Effect
Dragon Age

Coming soon:
Starcraft 2
Diablo 3
Supreme Commander 2
Command & Conquer 4

That's all just to name a few. Perhaps you should inform those developers that RPGs and strategy games died out a long time ago.
You practically confirmed my diagnosis. Games like Oblivion, Fallout 3, Diablo don’t deserve to stand near real RPGs. Starcraft is a great game, but who said its sequel will be any good?

Although I must admit that I’m not familiar with some of those titles. If any of those games is not real-time then maybe we are not doomed yet:)
I confirmed your claim that RPGs and strategy games are dead by listing numerous successful examples of both that have been released in recent years? Interesting logic.

I make no claim as to their comparison with older games, and never did. That is an entirely subjective comparison that is nothing more than one's personal opinion.

Of course, the question that begs to be asked is, what is a 'real' RPG?
Pages: 12