Blogger Syntax Highliter

Friday 1 May 2009

Animated walkers


It's silly how easy it is to get started with animation in Processing. All that was required was for me to move my code from a method I named to one called draw and to comment out the call to the method I named. The results are immediate. 

Although I am probably not going to spend a lot more time working on pictures, and I know that Processing is Java underneath, nobody is going to convince me quickly that we need to teach everyone the difference between paint, repaint and update... 




we all walked together


It would be nice to have each walker able to walk around with its own rules for how to colour, but this is hard to do without an OO structure, and readers won't have read the OO stuff by the time they get to my chunk.

I've wound up creating an array for each walker, containing its integer data: its weight, (x,y) position, R, G, B, colours, and direction. Then each walker can have its own function to keep updating these. The main loop can call one function for each walker. It's not ideal, but without an OO structure it's the best I can come up with at this point

Here's an example image with different walkers using different rules, although they are all pretty similar to one another in their rules for what to do at each iteration. (It's not obvious how to refactor that similar code without getting hopelessly complex at this point...)