Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to start an RPG game

This thread is locked; no one can reply to it. rss feed Print
How to start an RPG game
thirdy
Member #8,409
March 2007
avatar

Hi! I'm a newbie, last sem, I had C programming class then started making games + allegro, and I manage to make a simple RPG and posted in the depot. Right now, we have java but I got dissapointed because java is soo sloow.

Now I'm back to C to make another RPG game, search posts about rpg's and collision detections(w/c I didn't do b4). And I found this list of stuffs for programming an RPG game.

1http://allegro.cc/forums/thread/211124/211238#target
2 
3: Tilemap manager. Handles drawing the tilemap.
4 
5: Sprite Animation manager. Handles drawing and animating sprites.
6 
7: Console-RPG-style UI. User interface that display's stats,
8 equipment info, etc in a console-RPG style.
9
10: Basic collision detection. Collision detection between sprites and the tiles.
11 Perhaps just sprites cannot overlap with certain objects.
12
13: Basic RPG stat/item system. Contains dealing with characters, weapons, items,
14 equipment, etc.
15
16: Map interface. Handles going from one tilemap to another.
17
18: NPC interface. Handles NPC objects.
19
20: Combat manager. Handles fighting.
21
22: Game-specific code. Handles making your game your game. The previous stuff
23 could/would be a part of any console-style RPG. This is where the stuff goes that
24 makes this game yours.
25
26: Font drawing system. Draws characters in a particular font.
27
28: Loader. Handles loading data and passing it to the appropriate system.
29
30: Tilemap editor. Used to create tilemaps.
31
32: Sprite animation editor. Used to create sprite animations.
33
34: Image editor. Used to create images for tiles or sprites.
35
36: Font generator. Used to create fonts.
37
38: UI layout tool. Used to create UI screens.

Any recommendations where can I find these tools and libs? how to's and tutorials?
I plan on making a 2D RPG but FF7 different camera views style. And how bout 3D? Are there any easy ways to easilly learn it and include it in my RPG? Or should I just learn it later?
I Also downloaded collegro and MapSlapper but haven't tried them yet.
Thanks!!!

TeamTerradactyl
Member #7,733
September 2006
avatar

thirdy:

This list that you posted: is it what was recommended or required by your teacher/professor, or is this just something you wanted to do yourself?

I would start with someone else's tilemap. You can get your game built and working, and at least know that it's drawing to screen correctly. Then you'll need to modify the tilemap so it's your own later so you're not just ripping off someone else's work.

You can do collision detection with tiles in a few different ways. The two more common approaches are:
* Certain tiles will ALWAYS be impassible (can't move onto or through them)
* Parts of the map have an "obstacle" attribute so you can choose what can be walked on and what can't

My personal favorite is the latter for both side-scrollers and top-down games.

For the image drawing/painting, check out some of the discussions on "good tile editors" here.

spellcaster
Member #1,493
September 2001
avatar

I'd suggest that you start with a roguelike game.
It's pretty simple to do, you won't have to struggle for gfx - and it's a rpg.

http://en.wikipedia.org/wiki/Roguelike

I know that's not what you had in mind, but it's a task you can actually complete ;)

--
There are no stupid questions, but there are a lot of inquisitive idiots.

gnolam
Member #2,030
March 2002
avatar

Short answer: you code them yourself.

Slightly longer answer: you won't find libraries for all that (as that would, in fact, make a complete game sans the content). So you find libraries for the most difficult or tedious tasks and code the rest yourself.

The answer you don't want: this project looks like it might be over your head. Try starting with something simpler, like, say, a Tetris clone.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Paul whoknows
Member #5,081
September 2004
avatar

Begin with these, in this order:

1 : Sprite Animation manager. Handles drawing and animating sprites.

2 : Tilemap manager. Handles drawing the tilemap.

3 : Basic collision detection. Collision detection between sprites and the tiles.
Perhaps just sprites cannot overlap with certain objects.

After you finish those, come back again.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Jonatan Hedborg
Member #4,886
July 2004
avatar

A simple text-based RPG could be a good start. It can have all the parts of a regular RPG (story, character-advancement, items, combat etc), and it can be done using only ANSI C functions :) (though that could be kind of dull, you may want to look at ncurses - just for coloured output).

thirdy
Member #8,409
March 2007
avatar

Ok, maybe I'm not a newbie, but I still consider myself one. Not to boast, here's what I did last year, http://allegro.cc/depot/ProjectJem/, took me 2 long weeks to make it.

I did that prototype rpg game without even knowing that the stuff on my list existed, I don't even know what a tilemap exactly means until now.
But if you code them all yourself like gnolam said, then I'll just ask one more question.

How do you code for restricting the player from overpassing a road?
Create a bounding box for the whole road and the player? What if I have lot's of roads? And also for the numerous objects in a certain map(tileset?)?

spellcaster
Member #1,493
September 2001
avatar

Take a look at this:
http://www.gamedev.net/reference/articles/article728.asp
It should answer most of your questions.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Simon Parzer
Member #3,330
March 2003
avatar

Quote:

How do you code for restricting the player from overpassing a road?

The most basic approach: Every tile in the map has an attribute: "solid" which is either 0 or 1.
You simply make all of the road tiles solid and the player can't walk over it.

Neil Black
Member #7,867
October 2006
avatar

That's how I did my early RPG, which was in QBASIC and never fully completed, actually I got to the point where I had the character walking around, then I got to the point where I moved to C++, so I never actually got to the point where I worked on that again.

spellcaster said:

Take a look at this

I saw that one before, it looked pretty good.

thirdy
Member #8,409
March 2007
avatar

So if I have a large bitmap as my background map, divide it into a grid of squares. Then, every squares would have a walkable flag of 1 or 0?
If the player moves call,

1check_move_player(
2short int north_sq,
3short int south_sq,
4short int west_sq,
5short int east_sq,
6short int northE_sq,
7short int northW_sq,
8short int southW_sq,
9short int southE_sq,
10int player_pos_X, int player_pos_Y )
11{
12
13 // increment player_pos_X if west_sq is 1;
14 // decrement player_pos_X if east_sq is 1;
15 // increment player_pos_Y if north_sq is 1;
16 // decrement player_pos_Y if south_sq is 1;
17 
18 // increment both player_pos_X and player_pos_Y if northE_sq is 1;
19 // do the same logic with northW_sq, southW_sq, southE_sq;
20 
21}

Is this a good implementation?

Trezker
Member #1,739
December 2001
avatar

Ow, nasty function there. I'd have only one parameter for direction with values 1-8, one for each direction and use defines to name each.

1#define north_sq 1
2#define south_sq 2
3#define west_sq 3
4#define east_sq 4
5#define northE_sq 5
6#define northW_sq 6
7#define southW_sq 7
8#define southE_sq 8
9check_move_player(int player_pos_X, int player_pos_Y, int direction)
10{
11 // increment player_pos_X if direction is west_sq;
12 // decrement player_pos_X if direction is east_sq;
13 // increment player_pos_Y if direction is north_sq;
14 // decrement player_pos_Y if direction is south_sq;
15 
16 // increment both player_pos_X and player_pos_Y if direction is northE_sq;
17 // do the same logic with northW_sq, southW_sq, southE_sq;
18}

thirdy
Member #8,409
March 2007
avatar

Ow, that function is different..

Tobias Dammers
Member #2,604
August 2002
avatar

Quote:

So if I have a large bitmap as my background map

Usually, you don't, which is part of the tile map beauty.
A tile map means that you have a grid of (usually) square cells. Each cell has certain properties, among others, a 'walkable' flag and a bitmap pointer (or index into a global array). Often, these are linked to one another, i.e., the cell itself only contains a single index into a tile type table (a global array), which then contains a pointer to the corresponding bitmap, and the appropriate flags.
Example.
Say you have 3 kinds of tiles: GRASS, DIRT, and WATER. Both grass and dirt are walkable, but they have different bitmaps associated with them. Water has yet another bitmap, and it is not walkable. The tile type list might then look like this:

1struct TILETYPE {
2 bool walkable;
3 int dat_index; // I assume that you have loaded a datafile and included the corresponding header
4};
5 
6enum {
7 TILE_GRASS,
8 TILE_DIRT,
9 TILE_WATER
10};
11 
12TILETYPE tiletype[NR_TILETYPES] = {
13 { true, GRASS_TILE_BMP },
14 { true, DIRT_TILE_BMP },
15 { false, WATER_TILE_BMP }
16};

Then your tilemap is simple a 2D array (or a 1D array with clever functions to make it work like a 2D one) of indices (ints) into the global tiletype table.

The next thing you need to understand is that a tile grid has its own coordinate system, or 'space'. I use the terms 'world space' (or 'screen space') and 'tile space' to distinguish between them. The character walks in world space, but tile coordinates are in tile space. To convert between them, you need to multiply or divide by the tile size. So if you want to know which tile the character is on, you do this:

tx = character.x / tile_w;
ty = character.y / tile_h;

Note that this works only for point-shaped characters that have no logical size (they are exactly zero pixels high and wide).
Conversely, if you want to know the world space coordinates of a given tile at (tx;ty), or more specifically, the top-left corner of that tile, multiply by tile size:

world_x = tx * tile_w;
world_y = ty * tile_h;

Putting it together; to find out whether the character can move from point (ax;ay) to (bx;by), you need to do the following:
1. Find the first tile edge the character will encounter (one where x % tile_w == 0 or y % tile_h == 0).
2. Walk until the point you have found.
3. Find the next tile you would walk on, and check if it is walkable
4. If it is, repeat steps 1 to 3 until you reach the destination. Otherwise, you cannot move further.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Go to: