code is done one instruction after the other, the exeptions are when you call a gosunb or function, hit a goto (goto is bad practice left in for legacy reasons) or use a conditional statement, these are the bits that give a program its power, for example the following code runs as it is written
print "hello"
print "world"
it will read the instruction print, put the letters hello into the print instruction, then copy the text hello to the screen, then it looks at the next line, reads the instruction print and copies the letters world to it, then it copies that text to the screen, then the program ends since it has no more instructions to follow, if you do
top:
print "hello"
print "world"
goto top
then it remembers the label "top" as a location it will need for later, then it does the instructions as before, then it hits a goto instruction and that tells the code to go and read the location "top", so it does, and the next instruction...etc, so it follows those instructions forever and you get an endless list of
hello
world
hello
world
hello
...
etc
all it does is read the instructions one by one and change the position it reads them from when you tell it to, now when you want to structure a program the simplest way is to do it like this
load models
load sounds
load images
set up variables
title screen
do <<<<<<<<<<<<<<<<<<<the outer loop
do <<<<<<<<<<<<<<<<<the main loop
update player
update monsters
update bullets <<<<<if any
update scores and hud info <<<<if any
if end of level then exit <<<set a condition (like a special location) that means the player has won and check for it, then exit if they have
if dead then exit
sync
loop
{clear away all unused models
load the next level
load the monsters positions}
or
let the player load a saved game
loop
the updates (update player etc) are function calls, you place these at the end of the code, the outer loop keeps the whole game running, the inner loop keeps the main game loop running, you exit the inner loop when you need to load another level or inform the player he has died and end the game (a special case of loading the level...this could be a savegame or level 1), general layout then is
load stuff needed for game
do
do
run the game
exit if dead or completed
loop
load next level if completed
game load screen for those that died
loop
functions
gosubs
data
that is pretty standard for most games, and the easiest to follow, cheers.
Mentor.
PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.