• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Flurrih

How to code game data

7 posts in this topic

Hello!

 

At the begining I'd like to present myself as this is my first post here. I'm Tomek [Tom, Tomas etc], I'm 18 from Poland, I know some of C++, mostly basics.

 

I just have couple of questions that I can't find clear answer for it, or maybe just can't find it.

 

1. How do I code game inventory just like RPG games?

 

2. How to create item data?

 

I was trying to create it in dat file. Using fstream for that, but I find it difficult to manage line by line, it's not that simple.

I just want to know if I'm going right way with fstream, maybe there are bettter ways you used?

What I had in my mind, I want it to be sorted by, for example: ID / Name / Level / Class... so each item has their own properties.

 

I was trying to make registration system and stuff, but I can't get SQLite lib to work with VS12 [keep getting errors] so I will leave that for later.

 

 

I want to mention I just need key words from you, so I can google and learn it. I don't need you to explain me every detail, just if I will have troubles in understading I will ask you to do. This is not gonna be game at the begining, it's just for experiencing. Not gonna go farer than console app at the moment.

 

Thank you in advance.

 

0

Share this post


Link to post
Share on other sites

I'd also like to add, if your intent is to have a fairly extensive database of items, you're absolutely going to want some form of easy to use item editor utility that will allow you to easily add items to your database and edit items in your database.  This idea eventually extends to nearly every aspect of your game.  Class editors, monster/npc editors, level editors, quest system editors, etc.  These are preferably all wrapped up into a single game editor that gets used to create all the various data that composes the tangibles of your game.

 

You should also look into the factory pattern (and abstract factory pattern) for a popular method of wrapping and abstracting these content databases from your game code.

Edited by jHaskell
0

Share this post


Link to post
Share on other sites

Most large games I've worked on do it like this:

 

1. The data is entered into a spreadsheet or SQL database using whatever app you want (Excel, OO, Google Spreadsheet, SQL).  You can lay this out however you want (simple row/column grid all the way up to a fully normalized database).

 

2. The spreadsheet or database is scanned for the data, and stored however you feel is most appropriate for your game (custom binary form, protobuf, XML, JSON, etc).  This step typically takes database-style table-based data (i.e. if an inventory item has a variable length list of crafting ingredients, the crafting ingredients would be normalized as a separate sheet/table in the input spreadsheet/database) and turns it into more typical hierarchical data structures (i.e.  "Item.CraftingIngredients[0]").

 

3. The game loads the data into the data structure you feel is most appropriate for your game (a simple list, an associative array with unique IDs, a full-on SQLite database, etc).  Excessively large data sets may be hosted on a web service that can be fetched from 100 items (or so) at a time.

 

 

The large games I've worked on have all used Excel spreadsheets for data entry and associative arrays (Dictionary<string,InventoryItem>) for runtime storage.

Edited by Nypyren
1

Share this post


Link to post
Share on other sites

Most large games I've worked on do it like this:

 

1. The data is entered into a spreadsheet or SQL database using whatever app you want (Excel, OO, Google Spreadsheet, SQL).  You can lay this out however you want (simple row/column grid all the way up to a fully normalized database).

 

2. The spreadsheet or database is scanned for the data, and stored however you feel is most appropriate for your game (custom binary form, protobuf, XML, JSON, etc).  This step typically takes database-style table-based data (i.e. if an inventory item has a variable length list of crafting ingredients, the crafting ingredients would be normalized as a separate sheet/table in the input spreadsheet/database) and turns it into more typical hierarchical data structures (i.e.  "Item.CraftingIngredients[0]").

 

3. The game loads the data into the data structure you feel is most appropriate for your game (a simple list, an associative array with unique IDs, a full-on SQLite database, etc).  Excessively large data sets may be hosted on a web service that can be fetched from 100 items (or so) at a time.

 

 

The large games I've worked on have all used Excel spreadsheets for data entry and associative arrays (Dictionary<string,InventoryItem>) for runtime storage.

 

So from my understanding, please correct me if I'm wrong, I should start off writing the item data in app like excel [just example, excel seems to be less complicated than sql - I cant get the SQLite lib to work with my IDE], then it's being scanned for data and stored in XML file [aswell example, I already went deeper into XML] and then the data is loaded in game.

 

Just a question, how is the XML handling data from excel?

0

Share this post


Link to post
Share on other sites
Usually you have to save the Excel file out as some other format before beginning step 2. Dealing with Excel's native file format is kind of a pain, and writing an Excel plugin is no fun either.

The easiest is probably CSV, but "XML Spreadsheet 2003" (XMLSS) is also pretty easy to read and supports more of Excel's formatting information.

Step 2 consists more-or-less of the following sub-steps:

2a. Open the file in Excel, then "Save As" using the file type drop-down "XML Spreadsheet 2003". If you want, you can permanently keep the Excel spreadsheet in this format for editing as well, but it only supports a subset of Excel's features. For simple data entry and calculations, it will work fine.
2b. Use a program that you've written to load the .xml file, read each worksheet, row, and cell.
2c. Convert the data however you need to.
2d. Save the converted data in a file that your game will load later.


You'll want to examine the XMLSS file by hand to familiarize yourself with the format, and then write a loader which can read the portions you care about. There are a bunch of sections you won't care about at all. It's fairly human readable. The spec is here in case you need it: http://msdn.microsoft.com/en-us/library/office/aa140066(v=office.10).aspx Edited by Nypyren
0

Share this post


Link to post
Share on other sites

One important keyword for you, aside from the already mentioned by above posters, is hash table (hash map).

 

I was going to recommend an SQL library for C++ that was a single file, a single header to be precise, you could even copy and paste it on your program. But apparently I lost its name. I'll never forgive myself if I don't find its name...

 

You might find this interesting: http://www.boost.org/doc/libs/1_53_0/libs/serialization/doc/index.html

Edited by dejaime
0

Share this post


Link to post
Share on other sites

I just make an enum of item ID values, a table of structs matching up to it where I enter data for each item, and then the player's inventory can be one of two styles:

 

a) The player can have at most 99 of each item, but can have 99 of every item in the game all at the same time (no inventory limit). The inventory is just an array of bytes that corresponds to the item ID enum, which tells how many of each item the player currently owns. When displaying the inventory, don't show any that are 0. Final Fantasy 6 does this style (although it lets you change the display order)

 

b) Each slot in the inventory is an item ID and number of how many. In this style you can carry more than 99 of the same item type, by having multiple bundles (e.g. 99 cure potions in one slot, 20 more in another slot). Most games that use this style have a fairly limited number of slots, so you often have to sell old weapons and armor to make room for new ones. Final Fantasy 4 does this style. Some games, such as Earthbound on SNES, only let you store one item in each slot. So if you have two cookies, it takes two slots. And you only have 20 slots or something total. Too frustrating, IMO.

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0