I want to talk about a game I am currently developing and
about how I generally approach more complicated programs. I’ve always really
enjoyed playing market and trading based games, games like “Taipan!” and
“Tradewinds”. The basic game concept behind these games is you buy products at
one location and then travel to another in hopes of selling it for a profit.
Seems very simple and even boring but add some potential challenges and
somewhat controlled random prices and it can become a very fun and interesting
game. I want to start my game buy having the same game concept at its core but
then I want to creatively expand the game and add more complexity. This leads
into my next topic. How do I write code without knowing where exactly the game
design is headed?
The
answer to the question above has two parts. One is you should be brainstorming
and have a vague idea of stuff you want to add later in the game and you can
plan for them. The second and most important is to program you code in such a
way that it handles general problems and not one exact problem. For example if you are looping through
a list and you know the list has 5 elements in it you can just hard code the
loop to iterate 5 times. Now what would happen if the size of your list
changes, which often happen in almost every program? Your loop would end up
breaking your code. A better way to handle this would be to dynamically
determine the size of your list before starting the loop. This way your loop
will never break at least for having the wrong number of iterations. Everything
in a program that is subject to change should be generated dynamically when
used to avoid problems. When I program I am always thinking about all the
different cases and outcomes of the code I am writing and I write it so my code
can handle them. No one gets this right the first time but that’s what
debugging is for. So my point is think about the future of your code while
writing it not just how can I get this to work for my current circumstances.
No comments:
Post a Comment