Skip to content

107a. Lunar lander reworked

August 29, 2013

I had another go at the lunar lander, this time from the top down, ie instead of building it a piece at a time, I designed the whole thing first. This is of course the right way to do anything, but it’s much less fun than just building it piece by piece. The code is here.

However, doing it this way clearly shows how state management – controlling which stage of the game you are in (start menu, playing, level 1, level 2, winning, losing etc) – is the basic framework of the program. Everything is built around that frame.

Reworking your code like this is known as “refactoring”, ie improving it without changing what it does.

Advertisement
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: