• Advertisement
Sign in to follow this  

RPG tutorials?

This topic is 4149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for some good RPG coding tutorials. I have an RPG planned out, with the story and levels ready to code, but I can't figure out how to do code the engine! Please does anyone know any good tutorials on coding a basic RPG engine. If you're wondering I'm using Allegro with Dev-C++.

Share this post


Link to post
Share on other sites
Advertisement
P.S. It's a tile-based FFI style RPG. I can get the maps drawn on-screen with the player moving around, but I can't do things like NPCs and battles and an inventory system, etc.

Share this post


Link to post
Share on other sites
I'm in the process of creating an RPG right now as well. I'm using VB6, so I can't give you actual code, but I can tell you how I am doing things.

For NPCs, I made a custom data type (equivalent of a struct in c++) which holds the variables required for a single NPC (coordinates, hp, name, etc.), and have an array of that data type. Then, when I draw the screen, I draw the NPCs after the ground and items. I have done the same basic thing for the items.

For the inventory, I just have an array called CharInv, which has the numbers of the items the player has in their inventory.

Hope that helps!

Share this post


Link to post
Share on other sites
Since your using C++ here is what I suggest for the inventory. I suggest you use a vector to store the items. I am in a hurry, so I can't really give you code, but I am sure you get the idea. If not, then I am sure someone else here will describe it.


Chad

Share this post


Link to post
Share on other sites
Vector? I have no idea what that means. I'm just a beginner, my only experience is with QBASIC! I must research this... "vector"

Share this post


Link to post
Share on other sites
A vector is basically a templated self resizing array. Hows that for a mouthful :P But I must ask, if you are using no kidding arrays for things like NPCs and Inv... well you shouldn't be that low level... But whatever, if it works.

also, a vector is part of the std:: namespace.

std::vector< myClass > myVector = new std::vector(..);

Share this post


Link to post
Share on other sites
Tutorials? It's your game, you could say how should look data structures, you are person that would need to test a combat system if it feels right in the story.

So after carefully reading this. It seems you have, a maps, and a surprise story done. Now you don't have anything else. You must invent some combat system. And it seems you'd need to write a list of all items, and a strength of each item. Then you'd need to invent a combat system. Don't forget to learn about data structures, and create your own. I'd expect it would take you 3 months.

And yes one more thing don't forget to create some code when you are doing the above. Or you'd waste another few months.

[Edited by - Raghar on October 16, 2006 10:03:10 AM]

Share this post


Link to post
Share on other sites
There is nothing bad with arrays, if you doesn't need to resize them. You could use dipper class (you work with part of that array as if it would be an object) to access data safely. Actually arrays could give you an arrayOutOfBounds exception. Resizable arrays (in some languages more correctly called ArrayList) could give you OutOfMemory error. The first case is much less likely to hide in 150 source files, 500 lines of code each.

Share this post


Link to post
Share on other sites
I guess what I really need is info on how to do a dialouge system and an an NPC system. Like when you talk to an NPC, how does the game know which NPC you're looking at? Do you have to search through all the NPC's data to find matching coordinates?

Share this post


Link to post
Share on other sites
Quote:
Original post by Possumdude0
I guess what I really need is info on how to do a dialouge system and an an NPC system. Like when you talk to an NPC, how does the game know which NPC you're looking at? Do you have to search through all the NPC's data to find matching coordinates?


Yes and no, and it depends. :)

If you have to deal with massive worlds, thousands of NPC's and all, you'd want to do some culling beforehand. Like checking in what region the player is, and only taking the NPC's in that region into account. If you're dealing with only few characters, then such an approach might be overkill. Either way, in the end there's still a (hopefully small) list of NPC's to test against. Usually it's not worth culling every other character since that could take more time than testing the resulting list of a rough, but fast, culling method.

Share this post


Link to post
Share on other sites
Original post by Eddy999999
I'm in the process of creating an RPG right now as well. I'm using VB6, so I can't give you actual code, but I can tell you how I am doing things.
quote]

I use VB6 and I was wondering how you are making an RPG and what type of RPG is it. If you could give me any help yourself or if you could show me an excellent site to go that teaches.

Thanks Much.

Share this post


Link to post
Share on other sites
Quote:
Original post by Possumdude0
I guess what I really need is info on how to do a dialouge system and an an NPC system. Like when you talk to an NPC, how does the game know which NPC you're looking at? Do you have to search through all the NPC's data to find matching coordinates?


If he see the NPC, you already drawn NPC on the screen. How did you do that? You might use the same technique for discovering where is the character, and where is a NPC.

Often all NPC in the game has assigned an unique ID. It's often trivial to get from graphics subsystem an ID of object that is under mouse, then simple look up the matching ID. Other type is using array and expect the character is in adjacent field to NPC.

Share this post


Link to post
Share on other sites
If its a tile based engine as you say then an easy way to find the correct npc would be to have an npc pointer on each tile which points to any npc standing on that tile then you can simply check the array or whatever your storing your map info in to see if there is someone on a tile adjacent to you. You could even have a pointer to a general game object which could be an npc or could be an item or whatever and then the game object can decide how you interact with it.

Share this post


Link to post
Share on other sites
Raghar- I haven't drawn any NPCs on screen yet, just the basic maps and the player. But I get what you're saying.

rdansie- I don't see how that would be any better than checking an array of the NPCs

Captain P- culling, while not necessary for my current project, sounds good. I'll probably use it when I do a big RPG.

Fruny- LOL ;)

All- sorry for the long intervals between responses, I'm only online at school. Thanks for all the help.

Share this post


Link to post
Share on other sites
Quote:

rdansie- I don't see how that would be any better than checking an array of the NPCs


Because checking an array of npcs means that you have to check through every npc to see if they are adjacent to you which will take time whereas you could just check a single tile adjacent to you to see if there is something standing on it.

Share this post


Link to post
Share on other sites
Oh. That does make sense.

What about a dialouge system? Is it better to have the dialouge as a part of each NPCs data, or to use a database of dialouge like in Morrowind?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement