Hmm, I've got an interesting problem.
Actually, the code does
exactly what I'm telling it to...which is the problem.
Code:
Remstart
*****************************************************************
* Coins Galore Official Game Engine | Version 0.01 *
* Author & Programmer: Jeremy W. Gardner | Started on 9/22/09 *
*****************************************************************
Remend
`Call setup
GoSub Setup
`---------------------------------------
`The Main Menu will go here once every
`other thing is completed and working.
`---------------------------------------
GoSub LoadGame
`Setup the world one screen
World1:
Load Sound "Media\World_1_Select.mp3",1 : Loop Sound 1
Load Image "Media\World1_platforms.bmp",1
Load Image "Media\World1_platforms2.bmp",2
`Create the player object
Make Object Sphere 1,0.9 : Position Object 1, 0,5,0
Set Object Collision On 1 : Make Object Collision Box 1,-.5,-.5,-.5,.5,.5,.5,0
`Create the boxes of the first level
Make Object Box 2,5,5,5 : Position Object 2,0,0,0 : Texture Object 2,1
Set Object Collision On 2 : Make Object Collision Box 2,-2.5,-2.5,-2.5,2.5,2.5,2.5,0
Make Object Box 3,5,5,5 : Position Object 3,15,5,0 : Texture Object 3,1
Set Object Collision On 3 : Make Object Collision Box 3,-2.5,-2.5,-2.5,2.5,2.5,2.5,0
Make Object Box 4,5,5,5 : Position Object 4,-15,5,0 : Ghost Object On 4 : Texture Object 4,2
Set Object Collision On 4 : Make Object Collision Box 4,2.5,2.5,2.5,-2.5,-2.5,-2.5,0
Make Object Box 5,5,5,5 : Position Object 5,0,5,15 : Ghost Object On 5 : Texture Object 5,2
Set Object Collision On 5 : Make Object Collision Box 5,2.5,2.5,2.5,-2.5,-2.5,-2.5,0
Make Object Box 6,5,5,5 : Position Object 6,0,5,-15 : Ghost Object On 6 : Texture object 6,2
Set Object Collision On 6 : Make Object Collision Box 6,2.5,2.5,2.5,-2.5,-2.5,-2.5,0
`The main level loop
Do
Center Text 500,12,"World 1-Level Select Screen"
Text 0,24,"Health: "+Str$(Health)
Text 0,36,"Lives: "+Str$(Lives)
Text 0,48,"Coins: "+Str$(Coins)
Text 0,60,"Score"+Str$(Score)
Text 0,72,"FPS: "+Str$(Screen FPS() )
`If GameLev=a certain number...
If WorldLev=2 Then Ghost Object Off 4 : Make Object Collision Box 4,-2.5,-2.5,-2.5,2.5,2.5,2.5,0 : Texture Object 4,1
If WorldLev=3 Then Ghost Object Off 5 : Make Object Collision Box 5,-2.5,-2.5,-2.5,2.5,2.5,2.5,0 : Texture Object 5,1
If WorldLev=4 Then Ghost Object Off 6 : Make Object Collision Box 6,-2.5,-2.5,-2.5,2.5,2.5,2.5,0 : Texture Object 6,1
If MouseClick()=1 Then WorldLev=WorldLev+1 : GoSub SaveGame
`controls
`FORWARD
if keystate(17)=1 then move object 1,0.23
if upkey()=1 then move object 1,0.23
`BACK
if keystate(31)=1 then move object 1, -0.23
if downkey()=1 then move object 1, -0.23
`TURN LEFT
if keystate(30)=1 then yrotate object 1,wrapvalue(object angle y(1)-1.5)
if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-1.5)
`TURN RIGHT
if keystate(32)=1 then yrotate object 1,wrapvalue(object angle y(1)+1.5)
if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+1.5)
if controlkey()=1 and playergrav#=0 then playergrav#=0.30
` get current object position
posx#=object position x(1)
posy#=object position y(1)
posz#=object position z(1)
` gravity
playergrav#=playergrav#-0.01
posy#=posy#+playergrav#
`sliding collision
position object 1,posx#,posy#,posz#
if object collision(1,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=-0.0
endif
`set size for controlled object
s#=object size y(1)/2.0
`update with new object position
position object 1,posx#,posy#,posz#
`camera
angle#=object angle y(1)
camdist#=10.5 : camhigh#=posy#+2.5 : camfade#=12.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1
xrotate camera 10
`end loop
Sync
Loop
`=========================================
`P R O C E D U R E S and F U N C T I O N S
`=========================================
`The setup procedure
Setup:
Set Display Mode 1024,768,32
Hide Mouse : Sync On : Sync Rate 60
Backdrop on : Color Backdrop RGB(0,0,0)
Autocam Off
World=1
WorldLev=1
Health=100
Lives=3
Coins=0
Score=0
Return
`------------------------
`The saving procedure
SaveGame:
`Name the file
Filename$="Save Data\SavedGame.CGF"
`Check to see if it exists. If it does, delete it.
If File Exist(Filename$) Then Delete File Filename$ : `This will override the file and replace it with the updated info
`Now start saving the information
Open to Write 1,Filename$
Write String 1,"=========== Saved Game Data ==========="
Write String 1,"DO NOT ALTER ANYTHING! DOING SO CAN AND"
Write String 1," WILL RESULT IN A CORRUPTED GAME FILE."
Write String 1,"======================================="
Write String 1,Str$(World)
Write String 1,Str$(WorldLev)
Write String 1,Str$(Health)
Write String 1,Str$(Lives)
Write String 1,Str$(Coins)
Write String 1,Str$(Score)
Write String 1,""
Write String 1,"The .CGF file format was written specifically for Coins Galore."
Close File 1
Return
`----------------------------
`The loading procedure
LoadGame:
Filename$="Save Data\SavedGame.CGF"
If File Exist(Filename$)
Open To Read 1,Filename$
Read String 1,T$: Rem Ignore This Info
Read String 1,T$: Rem Ignore This Info
Read String 1,T$: Rem Ignore This Info
Read String 1,T$: Rem Ignore This Info
Read String 1,T$: World=Val(T$)
Read String 1,T$: WorldLev=Val(T$)
Read String 1,T$: Health=Val(T$)
Read String 1,T$: Lives=Val(T$)
Read String 1,T$: Coins=Val(T$)
Read String 1,T$: Score=Val(T$)
Read String 1,T$: Rem Ignore This Info
Read String 1,T$: Rem Ignore This Info
Close File 1
Endif
Return
What's happening is that this line of code...
`If GameLev=a certain number...
If WorldLev=2 Then Ghost Object Off 4 : Make Object Collision Box 4,-2.5,-2.5,-2.5,2.5,2.5,2.5,0 : Texture Object 4,1
If WorldLev=3 Then Ghost Object Off 5 : Make Object Collision Box 5,-2.5,-2.5,-2.5,2.5,2.5,2.5,0 : Texture Object 5,1
If WorldLev=4 Then Ghost Object Off 6 : Make Object Collision Box 6,-2.5,-2.5,-2.5,2.5,2.5,2.5,0 : Texture Object 6,1
If MouseClick()=1 Then WorldLev=WorldLev+1 : GoSub SaveGame
...seems to work great, until you try and re-load the level.
The value gets saved correctly, but because each value (2,3,4) has their own cube to turn solid, the last number it saves on will then only light up that one cube, no matter what value it's on. I tried fixing it by doing this:
If WorldLev=2 <> 3 <> 4 Then Ghost Object Off...
And
If WorldLev=2 or 3 or 4 Then Ghost Object Off...
But it still still didn't work. Then all of the cubes were lit up and nothing was being saved properly.
What I'm trying to do is set up a World screen, similar to what Mario Bros. 3 introduced. This is the only problem I'm having, other than that everything is working great.
The Media is attached, and the source code is included. If anybody can help me solve this problem, that would be great!
(Note: There is no reset option as of yet. Every time the game starts it loads the saved game. In order to reset you have to go into the 'Save Data' folder and delete the 'SavedGame.CGF' file.)
-Yodaman Jer.
Great quote: "If you want lots of people to play your game make it simple; lots of people are simple." -Obese87