[Carlos] 1st Code Section

Posted by Carlos_Ramos on Feb. 2, 2007, 11:38 a.m.

>EDIT v2>

LEMMINGS UPDATE

Work on the Lemmings Engine has been slow lately. However, I made a much better improvement in the file loading features. Not much of an update I'm afraid, so I'm not posting a demo…but the upgrade was an additional 100 lines of code. Once the source is release, you will notice the ease of creating the game :)

Ok ladies and Gentlemen, I somewhat finished my first CODERS' Section. It's alot to read, but I didn't have any good ideas. If you would like to see a tutorial or example tomarrow, please post a suggestion.

<EDIT v2<

CODER’S SECTION - Reading From Databases

Ok, database’s are so important to games, that I decided to have my first Coder’s section be centered around it. I split up the tutorial into several categories for ease of navigation…just skip the parts you are already familiar with:

* Who I’m thanking

* What is a database

* When should I use one

* Where are database’s found in a game

* Why should I use one

* How do I use one

Who I’m thanking

For this Coder’s Section, I’m thanking Ghostkeeper at GMC for developing the base scripts, which I later adapted to create the powerful XML Search function.

What is a database

A database is simply a base of data J Databases serve as a powerful means to store, organize, and retrieve information in the most efficient way possible. In Game Maker’s case, a database would be used to store variables, which the player can modify. Some different file format’s good for storing database’s are XML and INI.

When should I use one

You should use a database anytime you want to save games, create engines or other programs user’s will modify, store game properties such as screen resolution, difficulty, and user controls/input.

Where are database’s found in a game

The main database, or the one most used, is the config.ini file found in most games. Other database’s are found in Saved Game files, media, and other places which make use of list’s of files.

Why should I use one

Database’s provide MANY advantages to both the coder and the user. On the coder’s side, a database can be used to store a single instance of a variable. This is beneficial because once the coder decides that he/she wants to change, say, the players walking speed, he simply goes into the database and updates the variable, without having to go look for the code, or change each and every single time the user’s speed is used (and possibly miss one or two).

The advantages to the player is that they can simply open up, for example, the config.ini file and change the resolution quickly. In the case of an engine, the user can change the player’s speed or other properties without ever looking at your code!

How do I use one

Reading from an INI file is very simple. Use the Game Maker help files, they explain it perfectly.

For XML files, you’ll need to download Ghostkeeper’s scripts http://www.64digits.com/download.php?name=SimplXML.zip&id=14686, in which I helped creaet the XML search function (Press 1 to test the XML). The file contains information on how to use it…I will update this section a little later. Simply look at the time stamp in my title. Happy Coding!

Comments

s 17 years, 9 months ago

I just make a script my database.

Carlos_Ramos 17 years, 9 months ago

I don't understand :(

s 17 years, 9 months ago

I'll have a list of ifs and thens and I may have an array initilized, then I just refer there and it returns something or another.

Carlos_Ramos 17 years, 9 months ago

oh yea I understand. I was going to touch on having a hardcoded database, but ran out of time. Yes, a hard coded database is great as well, but with an external database will reduce the amount of code required, and allow the end-user the ability to edit variables from the outside.

But yes, a hard-coded database is just as important.

s 17 years, 9 months ago

Hardcode is good for games like XFER then,where the list of directories and files in io should not be user-editable

tylerthemiler 17 years, 9 months ago

Nice banner/avatar. :)