Sunday, 17 June 2012

Old Dogs, New Tricks

Everyone knows I am old school, I code old school even in Xcode I do everything programmatically and usually in one class, it works, it is just old school. However recently I have been playing with Scratch which is a visual object orientated programming language. One of the great things about Scratch is that you can get an object to simple detect if it is touching another colour, it saves loads of code for object collision. I have also been tinkering with loads of visual stuff like Augmented Reality, image and shape detection, so I have been analysing the content of pixels a lot recently. So I just thought why not code that in to a game engine of my own, I know people have been doing it for ages, but I am old school.

I would usually code a level like this"Old School" 2D array from "OCARBOT" Level 1.

However now it just looks like this. Instead of looking at the LEVELGRID it just analyses the colours of the pixels around the character. If it detects the color (Red: 66 Green: 0 Blue: 8, the slightly reddish black around the platforms) below the character, under the feet, it stops the character from falling. If it detects it to the left or right it prevents you from moving in that direction. It means I can move a character with better collision detect and a hell of a lot less code.

The example image above "OCARBOT Processing" with the new detection implemented, it plays the same just uses loads less code and is faster.

It also means I can do something awesome, very awesome, but that is for another time.

Like I said, "Old Dog, New Tricks"