开发者

How to create an internal database

开发者 https://www.devze.com 2023-02-11 19:41 出处:网络
Games, such as Nintendo DS games, have to store data of their objects, for example, RPG needs to store data of bestiary, weapons and spells.

Games, such as Nintendo DS games, have to store data of their objects, for example, RPG needs to store data of bestiary, weapons and spells.

I want to know the best way to create a game database in C++ and use object-oriented features.


Example:

A RPG with the following tables:

  • Class (Name, Race, Ability, Atk, Def, ...)
  • Race (Name, ...)
  • Ability (Name, ...)
  • Skill (Name, Race, Power, ...)
  • Learning (Class, Level, Skill, ...)

Each class belongs to a race. "Human ranger" a开发者_开发技巧nd "Elf ranger" are different classes. A class is not available to all races. Abilities are used outside battles (thieves can lockpick doors), and skills are for battles. Skills are invented by a race, but other races can learn it. A "human karateka" can learn "Tiger Fist Attack" from "cat men". A class can learn new skills when level up.

The player can hire mercenaries, that are randomly generated. Mercenaries data is stored in player's save file.

  • Mercenary (Name, Class, Level, Personality, ...)

It could be stored as static data. Each table could be stored as an array of structs, where the array index is the key of each line in the table.

I would have to create a function to initialize each array position with data of each line. But I think that it can be statically initialized in memory without a function.

An easy way to edit database is important, because many attribute values need to be tested and balanced.


Look into using SQLite. It is the most widely distributed embedded database and integrates very well into many languages.

As your posts begins to explain, you could accomplish this yourself with your own C++ code, but SQLite solves the problem very well and you get many advantages out of the box (sorting, aggregating, etc).

0

精彩评论

暂无评论...
验证码 换一张
取 消