lightatdawn

Hosted By:
cprogramming.com






SIMPLE THINGS I LEARNED ABOUT GAME DEVLOPMENT


1) Keep your code neat and tidy!

a) Indent code properly and in an orderly, standard, fashion.
b) Never place multiple functions/commands on a single line.

2) Use comments liberally throughout your code.

Place a brief comment on the purpose of every function. Comments regarding what certain
variables will be used for should be used in any case where the variables use is not
immediatly apparent and/or immediatly used. Anywhere that the code purpose is not instantly
obvious should be commented to illuminate others about said purpose. Keep comments brief
and to the point. Nobody wants to read a novel converning the reasons you used a do...while
loop over a for loop in a certain instance.

3) Never duplicate code, formulas, or constant values.

Use a global const int for any and every instance where a number is used in multiple places.
Likewide, always write a function to perform any task (no matter how small) that is duplicated
in another part of your program. If speed is an issue then you can always inline or even
__forceinline (if your compiler supports it). Although it may seem easier at the time to just
cut 'n paste some code and use it in another function, it may very well cost you a migrane or
two down the road. That way when you find a bug in the origional code later on, you dont have
to go hunting for other places that the same code was copied to. Or worse yet, you may even
have forgotten that you even copied it at all.

4) Keep track of where you're at in terms of development.

Have a TODO list included in your project. This will help you keep on track and allow you
to assess what still needs doing. You can also use it to list bugs etc so you dont lose
track of them. Additionally I have a HAVEDONE list which just makes me feel better as I can
see whats been done so far.

5) Use Classes.

OOP decimates linear programming with a single twitch of its highly flexable wrist. I wont
go into the millions of reasons that classes will rule the sad, pathetic, world of linear
programming, but suffice to say that there are many. You will eventually discover the
limitations of using functions instead of a class. I used to be a die hard function coder...
That all changed the day I got seriously into development. Its just not practical and its
messy as hell to organise all the globals. Classes instinctivly lead you to become a tidier
programmer.

6) Organise your project in an intuitive fashion.

Chances are that your project will get quite big. Use a new file for each class you have.
Sometimes a class will grow so large that is reasonable to use mutiple CPP files to hold
all class functions. I usually use the following naming conventions to avoid confusion but
any intuitive method would work.

CMap.h //Header for CMap class
CMap.CPP //Basic functions of CMap such as Constructor/Destructor
CMap__Draw.CPP //Functions of CMap relating to drawing
CMap__Load.CPP //Functions of CMap relating to loading data etc...


7) Everything should be scaleable. Everything.

It doesnt matter that you're really, absolutly, 100% completly, sure that you are never,
ever, going to need more than 10 elements in your lookup table. It will never work out that
way; In the end, you'll pay with your time when you have to re-write a bunch of hard-coded
routines (possibly missing some). This relates to tip #3, but it always helps to use
constant variables for array lengths which you would also use, for example, in any case you
may scan through the array with a for loop, etc.



lightatdawn@lycos.com

ÿ