SDL Maze!

I wrote some more maze code. This time in C++ using SDL for rendering. To be honest, I started this out by writing an extension for SDL in PHP. I may still finish that and write a blog about it. It was fun but the performance was reaaaally bad so I need to do some work on making it more high level. I was just doing a one to one for the SDL API (except in classes) and then writing the PHP code for DFS and rendering. So yea, as you can imagine, it was slow. Here’s a gist of what it was looking like.

Anyway, I was thinking of using emscripten on the SDL stuff I wrote so I could post a working version here. You’ll have to be satisfied with a short video and link to the code.

My favorite part of writing this in C++ was the part I did in C. I wrote a tweet about it. I really did spend time figuring out a circle fill algorithm instead of just drawing a circle in a paint application. It was more fun. You can see the simple (and poorly commented) code here.

The full code is available: github. There is some refactoring I had considered doing before posting but since it’s been a week and I haven’t touched it, it’s unlikely I will.

Unlike the other versions, I don’t render the path finding efforts in this version. Just the results. I also added the ability to simply move the little dot around using the arrow keys. Just playing around. Have a look.

MOAI Maze!

I created my maze “hello, world” in MOAI. I really enjoyed using MOAI and rather like much of the reasoning behind architectural decisions (primarily that there actually are reasons).

The code for this one is a bit rough since I was also re-familiarizing myself with Lua while learning the MOAI framework.

It’s here, nonetheless: MOAI Maze

I’m exploring a bit more into this framework. I’ve started writing a widget framework for it and will also be writing an actual game with it.

The following requires Chrome and Native Client enabled. I removed the embed since it would just show as an ugly box for 99% of people visiting the site.

Crafty Maze!

I’ve been looking at various game framework/libraries/engines for a long time now. I started my endeavor in 2006 with Torque Game Engine and have continuously been looking at technologies as they come out.

I posted something a while back about building a Maze in Objective-C. I used cocos2d then. Since then, I’ve been using very similar maze code as my “hello, world” of game frameworks.

Recently I looked at Craftyjs . It’s pretty sweet. Here’s my hello, world (bugs and all). There are some performance issues that I could likely optimize out and various other tweaks that I could make. Overall, I don’t really care. My “hello, world” is strictly to get a feel for the framework. I got a feel for it and would recommend it. It’s very much what I’ve wanted from the component entity pattern in a game framework.

The code:

Mac Wildcard DNS & apache subdomain vhosts

Instructions for when I need to do this again and get frustrated with the python DNS server.

First, we setup our local DNS server.

sudo rndc-confgen -a -c /etc/rndc.key 
sudo vi /var/named/dev.local

Populate contents of dev.local with:

dev.local. 7200    IN       SOA     dev.local. (
                     2008031801 ;    Serial
                     15      ; Refresh every 15 minutes
                     3600    ; Retry every hour
                     3000000 ; Expire after a month+
                     86400 ) ; Minimum ttl of 1 day 
dev.local. IN      NS      dev.local. 
dev.local. IN      MX      10 dev.local. 
dev.local. IN      A       {DESTINATION_IP} 
*.dev.local.    IN      A       {DESTINATION_IP}

No, {DESTINATION_IP} is not a variable. Replace it with the IP of your apache server. if local.

sudo vi /etc/named.conf


zone "dev.local" IN {
         type master;
         file "dev.local";

If there are errors presented by either of these commands, follow the logical instructions on resolving the errors

sudo named-checkconf /etc/named.conf 
sudo named-checkzone dev.local /var/named/dev.local

Add the org.isc.named daemon to startup and flush your dns cache

sudo launchctl load -w /System/Library/LaunchDaemons/org.isc.named.plist 
sudo dscacheutil -flushcache

Add to the DNS entries in the System Preferences Advanced adapter config (any adapters used)

Test the setup works:


The ->>HEADER<<- line should read:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9635

If there is an error, it’ll read something like:

;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 21136

When troubleshooting what the error might be, be sure to bounce the org.isc.named daemon if editing the various configuration files.

sudo launchctl stop org.isc.named 
sudo launchctl unload -w /System/Library/LaunchDaemons/org.isc.named.plist 
sudo launchctl load -w /System/Library/LaunchDaemons/org.isc.named.plist 
sudo launchctl start org.isc.named

Once that is completed, on the apache server (ubuntu for me)

sudo a2enmod vhost_alias

Next, modify your vhost

<VirtualHost *:80>
    ServerName dev.local
    ServerAlias *.dev.local
    ServerAdmin webmaster@localhost
    VirtualDocumentRoot /path/to/site/directories/%1
    <Directory /path/to/site/directories>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all

Db_NoRecordExists and RedBean

When initializing RedBean, I realized that I could simply utilize the Zend_Db resource configured in the application.ini to setup the connection.

require_once APPLICATION_PATH . "/../library/RedBean/";
$dbAdapter = Zend_Db_Table::getDefaultAdapter();

This means that I am able to utilize the built in form validation that utilizes the db (Db_NoRecordExists, for example). With one caveat: When there are no tables (cause that’s how RedBean works), attempting to submit a form that persists will cause a SQL exception. I’ll likely export the table structure when I’m pushing to production and won’t have this problem there. It’s merely an annoyance during development.

I’ve enjoyed not writing SQL and simply adding elements to my forms that are then automatically persisted. I’ll obviously need to optimize the table structure once I’ve completed the prototype but that’s an easy thing to do in comparison.

Cocos2d – Tiled

I have learned that the tiled importer in Cocos2D should not be used as is for complex layer based maps. I have ran into odd display issues (lines between layers) and odd limitations (one tilesheet per layer).

The work around I am going to attempt is to load strictly the data that I need using the TMX loader and build a map based on that data. Basically, the Tiled map editor will turn into a placeholder creator.

Once that work is complete, I may look into updating the TMX loader to be a bit more robust, given that I’ll be deep in its bowels soon.