Installing Cocos2d on Windows 7
Posted by Peter | Filed under Programming
Cocos2d is a free and open source game engine for the Python programming language. On a recent contract, I used the iPhone version of Cocos2d (in the Objective-C programming language). It worked fairly well, so I decided to try the original version. Unfortunately, the setup wasn’t quite as smooth as I would have hoped, and the installation instructions on the Cocos2d website are not terribly helpful, so below are the steps I followed to get it to work.
Please be aware that these instructions will not work forever. Different versions of software are not always compatible with each other, and there may be lots of updates between now and the time you read this. I’ve stated version numbers for each component below so you can compare them with the versions you are installing.
PHP gotcha: Content Type matters!
Posted by Peter | Filed under Programming
I encountered a frustrating problem regarding HTTP content type headers today. It massively broke the design of my site in Firefox, but didn’t seem to affect anything in Internet Explorer. The lesson learned is to be very careful where you send the Content-Type header using PHP.
ADOdb function: GetUpdateSQL
Posted by Peter | Filed under Programming
I have been getting myself familiar with ADOdb by using it in a personal web-development project. I ran across this (rather poorly documented) member function in the database connection class: GetUpdateSQL. In principle, it looks like a very useful function. Given a recordset (which you’ve previously retrieved in a query) and some desired changes, it will generate a nice compatible UPDATE query string for you. However, I have found it to be a little disappointing for my needs.
Making slugs with JavaScript and regular expressions
Posted by Peter | Filed under Programming
You will sometimes want to generate a suitable URL ’slug’ based on something the user has entered, such as the name of a blog post, or perhaps the name of a file which is being uploaded.
In order to ensure that your URLs are consistent, valid, and unambiguous, it is common to place the following restrictions on your slugs: allow only lowercase letters, numbers, and dashes (-). For example, a blog post called “Hello World!” might have a resulting slug of “hello-world”. Additionally, it is common to remove leading and trailing dashes from the final slug.
In this post, I’ll introduce a way of doing this in JavaScript.
Another SL presentation tool: Slide Wheel
Posted by Peter | Filed under Programming, Virtual Worlds
My supervisor (Daniel) and I were giving a SLOODLE presentation at a conference in Second Life today. When we were discussing it earlier this week, Daniel suggested a really novel way of presenting the slides… and since I’m never one to back down from a programming challenge, I built it!
The result is the Slide Wheel. All the slides in your presentation are displayed in a big wheel in mid-air. When you want to show a particular slide, the whole wheel rotates, and the current slide jumps to the foreground. I’ll upload a video of it soon, but for now, here’s a screenshot:
You can get this item free on XStreetSL, as I am releasing it open source. I am sorry it is not perfect yet, but the requests for me to make it available tell me it’s in high demand! Please give it a try, and contact me if you have any questions or if you find any bugs.
Happy presenting!
OpenGL gotcha: my particles are too small
Posted by Peter | Filed under Programming
As far as graphical effects go, a particle system is one of the most versatile. It can be used to simulate things like electrical sparks, dust clouds, smoke, fire, and water. However, there is one problem which I have been annoyed with several times in the past, but until now I hadn’t really bothered to fix it.
I would spend ages programming a particle effect, tweaking all the parameters to get it just right, and it would look fine at first. But then, on another computer, or on a different screen resolution, or even just with a different size of window, the effect suddenly wouldn’t look right. All the particles would be too small or too big.
You can see this problem in the image above. It shows a particle effect for a rocket thruster — the one on the left is how it should look, while the one on the right shows what happened when I roughly tripled the size of the game window.
OpenGL gotcha: remember GL_LIGHT0
Posted by Peter | Filed under Programming
In my experimenting with some simple scene geometry and lighting today, I stumbled into the same pitfall I’ve strumbled into several times before (you’d think I would have learned by now!). While moving around the scene, I found that the lighting on surfaces appeared to change depending on my camera angle — if I looked at a polygon square-on, it seemed much brighter than if I was looking slightly away from it.
There are two common reasons for this problem…
Read the rest of this entry »
PHP4/5: Object orientation and compatibility
Posted by Peter | Filed under Programming, SLOODLE
Some compatibility problems were reported following the release of SLOODLE 1.0, and they largely appear to centre around the object-oriented plugin system I developed for the Presenter module.
The idea is fairly simple. The SLOODLE core or 3rd party developers can create plugin classes to extend the functionality. These will all belong to a structured inheritance hiearchy, and will be automatically detected and loaded by the SLOODLE framework. However, it has been a big challenge maintaining compatibility for both PHP4 and PHP5, given that the object orientation of the language has changed so much in that time.
After considerable efforts, I think I’ve finally found the solution, and it’s infuriatingly inelegant.
OpenGL gotcha: scale your normals!
Posted by Peter | Filed under Programming
My OpenGL blunder this evening involved forgetting to make sure my normals were scaled correctly.
I had a scene with a single point light source and several small rotating cubes. Everything looked fine. I had also written a function to draw a 1×1 plane in the scene, and that looked fine too. I then applied a scaling transformation in my plane-drawing function (using glScalef) to make it 10×10, but for some reason the plane was then totally dark.
I tried moving and rotating the plane to see if it would catch the light at some other angle, but it wouldn’t. Eventually, I spotted the flaw…
PHP quirk: shell commands breaking on Windows
Posted by Peter | Filed under Programming, SLOODLE
I’ve been wrestling with many compatibility quirks in my work on SLOODLE lately, and this one certainly takes the prize. It seems that some perfectly valid shell commands will simply not work when executed from within PHP on Windows.
Read the rest of this entry »

