Database help

BlitzPlus Forums/BlitzPlus Beginners Area/Database help

DCI(Posted 2007) [#1]
Ok, im working on a game.. the basic premise of the game: players start out, pick a quadrent of space (which will consist of well over 5k planets) they find one they like, and begin setting up a colony. building buildings, infrastructure, mining for minerals. etc. building combat units. researching stuff.. this game will have multiple people playing at once, but only if their in combat with one another, .

When a player gathers resources enough to build say, an apartment building.. based on the amount of workers they have, and the conditions of the planet, and the size of the building, i was thinking of having the system do the math, and then, set a date for completion. for the purpose of my explaination, lets say, it will be complete on june 2nd at 3:01 am.. its june 1st now, real time..

These buildings under construction by all of the various players, on various planets, i was thinking, could reside on a single database.. the server program, would watch this database.. and when the time rolls around. it would place the building where it should be, on that planet, and zone's map (and data base) and then clear it, from the under construction database.

what i need, are tutorials on how to work with databases with blitz, how to organize the data, how to read and write entries from the database, and how to search the database. im a relitive newbie to programming.. i used to be an ace with Basica back when i was in highschool.. lol been almost 14 years now. please help! too many tutorals talk about "player entities" when im making more of an empire building/ real time strategy game dealing with ALOT of player controlled pieces.. as well as AI.

i REALLY need help.. please!


Adam Novagen(Posted 2007) [#2]
Okay, I'm no DB expert, but I do see one major flaw here.

A database is of course just a storage file, that doesn't update itself. So, picture this: work starts on the apartment building, but the player logs off, as does (through a coincidence) every other player. There are no longer any copies of the game running, so the DB stops updating and remains static. So, when a player logs back on, nothing's happened or changed! The very first thing you'll need is a program, always running, that can update the DB even if no one's playing the game. As far as UPDATING the DB goes, I've heard that ETNA works well; check this site's toolbox.


Phil Newton(Posted 2007) [#3]
If I'm reading this correctly, the database will be held on a separate server. Like everything in programming, there are lots of ways to solve this problem but this is how I'd do it :)

I recommend using a MySQL database server, because it's free and relatively easy to learn. It can take a little bit of effort to get it running, but it saves time later. There are plenty of MySQL Tutorials available online :)

Once you've got your DB running, it's time to make a server. You can either write the server in Blitz or in another language. Using Blitz has the advantage that you can port a lot of code from the client. However, it's more debugging work later on. Another method would be to use PHP on an Apache web server (the same thing that powers a lot of websites). You lose some speed and Blitz type stuff, but you can get something working fairly rapidly.

It's really down to personal choice, but my one piece of advice would be to make sure your server logs as much as possible. It'll save you bashing your head during debugging ;)

Start with something very small to learn the basics. Perhaps a simple map where you can place buildings using the client, and then the server will send a message once they're built (after 20 seconds or something). That'll help you get a grip of some basic stuff, so you can build on that experience to create your game.

Let me know if I can clarify any of that ;)