Category Archives: Coding

Topic for things specific to programming

The Whirlygig Is Born

I recently had another soul-crushing bug on my hands that I did not know how to fix, so I scrambled for a workaround. Instead of getting depressed for 2 months and ignoring Marble Maze for the duration, it only took me 2 days to shake it off and find a way to make it work. But if I couldn’t make it work this would have been a deal breaker, for sure. Probably would have made me go to 2D development where everything is under my control, and makes sense. 🙂

Basically I had a concept of the physics engine representation of the Whirlygig models, and it took about a dozen iterations of trial and error before I found something that works. Here were some of the major stages of the race…

  • A convex hull collision with an upvector joint, and using impulse forces to push the model around. This had serious performance issues (too many contact points, I believe?) and I could only have about 20 models running at any given time on my fast PC. Bounce collision with the player was not consistent, either.  No good.
  • A sphere collision with an upvector joint, and using Impulse to push the model around. This had less performance issues than the previous attempt but the model would jump around a bit and cause problems. I also received random issues where all of a sudden a physics object would have position/velocity of 1.#QNAN (yes you read that right). It caused the object to disappear from the world. It also happened to the player marble which is the most bizarre thing of all, and the player would be treated to a black screen stuck inside never-never-land. This 1.#QNAN is some sort of floating number corruption that is caused by divide by zero or negative exponents, or something. Google it, it freaks me out just thinking of what inside the wrapper or Newton DLL that could cause this.
  • A sphere collision with no upvector joint (thinking that may cause the corruption) and using Impulse. The 1.#QNAN issue still happened. By then I was getting very frustrated.
  • A sphere collision with no upvector joint, and using actual Forces instead of Impulse. This made the collisions skip all about and behave kind of weird. Still got the 1.#QNAN problem too.
  • A sphere collision, no upvector joint, and use Omega forces (just like the player) to move the sphere around. Bingo. We have a winner.

So what caused the 1.#QNAN ? I still have no clue, and I hope I don’t ever see it again. It is obviously some memory corruption of some kind (wrapper or Newton, I wouldn’t know) and it was extremely random.   A problem with using Impulse/Forces on too many objects?  Sometimes it would happen to the player marble as soon as a the Whirlygigs began to move. Sometimes it would happen part way through. Sometimes I could run the level of 25 Whirlygigs bopping around for 5 minutes before some of them started disappearing, one by one. It is maddening!

And thus my struggle with programming a complex system which utilizes 3rd party software that I can’t really get into or debug.

Having models represented by spheres in the physics engine will work for a majority of the enemies planned, but will not work for some of the more interesting ones, such as the flip-truck and the slimey oozes.  I’m not sure how those will be handled or if I’m stuck with a rolling sphere for everything.

But it seems to work now, no major bugs.  It doesn’t work perfectly: I eventually want these Whirlygigs to slow down and stop on a dime.  And sometimes the Whirlygig thinks it shouldn’t move when it should.  But it works.

So to celebrate I posted a few videos of the Whirlygigs!
Whirlygig AI
100 Whirlygigs

Gems, take 2

Here are the updated gems. I now have blue, red and yellow. Don’t know what the different colors will be for in actual game, but it’s nice to have a little variety, right?

A little better in the visuals department, but certainly not fancy!

Gems, take one

I’ve added gems into the Editor, under the Specials tab (where railings and other props will go). Right now they don’t do anything in the game except get loaded in, and they are registered as a Widget internally so it shouldn’t be hard to hook them up to the system and get something going. I spent a lot of time on the Widget system because I knew there would be many of them added over the lifetime of this project. Well, we’ll see how easy it is to get the action on these gems.

Geometrically perfect, but ugly in every way.


Oh yeah, and they look horrible. My 3D special effects skills are awful. I will be looking through code snippets and forum posts to see if I can find a command combination to give me a nice “gem effect”. This just highlights the “not fancy” part of our product.

Well isn’t that special…

And the response from the world is… silence! Nobody has made a level and sent it to me yet. Someone from the forums reported it stuttered every now and then which is something I saw on my old rig but not the new one. I think it may be inside Newton (or the wrapper), which means it will be a great pain to figure out, if it ever becomes a problem for most.

Work continues on the specials with coin and gem collecting. Not as simple as I originally thought in the editor, although I may be overcomplicating things. Basically I will be treating these as Widgets in the system. The underlying code is there. I think this will be easy to do in the game, but the editor code is what I am working on now. We’ll see how it goes in the next few weeks.

At some point I’ll take a break and work on the actual game objects for the coins and gems. I was thinking of putting my embossed face on the coin. I think it would be hilarious, but maybe people would think it odd?

Back on Track

Hello out there!

No pencil sketches available today but there is news of some good progress being made. I’ve actually been able to update the To Do list, which is something that has stayed the same for two months. Has it been that long? 🙂

Since the last To Do list was updated a bit of prep work has gone into getting the Widgets to be selectable and dropped on a map. It still amazes me how certain things take so much code to come together in order to see any benefit, you almost start to lose hope after a while. But when it does come together… it hits you like jolt of electric joy.

Of course there are still things to do (the Widgets is marked as functional but not complete) but at this point in time I can add Widgets, and all the maps where I artificially added widgets via code are now viewable in the editor as such. Here is a screenshot showing the Widget panel as it is now (pretty vacant, but functional!) for a level that should look familiar to you Alpha Testers…

Behold! Here is the widget panel in all its 5-Widget glory!

So what is left to do before you lucky few get to play with the editor? Here is the list:

  1. Ability to Erase a widget
  2. Ability to Undo/Redo widget activity
  3. Level Picker screen needs some polish (to handle lots of levels)
  4. Fun Points system added to cap level features
  5. Editor logic to handle Save conditions
  6. Ability to add Obstacles/Pipes

I’m hoping by month’s end I will have something to send out. The Obstacles addition may be a hefty one, but should be easier than widgets. Time will tell.