Optimised the tutorial
- March 17th, 2010
- Posted in News
- Write comment
I managed to get the cpu usage of the tutorial down by about 50%.
This + lowering the in game resolution should make it run even on a shit laptop with on board graphics. (except Jasmine’s because that thing isn’t even a computer).
So what I did was make all the bricks that make up the walls one massive brick, and that got it down from 30% CPU usage on my computer to about 22%. (this reduced the number of instances in the tutorial from 600 to 90)
Then I discovered through the process of elimination that the glow around the text in the tutorial was also causing it to hang. I didn’t think drawing text was such a big deal. I used this common method of drawing borders which is to draw the text you want 5 times. once in the middle and then 4 more times offset around the outside. (like the dots on the “5 side” of a die)
Anyway, taking that glow off reduced the CPU usage on my computer from 22% down to 14%. Seems pretty absurd that “having a nice glow” around the text doubled the CPU usage. It’s like a hood ornament that doubles the weight of the car.

I used to use the same technique to draw text, only I did it all 360 degrees! And I wondered why it was slow…
Anyway it always feels good to optimize code, I love it!