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.

DarkBASIC Professional Discussion / [Tutorial] Game Engines

Author
Message
Zotoaster
17
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Sep 2007 20:25 Edited at: 4th Sep 2007 20:34
If you are a new game programmer, and are human, you are likely to have hit a snag in most of your games, and given up. I mean of course, it's difficult to write a whole game from start to finish, but, here's the good news. You dont have to make a game from start to finish!

Here's an example. Lets say you made the new FPS Creator. You havent made a game, OK, but using it, you can through together a quality game that would take one a few days/weeks to hardcode.

The reason for this is because FPS Creator, The 3D Game Maker, and other things use a Game Engine.


Game Engines come in two forms.
1 - Graphics engines, sound engines, file I/O, internet access, etc
2 - Object handling, event handing, scripting, etc

DBPro itself isn't just a programming language. It's an engine, controlled by a programming language. If it wasnt for DBP you wouldn't get numbered objects, or object loading at all, or primitives, or sound capabilities (i.e. 3D sounds), etc. But this alone is hard to use. It does make it easier for us, but it's not very specific. It's just a wide range of commands that can be used to make any game you wish.

Now, lets think of the other type of Game Engine. It would be specific to the type of game you want to make (unless it's like T3DGM, but that's hardly usable, lol). For examples sake, lets think of an FPS, since they are relativelly simple.

Your FPS should handle:
- Multiple guns
- Bullets / Shooting
- Enemies
- Levels
- Physics

Other, more general things, could be:
- Dynamic level loading
- Scripting
- INI files
- Scripted entities
- HUD

I'll skip the chit-chat, and go straight to what a good structure might be for this:


Everything at the very right of each list (i.e. FPS -> Shooting -> Move bullets -> Hit Enemy) would be a regular DBP Function/Endfunction. With this kind of design, it is possible to have 100s/1000s of lines of code, but no game. But with ease, you can make something great. Here's one I would make with that particular structure (pseudocode obviously):


Now you see, with just a few lines of code, I could have a really good game going.


That particular game lacks structure though. It is important to structure your game so the code never changes if you ever want to change the game a bit. This is where file access comes in very importantly. There are some neat scripting plugins around (including Barnski's Lua which is free) which you can use to tweak things, such as the player's speed, how many enemies there are in a level, etc.


And that is how a game engine should be made. Sorry for the lack of code, but this kind of stuff applies to all programming languages, so it should be quite simple to port. It's the understanding that matters most in these realms.

Enjoy

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
tiffer
16
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 5th Sep 2007 01:26
huh what? what just happened?

Cwatson
vorconan
16
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 5th Sep 2007 22:03
That's quite a good tut actually, nice job Zotoaster.



Code Dragon
16
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 5th Sep 2007 22:48
Good job writing it up, should help lots of people in writing their games.

Sid Sinister
17
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 6th Sep 2007 04:06
If I may add too that it's easiest and often best to work on one section and then move on. For example, right now I'm working on camera controls for my rpg. I haven't even modeled the character yet but that doesn't mean I can't go ahead and start hashing it out. After Camera controls I plan on moving onto the environment and object placement and then after that dynamic level loading and culling. For me, the media is one of the last things on my list.

When writing an engine, or anything for that matter, if you get stuck on something to the point where you want to give up it's important to stay motivated. I do that by just moving on to another portion of the code that needs work or by taking a day off from programming. It's amazing how the brain can work on a problem in your subconscience and all of a sudden hit you while your sipping your lemonade
TinTin
16
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship
Posted: 7th Sep 2007 12:02 Edited at: 7th Sep 2007 12:03
Most of my insperation and ideas come after a good night down the local ale house, when I've sampled more than I should of their fine merchandise.

I'd also suggest using performance monitoring for your code sections, i.e. pt#= timer() at the begining of a section and pt#=timer()-pt# at the end. Most programming will have several diferent methods to achieve the same goal. When your developing a routine, checking the performance sould leave you with the fastest solution.


Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Mr Kohlenstoff
16
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 7th Sep 2007 16:02
You could mention, that flexibility is a very important feature of such engines... at least in my opinion.
The engine should be able to create many different games, maybe even different genres (e.g. a 3D FPS-Engine could also be used for a 3D Platformer, you just don't need the guns..).

Short, but good tutorial.

Kaitia
15
Years of Service
User Offline
Joined: 8th Sep 2007
Location:
Posted: 8th Sep 2007 10:40
I dont get it none of these load gun blablabla load image load this load that it all doesn't work.And how do you get those loads because u 1st need 2 save something before you can load it right?

''To program or not to program that is the question''
Zotoaster
17
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 10th Sep 2007 20:17
Mr K, Damn.. I could swear I mentioned flexibility, but then again, I wrote in a hurry. Lol.


Kaitia, it's not supposed to work. This isn't a tutorial for how to code. It's a tutorial aimed at people who already know how to code. This is more about the concept. All the code snippets are just pseudocode.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers

Login to post a reply

Server time is: 2022-12-01 10:39:31
Your offset time is: 2022-12-01 10:39:31