6 Replies - 250 Views - Last Post: 03 January 2014 - 05:36 AM Rate Topic: -----

#1 Taurous  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-October 12

Databases and Games

Posted 02 January 2014 - 10:43 PM

So say I wanted to make a game like Pokemon. How would I go about storing all the information about each Pokemon? My first thought was just to fill an array with structs of each kind but that would be a hassle to work with. Then I thought that maybe this is the perfect situation for a database.

For some reason I feel like databases are only for things that are online like websites or MMOs where the information stored changes constantly.

My question is, how do I store static data for my game to lookup?

Is This A Good Question/Topic? 0
  • +

Replies To: Databases and Games

#2 Xaos  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 108
  • Joined: 20-November 13

Re: Databases and Games

Posted 02 January 2014 - 10:57 PM

View PostTaurous, on 02 January 2014 - 10:43 PM, said:

So say I wanted to make a game like Pokemon. How would I go about storing all the information about each Pokemon? My first thought was just to fill an array with structs of each kind but that would be a hassle to work with. Then I thought that maybe this is the perfect situation for a database.

For some reason I feel like databases are only for things that are online like websites or MMOs where the information stored changes constantly.

My question is, how do I store static data for my game to lookup?



Maybe you should look up more about databases and learn more about them. A database is not just for online things, infact, a database would be the exact thing you need for something like that.
Was This Post Helpful? 0
  • +
  • -

#3 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: Databases and Games

Posted 03 January 2014 - 12:22 AM

Databases are not the only way to to accomplish this objective. You can manually write and read each 'Pokemon' to a binary file. Take for example, Skyrim. All objects in skyrim are written to a binary file, in which this case is an .esm file. This binary file is what hold all the object data for each object, such as the 3D model, the Texture, world coordinates as well as the objects rotation and scale. Not only that, there is a lot of data that is read from the esm binary file. This file is essentially, in some cases, the level or in Skyrims case, the entire game worlds and levels.
Was This Post Helpful? 0
  • +
  • -

#4 Rhino1111  Icon User is offline

  • D.I.C Head

Reputation: 96
  • View blog
  • Posts: 217
  • Joined: 28-August 13

Re: Databases and Games

Posted 03 January 2014 - 01:55 AM

Databases are the way to go in my opinion. I'd suggest checking out MySQL community edition, which is a free open source database.

Writing and reading to files is another alternative mentioned, but that method seems like its better suited for single player games and local storage..
Was This Post Helpful? 0
  • +
  • -

#5 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: Databases and Games

Posted 03 January 2014 - 04:13 AM

View PostRhino1111, on 03 January 2014 - 06:55 PM, said:

Writing and reading to files is another alternative mentioned, but that method seems like its better suited for single player games and local storage..


Which is what the OP's game is described as, single player and localized.

I prefer the read and write from a localized file simply because having all your objects in one database, could potentially be crippling if the database is hacked, the SQL tables are dropped accidentally or the power to the server that is maintaining the database, is lost.

Look at games on the XBox 360, the games that require disk are normally as I described, their objects are stored in a 'master/level' file that is read at object load time. For instance, Call Of Duty: Black Ops2, this game is 2-4 players yes, and yet all their game objects are defined inside a master file, thus giving reason to a level editor, when you click save, it saves all the new information, world objects, object locations as orientated to the current level, characters, animations, physics and even dialog are all stored/referenced in a 'master/level' file.

In saying that, I'm sure that there are games that fetch object data from a database at object creation time, I'm merely stating that the 'master/level' file is currently used the most.
Was This Post Helpful? 0
  • +
  • -

#6 Rhino1111  Icon User is offline

  • D.I.C Head

Reputation: 96
  • View blog
  • Posts: 217
  • Joined: 28-August 13

Re: Databases and Games

Posted 03 January 2014 - 04:35 AM

Yeah your right, for some reason when I read

Quote

"For some reason I feel like databases are only for things that are online like websites or MMOs where the information stored changes constantly."


I misinterpreted it, and assumed he was doing a multiplayer game (where the server should be making use of databases over file read/writes for data storage).
Was This Post Helpful? 0
  • +
  • -

#7 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: Databases and Games

Posted 03 January 2014 - 05:36 AM

View PostTaurous, on 03 January 2014 - 01:43 AM, said:

My first thought was just to fill an array with structs of each kind but that would be a hassle to work with.


And when you read data from the database, where does it go?

Keep in mind, all the data from a database needs to ultimately be stored in something that makes sense to your program. In this respect, the database is only of concern when you load or save data. A good program will hide the persistence layer from the rest of the program. e.g. loadPokemon(X), updateStats(X,Y) could talk to a database or simply update an array.

What a database buys you is persistence of data. When you need to save and reload between sessions. You may need a database, but don't get stuck on it. Your data store should not dictate your program design. If this is a desktop program, look into SQLite as your database.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1