WIP: Week 1 -- INI Files and Resources!

Published December 21, 2014
Advertisement
Hello!

What I hope to accomplish are weekly updates about my engine build, and go over some of the things I've been working on lately. This first one will cover what I did today, but future ones will cover an entire weeks worth of work.

Since last time I created an event system to tie my engine together, I began this weekend working on beginning my resource allocators. Since I wanted to start small and work my way up, I began with INI file types (with my own twist).

In reference to the voxel game I'm working on, I moved my voxel types from classes into a resource to load at runtime. No longer do I have to recompile my code just to change the color of a voxel; I can now fix the .conf file and re-run the executable! It was incredibly satisfying to get this working, and it allows an explosion of different voxel types to emerge rather quickly.

The BlockDef.conf file looks as follows (roughly):## Block Data information is in this file. Format (copy, paste):# [BlockName]# id = (int)# transparent = (bool -- true, false)# material = solid, liquid, gas (string)# color = (4 length array of floats)# [AirBlock] id = 0 transparent = true mat = "gas" color = {1, 1, 1, 1}[NullBlock] id = 1 transparent = false material = "solid" color = {0, 0, 0, 1} [StoneBlock] id = 2 transparent = false material = "solid" color = {0.2, 0.3, 0.4, 1}
For those of you that know the INI file structure, you'll notice one big difference -- there's arrays! I added this simple functionality in order to make defining colors, texture coordinates, and other such things easier to add. Overall it looks solid and is simple enough for newbies to learn!

In the engine, the results are viewable using nested C++ hashtables. Here's an example for gathering the color and name of a voxel from the results:[code=nocode:0]INIFILEMAP map = INIParser::parseFile("Resources/Blocks/BlockDef.conf");for (auto kv : map) { std::string voxel_name = kv.first; INIMAP voxel_data = kv.second; //... std::vector voxel_color = voxel_data["color"]; //...}
In the above code INIFILEMAP is the overall nested hashtable, and INIMAP is the interior labeled data from a specific entry in the INI file. Pretty sweet!

I'm not sure of what to work on next, but I've got the following list of things I can work on currently:

  • rendering buckets
  • transparency
  • texturing
  • resource management
  • python scripting (or lua.....not 100% sure yet on the pros/cons)
  • start physics engine
  • etc....

Next time we'll see where I'm at with this list!
1 likes 2 comments

Comments

CC Ricers

Ooh, a voxel engine. I am going to follow this.

December 21, 2014 10:58 PM
studentTeacher

Ooh, a voxel engine. I am going to follow this.

Thanks for the interest! I'm trying to build a general-purpose engine underneath it for exploring/world generation games so it should be pretty interesting :D

December 22, 2014 12:57 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement