Whee, String Theory

posted in DruinkJournal
Published September 28, 2005
Advertisement
I made a config file loader. Well, I converted some old code, so it uses a callback to read a line. That way I can easily read data from resources. I just have this code:
//==========================================================================//// Function to load a config file from a binary resource                    ////==========================================================================//bool LoadConfigFromResource(CConfigFile& rConfig, const std::string& strName){CBinaryResource* pResource;   // Load the resource //   pResource = (CBinaryResource*)CResourceManager::Get().GetResource(strName.c_str(),CResource::Binary);   if(!pResource)      return false;   // Load the config //   rConfig.Release();   if(!rConfig.Load(ReadLineFromResource,pResource))   {      pResource->Release();      return false;   }   // Cleanup and return //   pResource->Release();   return true;}//==========================================================================//// Function to read a line from a resource. CConfigFile::Load() callback    ////==========================================================================//bool ReadLineFromResource(std::string& rLine, void* pContext){CBinaryResource* pResource = (CBinaryResource*)pContext;char ch;   rLine = "";   // First, Eat '\r' & '\n' //   do {      if(!pResource->ReadByte((BYTE&)ch)) return false;   } while((ch == '\r') || (ch == '\n'));	   // Read up to next '\r' or '\n' //   do {      rLine += ch;      if(!pResource->ReadByte((BYTE&)ch)) return (rLine.length() != 0);   } while((ch != '\r') && (ch != '\n'));   return true;}

And I also edited my CBinaryResource class slightly, to include a position member. That lets you read from it in a more sane way, using fread()like functions.
I also started a bit of work on my animation classes. At the moment, I have CAnimation, which holds a series of frames and delays which make up one animation (e.g. a walk loop or an idle loop), and a CAnimationSet class which holds all of a characters animations (a walk animation, idle animation, etc etc).
I currently load an animation from a config file, the sample one I'm using is this:
# General character information[Character]Width = 64Height = 128# Animations this character can do# Format:# AnimationName = FrameName:Delay, FrameName:Delay, ...[Animations]Walk = Walk00.bmp:100, Walk01.bmp:100, Walk02.bmp:100, Walk03.bmp:100, Walk04.bmp:100, Walk05.bmp:100Idle = Idle00.bmp:1000

I'm loading each individual texture into each frame of the animation, and once I've loaded all of the animations, I'll composite them onto as few textures as possible (ideally 1 texture), and use texture coordinates to address each frame.
That won't be done for a while though, since I'll need to add clothing on top of the body to save on rendering stuff over and over.



In other news, I found 24 videos about string theory, which someone linked to somewhere in the lounge I think. So anyway, there's sod all on TV tonight, so I'll be watching those videos shortly.
Previous Entry Whee, String Theory
Next Entry Part 47c
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement