creating base game loop for RPG
Displaying 1-6 of 6 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
troynall

the main loop in a game depends on
1) Character's Life
2) Player wants to "SAVE" a character and Quit.

I understand this.

But how do you start implementing an inventory system, combat system, random object placement and monster A.I. ?

My graphics are going to be old school ASCII characters- just like Dungeon Hack/Rouge.

I am going to hook "keypress's" to certain actions that a character can do. Wield weapon, Pick up all, put on rings, search room, examine sword, open potion, drink potion, unlock door, detect trap, etc...

but how do i implement this in programming terms ?

Whats the main loop going to look like after this ?

Just fustrated with all this coding stuff. Would like to worry more about creating items and adding interactions with the items to character OR character to environment interaction OR just basically creating the dungeon and neat magic items. But i also want to "control" how these items interact with everything else.

Guess I just need a nudge in the right direction.

troy:)

Posted on 2007-06-12 10:09:04

mcgrue

Well, first off it matters wither you're going to use verge's native entity/player movement or if you're going to programatically "hijack" verge's own control loop for more control. Once you get past that

Inventory is abstracted from that quandry and so can be deal with here: basically you just make an array of a struct for your items, and display them as you see fit. I'd recommend doing it sorta zelda-style for a verge roguelike, with a few items from inventory hotkeyed to mutable buttons always displayed in a HUD overlaid upon the screen (in addition to the standard keyboard hookkeys), and an inventory menu.

I just reccomend this because it's "shinier". Everyone loves icons, right? ;)

Anyways, most of your game logic will, most likely, be triggered in a master HookRetrace'd function.

Overkill, don't you have a simple demo of how to set up a non-RPG game in v3? Like your various sidescrollers, etc?

Posted on 2007-06-12 14:37:15

Overkill

Well, I don't have a "simple" demo of how to set it up, but look at Snowball, My Two Bits, or Wing Blaster for some ideas.

I use a frame limiter/throttler to ensure that the timing is consistent across all platforms. I update as long as there's frames being missed and render when the engine's caught up.

Untested general code loop:

int i;
while(!game_done)
{
// Draw while we're caught up.
Render();
// [Drawing stuff here]
ShowPage();

FrameThrottle();
// For every frame we miss, update.
// Gap is the distance in time between the
// current frame and last one.
for(i = 0; i < frame_throttler.gap; i++)
{
UpdateControls();
// [Update stuff here]
}
}


To check if buttons/keys are pressed, it's pretty easy, and it's fairly well documented and discussed. Attaching the scancodes to your own 'custom' buttons is simple enough, but I don't quite think it'll let you use defines in defines, so the next best thing.

int PLAYER_KEY_GET = SCAN_G;
int PLAYER_KEY_LOOK = SCAN_L;
int PLAYER_KEY_TALK = SCAN_T;
int PLAYER_KEY_DROP = SCAN_D;
int PLAYER_KEY_SLEEP = SCAN_S;
int PLAYER_KEY_EQUIP = SCAN_E;
int PLAYER_KEY_USE = SCAN_U;
int PLAYER_KEY_ATTACK = SCAN_A;
int PLAYER_KEY_PARRY = SCAN_P;
int PLAYER_KEY_SNEAK = SCAN_S;


Then use key[SCANCODE] to check if it's pressed.

Oh, and a lot of resources on the Internet for random map generation and item placement are documented in C code. Most of these solutions work okay with a bit of prodding. Random maps are probably more annoying than actually populating your dungeon. Someone else would probably be better able to explain a good dungeon generation algorithm.

Posted on 2007-06-12 20:36:45 (last edited on 2007-06-12 20:41:23)

troynall

yes, the random map thing is interesting. I have found several simple algorithms. the basic dungeon will be an huge square, inside a smaller square that have bi-sect ed several times at random x,y coordinates. Then spaced out as per "dungeon" cooridoors.

ok, i am thinking long term in project design but i would like to eventually move to a client/server "atmosphere". but i know learning how to crawl first, then walk, then run is in order.

I am going to managing character's movements myself, because i want to do more than just detect for obstructions. Or is my thinking that verge's obstruction just really simple ?

Right I am learning to read from a file and writing out the basic positioning of all the items/object in my world and then try to make my character walk around and interact with them.

I will implement the hooks you talked about for my character actions and definetly implement a frame timer.

thanks for the push,
troy:)

Posted on 2007-06-13 10:39:16

grenideer

Also, main game loops are usually very general - not getting into the player's health and that kind of thing. You basically should start with an Update and a Render call or something like that. Within your game update you'll break it down into several Update modes, one of which being your game which in itself will have many update functions for all your systems.

Posted on 2007-06-16 00:24:19

Arkhan

for random dungeon generation, in all honesty, Look in an old Dungeons and Dragons manual.

thats what I used at one time to make a dungeon generator.

Posted on 2007-06-16 22:44:26


Displaying 1-6 of 6 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.