Ah, code organisation, an interesting subject.
Lots of companies have specific standards for this sort of thing, the last document I saw ran to 10 pages.
I use prefixes for all my variable names like this:
rem Variable prefixes are:
rem g = Global
rem b = boolean
rem f = float/real
rem i = integer
rem w = Word
rem dw = DWORD
rem y = byte
So "gfCameraPositionX" would store the cameras X axis location in space as a float and can be used from any part of the program because it is global.
After I have finished writing a small piece of code, I will ensure the variable names still relate to what they actually do.
I often spend a few minutes working out good names for variables and functions.
This helps LOADS.
I also comment like a mad-man. even if I understand what something does easily, I might not tomorrow.
I use loads of procedures and functions, and make code as modular as possible.
For example, my main loop currently looks something like this:
rem Start Main Loop
do
gosub _MouseInput
gosub _KeyboardInput
gosub _PlayerShipMovement
gosub _ParticleMovement
gosub _PlayerShipBulletMovement
gosub _PlayerShipBulletCollision
gosub _PlayerShipFlareMovement
gosub _EnemyShipMovement
gosub _EnemyShipAI
gosub _EnemyShipBulletMovement
gosub _EnemyShipBulletCollision
gosub _ParticleExplosions
gosub _CameraMovement
gosub _ShowHUD
gosub _ShowIngameText
gosub _ShowDebugText
Rem Position light source around where the players ship is
position light 0, gObject(gwPlayerShipObject).gfPositionX,gObject(gwPlayerShipObject).gfPositionY,gObject(gwPlayerShipObject).gfPositionZ
rem Calculates time difference between 2 frame syncs - used for various timings in the game
gdwTimeDifference =getTimeDifference()
sync : rem update screen
rem End Main Loop
loop
The light source code is just temporary, but I still commented it.
I also define all my initial variables in the same place, create my objects in the same place etc. so when I look for something I can find it easily.
You need to get a good mental picture of how the code is structured to work on it sucessfully.
For example, in the code above, only the "_PlayerShipMovement" procedure will ever move the main space ship, nothing else will, ever.
It's all very well knowing how to hack out a piece of code, but if it's written badly it will be worthless in a weeks time (this is especially true in a development environment where other people will use your code).
And while we are on the rough subject, make sure you backup your code.
I use a 3 day rotating offsite backup, which simply means 3 different directories that store the 3 last versions of my code on a website somewhere that only I have write access to.
STE ;¬!