Oh my......this is not what I was expecting you to do at all. All subroutines must be ended with a 'return' command. You should put all of your subroutines after your main code like you did the functions. Then your main code calls the subroutines and functions as they are needed. You should straighten this out before you do anything else. To show you what I'm talking about, look at this:
` ***
` *** START SYSTEM SETUP SECTION
` ***
sync on
sync rate 30
autocam on
hide mouse
randomize timer()
` ***
` *** STOP SYSTEM SETUP SECTION
` ***
` ***************************************
gosub INTRO
wait key
gosub OPTIONS
wait key
gosub LEVEL_INTRO
wait key
gosub MAIN_HEADER
wait key
` *** MAIN SECTION LOOP
` ***
do
`SPECIAL EFFECTS
`SPECIAL EFFECTS
`Trees and Sky - Side-Scrolling
scroll object texture 100, .1,1
scroll object texture 101, .1,1
scroll object texture 102, .1,1
scroll object texture 103, .1,1
scroll object texture 104, .1,1
scroll object texture 105, .1,1
scroll object texture 106, .1,1
scroll object texture 107, .1,1
scroll object texture 108, .1,1
scroll object texture 109, .1,1
scroll object texture 110, .1,1
scroll object texture 111, .1,1
scroll object texture 112, .1,1
scroll object texture 113, .1,1
`OBJECT ORIENTATIONS
`Player Character
1pX# = object position X(1)
1pY# = object position Y(1)
1pZ# = object position Z(1)
1aX = object angle X(1)
1aY = object angle Y(1)
1aZ = object angle Z(1)
`Enemies
for n = 301 to (300 + LevelEnemies(0))
if object exist(n) = 1
pXenemy#(n-300) = object position X(n)
pYenemy#(n-300) = object position Y(n)
pZenemy#(n-300) = object position Z(n)
endif
next n
`LIVE SCREEN DISPLAY
`TEXT
`HUD
`CONTROL INPUT
`Acceleration and Pitch
if Upkey()=1 then move object 1,10
if Downkey()=1 then move object 1,-10
`Turning and Banking
if Leftkey()=1 then 1aY = wrapvalue(1aY-5)
if Rightkey()=1 then 1aY = wrapvalue(1aY+5)
`Releasing Projectiles
if Spacekey()=1
if SpacekeyHold = 0
for n = 21 to 23 : `search for a projectile which is ready to be released
if projectileReleased(n) = 0
projectileReleased(n) = 1
show object n
exit
endif
next n
endif
SpacekeyHold = 1 : `key pressed
else
SpacekeyHold = 0 : `key released
endif
`Quit Game
if Inkey$() = "q"
GameOver$ = "quit"
ClearWorld()
gosub EndSection
endif
`TRANSFORM OBJECTS
`MOVE OBJECTS - PRE-COLLISION
`Player Character
Yrotate object 1,1aY : `rotate object accordingly
new1pX# = object position X(1)
new1pY# = object position Y(1)
new1pZ# = object position Z(1)
`Projectiles
for n = 21 to 23
if projectileReleased(n) = 1 then move object n,20 : `move the projectile if it's been released
next n
`Enemies
MoveLevelEnemies()
`CHECK COLLISION
`Check Player Character
`Wall Collision
s# = 12.0
if get static collision hit(1pX#-s#,1pY#-s#,1pZ#-s#, 1pX#+s#,1pY#+s#,1pZ#+s#, new1pX#-s#,new1pY#-s#,new1pZ#-s#, new1pX#+s#,new1pY#+s#,new1pZ#+s#) = 1
dec new1pX#, get static collision x()
dec new1pY#, get static collision y()
dec new1pZ#, get static collision z()
position object 1,new1pX#,new1pY#,new1pZ# : rem adjust my position according to collision
endif
`Pick-Ups
`Check Projectile
for p = 21 to 23 : `Check all projectiles
if projectileReleased(p) > 0
`If this projectile has been released or is exploding
`Wall Collision
for n = 101 to 200 : `Check all walls
if object exist(n) = 1 : `If wall exists
if object collision(p,n) > 0 : `If projectile hits this wall
projectileReleased(p) = 2 : `Start projectile explosion
endif
endif
next n : `Check next wall
`Enemy Collision
for n = 301 to (300 + LevelEnemies(0)) : `Check all enemy objects on this level
if object exist(n) = 1 : `If enemy is still alive
if object collision(p,n) > 0 : `If projectile hits this enemy
projectileReleased(p) = 2 : `Start projectile explosion
delete object n : `Remove enemy object
`**********EDIT HERE FOR MULTI-LEVEL'S*****
LevelEnemiesDestroyed(0) = LevelEnemiesDestroyed(0) + 1 : `Mark up one more destroyed enemy
if LevelEnemiesDestroyed(0) = LevelEnemies(0) : `If all the enemies on this level are destroyed
GameOver$ = "win"
ClearWorld() : `Clear game world
inc LevelNumber,1 : `Go to the next level
if LevelNumber = TotalLevels + 1
`If there are no more levels
gosub EndSection : `End the game
else : `Otherwise
gosub LEVEL_INTRO
endif
endif
endif
endif
next n
endif
if projectileReleased(p) = 2 then projectileCollide(p) : `If projectile is exploding, continue explosion
next p
`Check Enemy
s# = 25.0
for n = 1 to LevelEnemies(0)
if object exist(n+300) = 1
x1=pXenemy#(n) : `Abbreviated variable name to save space on lines below
y1=pYenemy#(n)
z1=pZenemy#(n)
x2=newpXenemy#(n)
y2=newpYenemy#(n)
z2=newpZenemy#(n)
if get static collision hit(x1-s#,y1-s#,z1-s#,x1+s#,y1+s#,z1+s#,x2-s#,y2-s#,z2-s#,x2+s#,y2+s#,z2+s#)=1
newpXenemy#(n) = newpXenemy#(n) - get static collision x()
newpYenemy#(n) = newpYenemy#(n) - get static collision y()
newpZenemy#(n) = newpZenemy#(n) - get static collision z()
position object n+300,newpXenemy#(n),newpYenemy#(n),newpZenemy#(n) : rem adjust my position according to collision
endif
endif
next n
`Set Post-Collision Object Orientation Values
`Player Character
1pX# = object position X(1)
1pY# = object position Y(1)
1pZ# = object position Z(1)
1aX = object angle X(1)
1aY = object angle Y(1)
1aZ = object angle Z(1)
`Projectile
for n = 21 to 23
if projectileReleased(n) = 0
position object n, 1pX#,1pY#,1pZ#
rotate object n, 1aX,1aY,1aZ
endif
next n
`Check Player Expiration
`MOVE CAMERA
set camera to follow 1pX#,1pY#,1pZ#, 1aY,50,70, 1,1
`MOVE LIGHT
`REFRESH SCREEN
sync
loop
` ***
` *** STOP MAIN SECTION
` ***
` *****************************************
`
gosub ENDSECTION
end
rem **************** SUBROUTINES ***************************
INTRO:
` ***
` *** INTRO SECTION HEADER
` ***
`REM LOAD TEXTURES
Load image "images/cell.bmp",1
`DECLARE VARIABLES
`SCREEN DISPLAY
load bitmap "images/splashexample.bmp"
set text size 80 : center text 320,170,"Bacteria"
wait 1000
set text size 70 : center text 320,250,"Bash"
wait 1000
set text size 40 : center text 320,300,"To cure the World"
wait 1000
cls 0
load bitmap "images/splashexample.bmp"
set text size 30 :center text 320,220,"FLYER PROTOTYPE TEMPLATE"
center text 320,260,"HIT ANY KEY TO BEGIN"
`LOAD SOUNDS
`SOUND EFFECTS
`SPECIAL EFFECTS
`REFRESH SCREEN
sync
` ***
` *** INTRO SECTION LOOP
` ***
do
`SCREEN DISPLAY
`CONTROL INPUT
if keystate( scancode() ) = 1 then gosub OptionsSection
`REFRESH SCREEN
sync
loop
` ***
` *** END INTRO SECTION
return
OPTIONS:
` *****************************************
` ***
` *** START OPTIONS SECTION
` ***
` ***
` *** OPTIONS SECTION HEADER
` ***
OptionsSection:
`DECLARE VARIABLES
` 0,0 is the exact center of the screen
screenLeft = -1 * (Screen Width() / 2) : `Left edge of screen
screenRight = (Screen Width() / 2) : `Right edge of screen
` Screen Width() automatically determines the pixel resolution width of the game screen -
` Default is 640
screenTop = (Screen Height() / 2) : `Top edge of screen
screenBottom = -1 * (Screen Height() / 2) : `Bottom edge of screen
` Screen Height() automatically determines the pixel resolution height of the game screen -
` Default is 480
`Levels
TotalLevels = 3 : `Total number of levels
LevelNumber = 1 : `Start on Level 1
`SCREEN DISPLAY
cls 0
ink rgb(255,255,255),0
center text 320,220, "PRESS SPACE BAR TO FIRE"
center text 320,260, "USE ARROW KEYS TO MOVE"
center text 320,280, "PRESS 'Q' TO QUIT"
center text 320,350, "PRESS ANY KEY TO CONTINUE"
`LOAD SOUNDS
`SOUND EFFECTS
`SPECIAL EFFECTS
`REFRESH SCREEN
sync
` *** END OPTIONS SECTION
` ***
return
LEVEL_INTRO:
` *****************************************
` ***
` *** START LEVEL INTRO SECTION
` ***
` ***
` *** OPTIONS SECTION HEADER
` ***
LevelIntroSection:
`DECLARE VARIABLES
`SCREEN DISPLAY
cls 0
ink rgb(255,255,255),0
center text 320,220, "LEVEL"
set cursor 320,240
print LevelNumber
center text 320,260, "HIT ANY KEY TO BEGIN"
`LOAD SOUNDS
`SOUND EFFECTS
`SPECIAL EFFECTS
`REFRESH SCREEN
sync
` ` *** END LEVEL INTRO SECTION
return
MAIN_HEADER:
` *****************************************
` ***
` *** START MAIN SECTION
` ***
` ***
` *** MAIN SECTION HEADER
` ***
MainSection:
`SET VARIABLES
spaceHold = 0 : `Is space key being held down
returnHold = 0 : `Is return key being held down
lightColor = 3 : `Set of colors for light, 1-8
backdropColor = 3 : `Set of colors for backdrop, 1-8
`Colors
`Light 0
if Spacekey()=1
if spaceHold = 0
inc lightColor, 1
if lightColor = 9 then lightColor = 1
changeColor(0,lightColor) : `Function Call
spaceHold = 1
endif
else
spaceHold = 0
endif
`Backdrop
if Returnkey()=1
if returnHold = 0
inc backdropColor, 1
if backdropColor = 9 then backdropColor = 1
changeColor(1,backdropColor) : `Function Call
returnHold = 1
endif
else
returnHold = 0
endif
`SCREEN DISPLAY
cls 0
backdrop on
color backdrop rgb(98,000,000) : `Match the backdrop and fog colors for a smooth blending effect
make3DSprite(67, 641,481, "RightBottom", screenRight-0,screenBottom-0, "images/screenoverlay2.bmp",0,0,0 ,0)
make3DSprite(54, 300,300, "RightBottom", screenRight-210,screenBottom-0, "images/bio.bmp",0,0,0 ,0)
`SET LIGHTS
fog off : `By default, fog is off
fog on : `Turn fog effects on
fog color rgb(90,000,000) : `Color of fog
fog distance 1000 : `Distance from camera when objects are hidden by fog
`DECLARE VARIABLES
`Player Character
`Projectiles
dim projectileReleased(23)
`LoadPlayerCharacter will create projectile objects 21-23 (0-20 are blank)
`projectileReleased(n) = 0 : Projectile waiting to be released
`projectileReleased(n) = 1 : Projectile traveling through the air
`projectileReleased(n) = 2 : Projectile currently exploding
dim projectileExplode(23)
SpacekeyHold = 0 : `Key release
`Enemies
dim LevelEnemies(0) = 0
dim LevelEnemiesDestroyed(0) = 0
thisLevelEnemies = 0
`Other
GameOver$ = ""
`LOAD IMAGES
`SCREEN DISPLAY
cls 0
backdrop on
`TEXTDECLARE VARIABLES
` 0,0 is the exact center of the screen
screenLeft = -1 * (Screen Width() / 2) : `Left edge of screen
screenRight = (Screen Width() / 2) : `Right edge of screen
` Screen Width() automatically determines the pixel resolution width of the game screen -
` Default is 640
screenTop = (Screen Height() / 2) : `Top edge of screen
screenBottom = -1 * (Screen Height() / 2) : `Bottom edge of screen
` Screen Height() automatically determines the pixel resolution height of the game screen -
` Default is 480
`HEADS-UP DISPLAY (HUD)
`OBJECT CREATION
`World Map
LoadLevelMap(LevelNumber]
`Player Character
LoadPlayerCharacter()
`Enemies
LoadLevelEnemies()
thisLevelEnemies = LevelEnemies(0)
`Declare New Variables
dim pXenemy#(thisLevelEnemies)
dim pYenemy#(thisLevelEnemies)
dim pZenemy#(thisLevelEnemies)
dim newpXenemy#(thisLevelEnemies)
dim newpYenemy#(thisLevelEnemies)
dim newpZenemy#(thisLevelEnemies)
` Screen Height() automatically determines the pixel resolution height of the game screen -
` Default is 480
`Pick-Ups
`LOAD MODELS
`SET LIGHTS
`SET CAMERA
`SOUND EFFECTS
`SPECIAL EFFECTS
`REFRESH SCREEN
sync
return
ENDSECTION:
` *****************************************
` ***
` *** START END SECTION
` ***
` ***
` *** END SECTION HEADER
` ***
EndSection:
`DECLARE VARIABLES
`SCREEN DISPLAY
cls 0
ink rgb(255,255,255),0
if GameOver$ = "quit" then center text 320,220, "GAME OVER"
if GameOver$ = "win" then center text 320,220, "YOU WIN!"
center text 320,260, "PLAY AGAIN [Y/N]?"
`SOUND EFFECTS
`SPECIAL EFFECTS
`REFRESH SCREEN
sync
` ***
` ***
` *** STOP END SECTION
return
rem ************************* FUNCTIONS *************************
` *****************************************
` ***
` *** START FUNCTIONS
` ***
` ***
` *** LOAD LEVEL MAP - LoadLevelMap
` *** Generates the 3D level
` ***
function LoadLevelMap(LevelNumber)
`Walls
load image "images/cell.bmp",1
load image "images/cell3.bmp",2
if LevelNumber = 0
LoadObstacle(101, 600,300,100, 800,0,1550, "wall") : `North Wall
LoadObstacle(102, 600,300,100, 800,0,50, "wall") : `South Wall
LoadObstacle(103, 100,300,600, 50,0,800, "wall") : `West Wall
LoadObstacle(104, 100,300,600, 1550,0,800, "wall") : `East Wall
`Corners
LoadObstacle(105, 500,300,500, 250,0,1350, "corner") : `Northwest Corner
LoadObstacle(106, 500,300,500, 1350,0,1350, "corner") : `Northeast Corner
LoadObstacle(107, 500,300,500, 250,0,250, "corner") : `Southwest Corner
LoadObstacle(108, 500,300,500, 1350,0,250, "corner") : `Southeast Corner
`Pillars
LoadObstacle(109, 200,300,200, 800,0,1200, "pillar") : `North Pillar
LoadObstacle(110, 200,300,200, 800,0,400, "pillar") : `South Pillar
LoadObstacle(111, 200,300,200, 400,0,800, "pillar") : `West Pillar
LoadObstacle(112, 200,300,200, 1200,0,800, "pillar") : `East Pillar
LoadObstacle(113, 200,300,200, 800,0,800, "pillar") : `Center Pillar
`Floor
LoadObstacle(100, 1600,1,1600, 800,0,800, "floor") : `Floor
Texture object 101,2
Texture object 102,2
Texture object 103,2
Texture object 104,2
Texture object 105,2
Texture object 106,2
Texture object 107,2
Texture object 108,2
Texture object 109,2
Texture object 110,2
Texture object 111,2
Texture object 112,2
Texture object 113,2
Texture object 100,2
endif
if LevelNumber = 1
LoadObstacle(501, 600,300,100, 800,0,1550, "wall") : `North Wall
LoadObstacle(502, 600,300,100, 800,0,50, "wall") : `South Wall
LoadObstacle(503, 100,300,600, 50,0,800, "wall") : `West Wall
LoadObstacle(504, 100,300,600, 1550,0,800, "wall") : `East Wall
`Corners
LoadObstacle(505, 500,300,500, 250,0,1350, "corner") : `Northwest Corner
LoadObstacle(506, 500,300,500, 1350,0,1350, "corner") : `Northeast Corner
LoadObstacle(507, 500,300,500, 250,0,250, "corner") : `Southwest Corner
LoadObstacle(508, 500,300,500, 1350,0,250, "corner") : `Southeast Corner
`Pillars
LoadObstacle(509, 200,300,200, 800,0,1200, "pillar") : `North Pillar
LoadObstacle(510, 200,300,200, 800,0,400, "pillar") : `South Pillar
LoadObstacle(511, 200,300,200, 400,0,800, "pillar") : `West Pillar
LoadObstacle(512, 200,300,200, 1200,0,800, "pillar") : `East Pillar
LoadObstacle(513, 200,300,200, 800,0,800, "pillar") : `Center Pillar
`Floor
LoadObstacle(500, 1600,1,1600, 800,0,800, "floor") : `Floor
Texture object 501,1
Texture object 502,1
Texture object 503,1
Texture object 504,1
Texture object 505,1
Texture object 506,1
Texture object 507,1
Texture object 508,1
Texture object 509,1
Texture object 510,1
Texture object 511,1
Texture object 512,1
Texture object 513,1
Texture object 500,1
endif
endfunction
` ***
` *** LOAD OBSTACLES - LoadObstacle
` *** Generates the solid static wall/pillar elements of the 3D level
` ***
function LoadObstacle(myObject, myXScale,myYScale,myZScale, myXPosition,myYPosition,myZPosition, myType$)
load object "models/box100.x", myObject
scale object myObject, myXScale,myYScale,myZScale
make object collision box myObject, 0-(myXScale/2),0,0-(myZScale/2), (myXScale/2),myYScale,(myZScale/2), 0
position object myObject, myXPosition,myYPosition,myZPosition
make static collision box myXPosition-(myXScale/2),myYPosition,myZPosition-(myZScale/2),myXPosition+(myXScale/2),myYPosition+myYScale,myZPosition+(myZScale/2)
endfunction
` ***
` *** LOAD PLAYER CHARACTER - LoadPlayerCharacter
` *** Generates the player character ship and weapons
` ***
function LoadPlayerCharacter()
`Construction
`Ship
`Central Control Object
make object sphere 1,1 : `create the central control object
`Hull
make object cone 2,0 : `make a cone
scale object 2, 0,0,0 : `squash the cone front to back
xrotate object 2,0 : `turn cone on it's front
make mesh from object 2,2 : `make a mesh object from the cone
delete object 2 : `delete object 2 (cone); mesh 2 (cone) still exists
`Assembly
add limb 1,1,2 : `add a limb to object 1 (controller), call it limb 1, and use mesh 2 (cone) for the limb
color object 1,rgb(200,0,255)
make object collision box 1, -12,-12,-12, 12,12,12, 1 : `the collision box extends past the controller
`Projectiles
load image "images/cell2.bmp",1
for n = 21 to 23 : `3 projectiles
make object cylinder n,4
set object n, 1,1,1,2,0,1,0
Texture object n,1
make object collision box n, -2,-2,-2, 2,2,2, 0
hide object n
next n
`Positioning
`Ship
position object 1, 1000,50,600 : `move player to selected starting spot in maze
yrotate object 1, 270 : `rotate player to face west
`Projectiles
for n = 21 to 23 : `3 projectiles
position object n, object position X(1),object position y(1),object position z(1)
set object to object orientation n,1
projectileReleased(n) = 0
next n
`Camera
position camera 1100,70,600
point camera object position X(1),object position Y(1),object position Z(1) : rem point camera at player character
endfunction
` ***
` *** PROJECTILE COLLIDE - projectileCollide
` *** Projectile collision explosion animation
` ***
function projectileCollide(p)
if projectileExplode(p-20) = 0
color object p,rgb(000,255,000)
ghost object on p
endif
projectileExplode(p-20) = projectileExplode(p-20) + 1
if projectileExplode(p-20) <= 3
scale object p, 100 + (projectileExplode(p-20) * 800),100 + (projectileExplode(p-20) * 200),100 + (projectileExplode(p-20) * 200)
endif
if projectileExplode(p-20) > 3
scale object p, 700 - ((projectileExplode(p-20)-2) * 800),700 - ((projectileExplode(p-20)-2) * 200),700 - ((projectileExplode(p-20)-2) * 800)
endif
if projectileExplode(p-20) = 6
scale object p, 100,100,100
color object p,rgb(0,255,0)
ghost object off p
hide object p
projectileReleased(p) = 0
projectileExplode(p-20) = 0
endif
endfunction
` ***
` *** LOAD LEVEL ENEMIES - LoadLevelEnemies
` *** Generates the enemies
` ***
function LoadLevelEnemies()
LoadSpinner(301, 1000,50,1400) : `(ObjNum, XPos,YPos,ZPos)
LoadSpinner(302, 600,50,1000) : `(ObjNum, XPos,YPos,ZPos)
for x = 301 to 400
if object exist(x) = 1 then LevelEnemies(0) = LevelEnemies(0) + 1
`count how many enemies are on this level
next x
endfunction
` ***
` *** LOAD SPINNER - LoadSpinner
` *** Generates a simple spinning enemy
` ***
function LoadSpinner(ObjNum, XPos,YPos,ZPos)
load image "images/cell2.bmp",999
make object cube ObjNum,50
texture object ObjNum,999
scroll object texture ObjNum, .1,1
make object collision box ObjNum, -25,-25,-25, 25,25,25, 0
rotate object ObjNum, 45,0,45
fix object pivot ObjNum
position object ObjNum,XPos,YPos,ZPos
endfunction
` ***
` *** MOVE LEVEL ENEMIES - MoveLevelEnemies
` *** Moves the enemies
` ***
function MoveLevelEnemies()
for n = 301 to 400
if object exist(n) = 1
Yrotate object n, wrapvalue(object angle Y(n)+20)
n2 = rnd(1)
if n2 = 1 then move object n,10
endif
next n
for n = 301 to (300 + LevelEnemies(0))
if object exist(n) = 1
newpXenemy#(n-300) = object position X(n)
newpYenemy#(n-300) = object position Y(n)
newpZenemy#(n-300) = object position Z(n)
endif
next n
endfunction
` ***
` *** START FUNCTIONS
` ***
` ***
` *** MAKE 3D SPRITE - make3DSprite
` *** Make a 3D plain that acts likea sprite
` ***
function make3DSprite(thisObjNum, thisWidth,thisHeight, thisPos$,thisXPos,thisYPos, thisTexture$,thisRed,thisGreen,thisBlue, thisTransparency)
`Create Object
make object plain thisObjNum,thiswidth,thisheight : ` Create a flat plain
`Color/Texture Object
if thisTexture$ = "NONE" : `If no texture is defined
color object thisObjNum, rgb(thisRed,thisGreen,thisBlue) : `Set the color of the plain
else : `If a texture is defined
load image thisTexture$,thisObjNum : `Load the texture into the game
texture object thisObjNum,thisObjNum : `Apply
endif
`Object Settings
set object thisObjNum, 1,thisTransparency,1,0, 0,0,0
`Wire,Trans,Cull,Filter, Light,Fog,Ambient
`Change Light or Ambient to 1 to see the differences
`Position Object
thisZPos = 400
`Since these are 3D Objects,
`we need to determine how far away from the camera they should be
`to display at the correct size
`screenWidth (640) / 4 = 160
`screenHeight (480) / 3 = 160
`160 * Camera Depth of Field (2.5) = 400 = thisZPos
if thisPos$ = "LeftTop" then position object thisObjNum, thisXPos+(thisWidth/2),thisYPos-(thisHeight/2),thisZPos
if thisPos$ = "LeftMiddle" then position object thisObjNum, thisXPos+(thisWidth/2),thisYPos,thisZPos
if thisPos$ = "LeftBottom" then position object thisObjNum, thisXPos+(thisWidth/2),thisYPos+(thisHeight/2),thisZPos
if thisPos$ = "CenterTop" then position object thisObjNum, thisXPos,thisYPos-(thisHeight/2),thisZPos
if thisPos$ = "CenterMiddle" then position object thisObjNum, thisXPos,thisYPos,thisZPos
if thisPos$ = "CenterBottom" then position object thisObjNum, thisXPos,thisYPos+(thisHeight/2),thisZPos
if thisPos$ = "RightTop" then position object thisObjNum, thisXPos-(thisWidth/2),thisYPos-(thisHeight/2),thisZPos
if thisPos$ = "RightMiddle" then position object thisObjNum, thisXPos-(thisWidth/2),thisYPos,thisZPos
if thisPos$ = "RightBottom" then position object thisObjNum, thisXPos-(thisWidth/2),thisYPos+(thisHeight/2),thisZPos
`Finish
lock object on thisObjNum : `Attach object to the camera view
set object collision off thisObjNum : ` Ignore collisions with HUD
endfunction
` ***
` *** CHANGE COLOR - changeColor
` *** Changes the color of the light or backdrop
` ***
function changeColor(myType,myColor)
if myType = 0
if myColor = 1 then color light 0, rgb(0,0,0)
if myColor = 2 then color light 0, rgb(0,0,255)
if myColor = 3 then color light 0, rgb(0,255,0)
if myColor = 4 then color light 0, rgb(0,255,255)
if myColor = 5 then color light 0, rgb(255,0,0)
if myColor = 6 then color light 0, rgb(255,0,255)
if myColor = 7 then color light 0, rgb(255,255,0)
if myColor = 8 then color light 0, rgb(255,255,255)
else
if myType = 1
if myColor = 1 then color backdrop rgb(0,0,0)
if myColor = 2 then color backdrop rgb(0,0,255)
if myColor = 3 then color backdrop rgb(0,255,0)
if myColor = 4 then color backdrop rgb(0,255,255)
if myColor = 5 then color backdrop rgb(255,0,0)
if myColor = 6 then color backdrop rgb(255,0,255)
if myColor = 7 then color backdrop rgb(255,255,0)
if myColor = 8 then color backdrop rgb(255,255,255)
endif
endif
endfunction
` ***
` ***
` *** CLEAR WORLD - ClearWorld
` *** Remove all existing 3D elements from world
` ***
function ClearWorld
for x = 1 to 1000
if object exist(x) = 1 then delete object x
if matrix exist(x) = 1 then delete matrix x
if mesh exist(x) = 1 then delete mesh x
if light exist(x) = 1 then delete light x
if x <= 32
if animation exist(x) = 1 then delete animation x
endif
next x
`Static Objects
make object cube 1,5
make static object 1
delete object 1
delete static objects
fog off
backdrop off
cls 0
endfunction
` ***
` *** STOP FUNCTIONS
` ***
`***
`*** END PROGRAM
`***
`*****************************************
`*****************************************
I did not optimize your main loop, but you should be able to pull out subroutines or functions that you can simply call from it. Some of your names for the subroutines may be a little different than what I named them, so you'll have to double-check that. Once you get it up and running like you want, let me know if you still have the problem or not. I don't know if it will make a difference or not, but your call to 'function LoadLevelMap(LevelNumber)' did not have a closing parenthesis at the end, but a 'close box' character. I changed it in the code above.
LB