11.30.06
Game Creation with PHP - Our Database
In selecting a database for our game, I wanted to make sure I choose something that was robust enough to handle the job. I decided to go with MySQL 5.x, but think I may regret it due to overhead problems. I know there are things that can be done to tweak the system, but maybe I’ll address those issues later.
I also decided to create a custom interface that would make managing the game tables in the database easy to administer. And that is what I’ll refer to them as - game tables. So far I have tables for players, player items, locations, and items. The way I setup these tables is kind of crazy and really hard to explain. I have a players table which is nothing but the fields I think I’m going to use in the game. these are just records containing and ID field and a name field. Then I have a table called players_data which ties to the `players` table to get the field names for each player record. Player’s data has the records of id, recordid, fieldid (from players table), and value (the value of the field in the record). Pretty nuts eh? Well, this allows me to quickly and easily design the data structure for the game, and I forgot to mention, I also have a pID (parent ID) field in the Players table, so I can categories the fields in a tree structure. I’m using a script I found online to accomodate the creation of the tree.
I also created some custom database functions to deal with all the selecting, updating, inserting, and deleting of records. The select functions used to determine the players x,y coordinates on the map are pretty interesting. I have to basically get two arrays of x and y results and then get the intersecting ‘point’ using an array_intersect_assoc command. I was afraid with these extra queries and the craziness of my array manipulations used to support my game design program, the performance might be slow, but it works amazingly fast. I’m sure it will be faster after I flaten out the database structure and use regular queries to handle the bulk of the work.
I’ll try to get some more code and information listed here soon. I actually am further ahead on the game than I am on this series, but I might as well make sure that whatever ideas I’m going to talk about here are actually working first before wasting my time talking about it.