Category Archives: Coding

Topic for things specific to programming

Reuseable Code FTW

One of the items on my To Do list is to have Bitmap Fonts. Bitmap Fonts are a graphical alphabet. The standard fonts don’t really look right in a game, and all sorts of cool effects (fading) can be done with the graphical version. Usually writing a system like this in a game can take several hours to get right. However, I was able to take lines upon lines of code from an earlier project (called Cubix!) and just place it into the Marble Maze game.

Whammo! I had bitmap fonts.

This is the beauty of reuseable code. If an area of a game is something central enough that it can be used elsewhere, it is worth the effort to make it modular and pluggably friendly for later projects. I spent some extra time on the Bitmap Fonts code I used in the previous game, and saved that time and more on this current project.

Brick walls, continued…

Warning: The following post may only interest my fellow nerds.  And even that is debatable.  🙂

I have dabbled in C/C++ over the many, many years of my programming tenure.  Almost 20 years ago, at the age of 16, I tried my hand at Turbo C++ 3.0 by Borland.  The low level nature of the language, and need for meticulous memory management, were a barrier to my fledgling skills and as a result I got frustrated.  I continued programming with QBasic for DOS instead.

About a decade ago I tried in earnest to learn C++ again along with DirectX.  Self instruction did not last long.  Soon after that I then took a certificate program at a local university for Object-Oriented Programming in C++.  By then I was understanding the syntax and the commands.  Yet still, it didn’t really stick with me.  I just didn’t enjoy the language very much and I couldn’t “just write code” whenever I felt like it.  Each line was a tentative save & compile session, ending with a review of whatever compiler warnings or errors I had just produced.  Not fun.

I found Darkbasic Professional a few years later and I loved it.  It had everything I needed, such as a simple BASIC syntax with an API geared towards making 3D games.  I often wonder, if I had stuck with C/C++ would I have grown to enjoy it along with my expertise?  I’ll never know the answer to that because I quickly abandoned any C/C++ efforts and stuck with DBPro.

As the previous post stated, over the last few years I have had a heck of a time with random crashes and other such anomalies that seemed to be out of my control.  Over the past year that ended when I decided to stop playing victim, get the source of the Newton physics wrapper DLL, and start looking into updating it to a later version of Newton that had lots of bug fixes in it.  I wasn’t sure if any of them would fix my random crashes but it was worth a try.

After a month or two of fighting with Visual C++ 6.0 (a very dated version) and learning about compiling DLLs I got the Newton physics wrapper updated just enough so it was functional.  I didn’t include some new commands, nor did I update the documentation or demos for the wrapper.  This was a custom version just for me to use with in my big project.  It still crashed once in a while, but not as often.

A few months ago I decided that enough time had passed and I should finish up all the new commands for the wrapper, update the documentation and demos, and ship out the new Newton physics wrapper for my fellow DBPro users.  I dove back into C++ and worked out the changes necessary.  While updating and testing the demos I noticed that I could repeat the crash I encountered all these years in one of them.  After debugging the DBPro code, and the wrapper source itself, I was able to spot the bug and fix it!

It felt really good taking care of a bug that has plagued me for years, and caused untold amounts of grief and frustration.  I still don’t enjoy C/C++ but I can’t say any longer that it has never given me any joy.

With the spectres of failure cast into the abyss, I can now forge ahead in my long journey to complete the marble game.

Bouncing off brick walls

In a previous post I promised a bit of an explanation on just why this project has taken so long to get this far (barely alpha at the time of this writing).  The main reason for this will reveal a little piece of who I am and how I handle what appears to be insurmountable hurdles, or at least how I handle the day to day frustrations of a mediocre programmer.

Throughout the entire life of the project (6 years) I have been subjected to certain random and, shall we say, unknowable crashes in the Marble Maze game.  These would crop up perhaps twice a year or so, and sometimes disappear without any work done by me.  Nothing frustrates me more than dealing with a bug I have no clue how to fix.  It just shouldn’t happen!  But it does.

I used the term unknowable because of the nature of the DBPro language and its plugins.  As stated in a prior post, the DBPro language can be extended through the use of plugins (DLLs).  The Newton physics engine is wrapped by one such plugin.  When a random crash occurs deep inside the bowels of Newton.dll I have no way of knowing what inside Newton has crashed or why.  It is a black box where I have no idea what is going on inside.

It is a toss up between whether the randomness of the crash or the closed nature of 3rd party software makes it so frustrating to deal with these types of issues.  Regardless of the cause, it is the outcome that counts.  I handle these frustrations in a very non-productive way.  I stop coding.

The most secret fear I have with a project of this scope is this: that I will eventually strike upon a brick wall situation of which there is no workaround.  In other words, that some limitation/bug of the DBPro language or the Newton physics engine will cause my dream of a 3D marble platformer to never come to fruition.

…Yet I endure.  I continue work to this day, however slowly.  I continue despite several episodes of “coder’s heartbreak” over the years where I really thought there would be no recovery.  But now I can see the light at the end of the tunnel, and I strive for it with a renewed vigor I have not felt in years!

I would like to write about how I took control of certain fears, along with the perceived helplessness, and the positive results it had on my productivity.  That will be for another time…