It's funny, I was working with another coder the other day and found out he is from Australia also. You know you're a serious coder when you are still up at 3:15am working on something.
Anyway, I had been working on combining the code into one also. Take a look at this:
Rem Project: Dark Basic Pro Project
Rem Created: Wednesday, November 17, 2010
Rem ***** Main Source File *****
sync on
sync rate 60
hide mouse
autocam off
set display mode 800, 640, 32
//setting up player cube
make object cube 1, 2
color object 1, rgb(0, 0, 255)
position object 1, 0, 50, 0
make object collision box 1, -1.4., -1.4, -1.4, 1.4, 1.4, 1.4, 0
ScreenWidth = screen width() : ScreenHeight = screen height()
TotalPlatforms = 14 // be sure to add to this and to the data at PF_Data when you add more platforms
gosub SetupPlatforms
//speed variable
speed# = .3
//make the timer variable.
time = 6000
GameOver = 0 : TimeToGo = 0
//main program loop
repeat
//movement
if upkey() then move object 1, speed#
if downkey() then move object 1, -speed#
if rightkey() then yrotate object 1, object angle y(1)+1
if leftkey() then yrotate object 1, object angle y(1)-1
//reposition player to the 1st platform after a fall
if object position y (1) < -10
position object 1, 0,50,0
speed# = 0.3
grav# = 0.0
endif
//This is the timer system
Time = Time - 1
`What to do when the timer reaches 0
If Time <= 0
FinalTimer = timer() + 1500
set text size 35
set text font "times new roman"
xpos = ScreenWidth / 2 : ypos = ScreenHeight / 2
repeat
center text xpos,250, "TOO LATE"
center text xpos,350, "YOU HAVE RUN OUT OF TIME"
sync
until timer() > FinalTimer
GameOver = 1
endif
//Gravity
x# = object position x(1)
y# = object position y(1)
dec y#, grav#
inc grav#, .01
z# = object position z(1)
gosub CheckCollision
//Camera setup
if y# < -100
position camera camera position x(), 100 + camera position y() - y# , camera position z()
` y# = 100
`grav# = 0.0
endif
position object 1, x#, y#, z#
set camera to follow object position x(1), object position y(1), object position z(1), object angle y(1), 20, 15, 5, 0
point camera object position x(1), object position y(1), object position z(1)
gosub Debug
if GameOver > 0 then gosub HandleGameOVer
sync
until TimeToGo > 0
end
SetupPlatforms:
//Setting up platforms
for t = 2 to TotalPlatforms
make object plain t, 50, 50
make object collision box t, -22, -22, -22, 22, 2, 22, 22
point object t, 0, -50, 0
next t
make object plain 15, 10, 10
make object collision box 15, -3, -3, -3, 3, 2, 3, 3
point object 15, 0, -50, 0
//Positioning the platforms
restore PF_Data
for pf = 1 to TotalPlatforms
read obj,x#,y#,z#,red,green,blue
position object obj,x#,y#,z#
color object obj,rgb(red,green,blue)
set object ambience obj,rgb(red,green,blue)
NEXT
return
CheckCollision:
//collision detection
CollObj = object collision(1,0)
if CollObj > 0
dec x#, get object collision x()
down# = get object collision y()
` if down#
if spacekey() :`and down# < 0
grav# = -.9
else
grav# = 0
endif
` endif
dec y#, down#
dec z#, get object collision z()
endif
//speed increase platforms
for t = 6 to 15
if CollObj = t and speed# > .3 : `object collision (1,t) = 1 and speed# > .3
speed# = .3
endif
next t
for t = 3 to 5
if CollObj = t and speed# <> .9 : `object collision (1,t) = 1 and speed# <> .9
SpeedIncreasedTimer = timer() + 1500
speed# = .5
endif
next t
//Jump increase platforms
for t = 6 to 9
if CollObj = t : `object collision (1,t) = 1
dec x#, get object collision x()
down# = get object collision y()
if down#
if spacekey() and down# < 0
if grav# <> -.9
grav# = -.9
JumpHeightIncreasedTimer = timer() + 1500
endif
else
grav# = 0
endif
endif
dec y#, down#
dec z#, get object collision z()
endif
next t
If CollObj = 15 then GameOver = 2 : ` player has reached the end
return
HandleGameOver:
Select GameOver
case 1
FinalTimer = timer() + 2000
set text size 35
set text font "times new roman"
xpos = ScreenWidth / 2 : ypos = ScreenHeight / 2
repeat
center text xpos,250, "TOO LATE"
center text xpos,350, "YOU HAVE RUN OUT OF TIME"
sync
until timer() > FinalTimer
TimeToGo = 1
endcase
case 2
FinalTimer = timer() + 2500
set text size 35
set text font "times new roman"
xpos = ScreenWidth / 2 : ypos = ScreenHeight / 2
repeat
center text xpos,250, "You did it, congratulations!"
center text xpos,350, "Your skills are incredible!"
sync
until timer() > FinalTimer
TimeToGo = 2
endcase
` at this point, you could give the user the option to restart the game, or you could
` load in a new level if they succeeded
EndSelect
return
Debug:
if SpeedIncreasedTimer > timer() then text 5,20,"Speed Increased!"
if JumpHeightIncreasedTimer > timer() then text 5,40,"Jump Height Increased!"
text 5,5,"TIME LEFT: " + str$(time)
` text 5,100,"object pos y(1) = " + str$(object position y(1))
text 5,120,"CollObj = " + str$(CollObj)
return
PF_Data:
` platform ObjectNumber,x#, y#, z#
data 2,0.0,-3.5,0.0,144,238,144
data 3,-70, -3.5, 60,135,206,235
data 4,70, -3.5, 235,135,206,235
data 5,-100, -3.5, 315,135,206,235
data 6,70, -3.5, 60,205,000,000
data 7,-70, -3.5, 220,205,000,000
data 8,90, -3.5, 315,205,000,000
data 9,-100, -3.5, 395,205,000,000
data 10,-70, -3.5, 140,144,238,144
data 11,70, -3.5, 155,144,238,144
data 12,70, -3.5, 410,144,238,144
data 13,25, -3.5, 480,144,238,144
data 14,-55.0, -3.5, 490.0,255,127,000
data 15,-55, -3.5, 450,255,0,255
I am using plane 15 for the final goal. The planes all show their colors properly, and everything seems to work okay. Take a look and see if there is anything you want changed. It also shows the current object that is being collided with - this was only put in to help me and is for debugging purposes.
If you run out of time, it will tell you and then end. If you reach plane 15, it congratulates you and ends.