Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Questions about game structure

Author
Message
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 29th Jul 2006 11:39
I have the basics of programming down and made a little platformer engine with jumping and collision and all that. However, the logic behind multiple levels and stuff like that fails me. I've looked at some code from games that people have made but couldn't quite decifer it as they weren't well commented.

Basically, let's say it's a Eastern style RPG game, and I'm on the map. I'd have the character model and the map model and all the logic and if:thens and whatnot loaded, but I wouldn't want to be calling the battle scene if thens or all the town's of the world's code. So if I was to enter battle, would I end the loop and then have the code directed to a new loop? Like... "if battle=1 then endloop" and then have it directed to the do:loop cycle of the battle code?

If so... I don't really know how I'd go about doing that. And if not... well then how do you do it?


It seems like a dumb and basic question but eh...

Neeeeeeeewom!
Trinita
21
Years of Service
User Offline
Joined: 29th Sep 2003
Location: Italy
Posted: 29th Jul 2006 13:36
You should use Functions or Subroutines for the special actions in your game. For example if your player is involved in a fight, call a specific Subroutine that has all the fight graphical and variables modification, including a loop with a Sync command. So the game will continue in your Subroutine, and at the end of the balle will retourn to the main loop.
Creating different loop with Sync inside them is the best solution; the main loop just handles and calls all these Subroutines or Functions.

"An eye for an eye will only make the whole world blind."
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 29th Jul 2006 13:45
Thanks for the reply!

So one main loop that will always be running and then each room/level/whatever will have its media and code loaded in a function and each of those functions will each have a do:loop inside of them?

If that's the case then I think I understand. In the rpg example I suggested, when being attacked on the map how would I go about deleting all the map media from RAM to make room for the battle mode media?

Neeeeeeeewom!
Profit
18
Years of Service
User Offline
Joined: 19th Feb 2006
Location: United States
Posted: 29th Jul 2006 17:59 Edited at: 29th Jul 2006 18:00
Thanks, I was wondering the same thing

common people are walking in line.
Trinita
21
Years of Service
User Offline
Joined: 29th Sep 2003
Location: Italy
Posted: 29th Jul 2006 18:42
You must create a unique function for all fightings and then call it when needed during the gameplay. Your media must be loaded at the beginning of the game for a better speed; you can load the necessary media even in the called function but it will slow down the execution.
Loading all your media at the beginning and using commands like hide object or exclude object on will surely speed up the passage between the walking routine and fighting routine.

"An eye for an eye will only make the whole world blind."
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 30th Jul 2006 03:18
At the same time if there was a great deal of media I wouldn't want the player to have to sit there for a long period of time when they start the game and I wouldn't want to take up that many resources the entire time I'm playing the game.

I suppose a better example of my question would be an action adventure game or FPS, where the player would play through large levels and on completion would continue onto the next level. Clearly I don't want to load each of these levels when a new game is started, so how would I go about progressing from one level to the next in the code, clearing all the data from the first level and loading all the data for the next. This especially perplexes me if I was to use different controls for player movement or anything like that in the next level... I'm used to having that stuff in the main loop.

Neeeeeeeewom!
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 30th Jul 2006 10:55
In addition to what Trinitia has already said, I like to think of the main sections of my game (say, an RPG) as a 'state machine'. That's just a funky word for me having one big loop that basically says:



(I'd actually use select/case for this, but if/thens are more basic in DBPro). Basically, the game keeps a single number 'gamestate' and that number remembers what state it's in at any one time. Parts of those 'do stuff sections would jump between states - for example, when it's loaded all the level, it would change the gamestate to 'StartLevel' or similar. Or when the player selects 'New Game' in the menu gamestate, it would take note of the level and change the gamestate to LoadLevel.

Loading media between levels really depends on how long you want the player to wait. Deleting models has traditionally been very slow, but I think there may have been some work-arounds put into the latest version of DBPro to make it a little faster. Loading media is also quite slow, so you'd want to make your media as fast as possible to load - using DBO's instead of .X, or .X instead of .3DS.

If you're changing the actual way you move from one level to the next, then you're going to have to have a 'state' for each control method, and then have gamestates like "DrivingLevel" or "FPSLevel". If you're just adding in extra features like a rocketpack to a standard FPS movement, then you can just do an 'if' in the standard "PlayLevel" state to check if they have a rocketpack or not, and deal with the controls accordingly.

Well, I've waffled too much - hope I've been of some help.

Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 30th Jul 2006 15:52
Yeah, I think the picture is all comin together. About all I'd need to really get my head around the concept is to see a game's code thats pretty far along and consists of multiple levels and models and whatnot, just to see how it's literally handled in examples.

Thanks!

Check out my music page: Kill for Quid (myspace)
I'm happy to make music for any game!
geecee3
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location: edinburgh.scotland.
Posted: 30th Jul 2006 16:15
best thing to do m8, is write a mock game that allows you to simulate events with keypresses, this is just an empty shell that represents the control flow of the game, Doing this will help you get to grips with control flow logic. Basically, Once you have done this and are happy with the flow, you write an empty game shell for real, then populate it with the game routines. Knowing your control flow logic is sound before adding in 'real game' routines will help you no end in making a game, I done this for a 48 hour remake of missile command, I wrote all the flow logic first, tested it with keypresses, then added the game routines to a shell that I knew worked before i even wrote any 'real-game' code.

Preparing your control flow logic early in the process makes writing the rest of the game much easier than trying to shoe horn a load of game routines into 'on the fly' control flow logic.

As for sync commands, If you can pull off your game with a single sync in your code your doing really well, I tend to have a sync for the title screen routine, game over, level ended, get ready etc. The actual 'game' only has a single sync though in the main loop.

cheers, Grant.

Ohd Chinese Ploverb say : Wise Eskimo, not eat yerrow snow.

Login to post a reply

Server time is: 2024-11-26 14:34:47
Your offset time is: 2024-11-26 14:34:47