Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Sun Sep 22, 2019 4:38 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: String Table
PostPosted: Tue Jun 10, 2014 4:01 am 

Joined: Fri Oct 19, 2012 5:50 pm
Posts: 32
My game is going to have a lot of text, and I intend to save the text in a file and use file i/o to retrieve the strings as needed. I'm doing this for the sake of localization (supporting multiple languages) and general organization.

Do you have any recommendations for setting this up? In a previous game, I defined all my strings in a .h file which I included in the project. That was not very elegant--I'd like to be able to edit my strings without recompiling the game. And that was just 100 or so strings in 1 language. For this project, I really don't know how many strings I'll have. I expect over 1,000. And the target will be 5 languages (EFIGS). Assuming the average string is "The quick, brown fox jumps over the lazy dog." (46 bytes), that's still only around 250kB. Here are the options as I see them:

0) Hard code the strings and just let the whole string table exist in memory all the time. 250k is still relatively negligible.

1a) Strings in external file, accessed as needed.

1b) Strings in external file, added to exe as resource.

2) String table accessed via Lua or SQL. This seems to be the method of choice for larger games such as World of Warcraft (which contains 6 million words of text).

My current thinking is to do something like 1a (migrated to 1b before release), and try to minimize file access and memory usage by loading the strings into memory in chunks. e.g., Upon loading an area, load all strings used in that area. But I really have no clue. Any insight you may have on formats and functions would be much appreciated.

Reply with quote  
 Post subject: Re: String Table
PostPosted: Tue Jun 10, 2014 3:56 pm 
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 553
I would probably load the strings from disk into a dynamically created array of strings. It could be for the current level or for the entire game depending on the amount of data. This would support easy modification of the strings without the need to recompile the code. Warcraft and other games use a scripting language, such as lua, to write part of the game logic. This allows them to modify the game logic without recompiling the C++ code.

Professor Kelly

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group