Hey something is wrong with the collision in my game. Any suggestions?
This is the code
REM *****************************************
` *** TITLE - My Space Game
` *** VERSION - 1.0.0 LAST UPDATED - 10.5.2009
` *** DEVELOPER - Andrew Murphy
` *** DATE CREATED - 9.22.2009
` ***
REM *** START SYSTEM SETUP SECTION
sync on
sync rate 60
autocam off
randomize timer()
hide mouse
backdrop off
MainSection:
rem Load Music
load sound "sounds/background music cypress hill instrumental.wav",1 : set sound volume 1,100
rem Load Images
load image "images/space.jpg",1
load image "images/explosion.jpg",2
load image "images/earth.jpg",3
load image "models/blackbird texture.bmp",4
load image "images/asteroid.jpg",5
rem Set Variables
Mytimer = 5000
MySpeed = 20
fuel = 500
set camera range 20,1000000
rem Actual Main Character : Model of a spaceship
load object "models/blackbird.x",1
rotate object 1,0,260,90
fix object pivot 1
position object 1,0,30,300
color object 1,rgb(125,125,125)
fade object 1,200
set object collision on 1
set object collision to boxes 1
rem the Sun
make object sphere 2,1000
texture object 2,2
position object 2,10000,0,0
set object collision on 2
set object collision to spheres 2
rem the Earth
make object sphere 3,250
texture object 3,3
position object 3,2500,0,0
scale object 3,25,25,25
set object collision off 3
set object collision on 3
rem Background
make object sphere 4,-1000000
texture object 4,1
set object collision off 4
rem Wormhole/Blackhole
make object cone 5,10000
scale object 5,100,20,100
rotate object 5,180,0,0
color object 5,rgb(0,0,0)
fade object 5,50
position object 5,0,0,25000
set object collision on 5
make object cone 6,5000
scale object 6,100,50,100
rotate object 6,180,0,0
color object 6,rgb(0,0,0)
fade object 6,50
position object 6,0,-1250,25000
set object collision on 6
make object cone 7,2000
scale object 7,100,200,100
rotate object 7,180,0,0
color object 7,rgb(0,0,0)
fade object 7,50
position object 7,0,-3500,25000
set object collision on 7
make object cone 8,500
scale object 8,100,1000,100
rotate object 8,180,0,0
color object 8,rgb(0,0,0)
fade object 8,50
position object 8,0,-6750,25000
set object collision on 8
rem Asteroids
for a = 9 to 85
make object sphere a,500
texture object a,5
position object a,rnd(10000),rnd(10000),rnd(10000)
set object collision on a
set object collision to spheres a
next a
do
rem Background Music
rem Set Variables
opx# = object position x(1)
opy# = object position y(1)
opz# = object position z(1)
oax# = object angle x(3)
oay# = object angle y(3)
oaz# = object angle z(3)
oax5# = object angle x(5)
oay5# = object angle y(5)
oaz5# = object angle z(5)
oax6# = object angle x(6)
oay6# = object angle y(6)
oaz6# = object angle z(6)
oax7# = object angle x(7)
oay7# = object angle y(7)
oaz7# = object angle z(7)
rem Fuel Bar
set cursor 10,10
print "Fuel:",fuel/5
box 10,30,fuel*1.26,40
rem Controls
if upkey()=1 then pitch object down 1,1
if downkey()=1 then pitch object up 1,1
if leftkey()=1 then turn object left 1,1
if rightkey()=1 then turn object right 1,1
if spacekey()=1 then move object 1,MySpeed
if inkey$() = "a" then roll object left 1,1
if inkey$() = "d" then roll object right 1,1
if inkey$() = "s" then move object 1,0-MySpeed
rem Camera Settings
position camera object position x(1),object position y(1),object position z(1)
set camera to object orientation 1
pitch camera down 20
move camera -40
rem Lightspeed Settings
if fuel < 0 then fuel = 0
if fuel > 0
if inkey$() = "l"
ghost object on 4
dec fuel
move object 1,250
else
ghost object off 4
endif
endif
if fuel = 0
ghost object off 4
endif
rem Planetary Rotation
yrotate object 3,oay#+0.01 : rem Earth's rotation
move object 3,1
if oay# > 360 then oay# = 0
rem Asteroid Movement
for b = 9 to 20
move object b,100
next b
for c = 21 to 35
move object c,80
next c
for d = 36 to 49
move object d,50
next d
for e = 50 to 60
move object e,-60
next e
for f = 61 to 75
move object f,-80
next f
for g = 76 to 85
move object g,-100
next g
rem Blackhole Rotation
yrotate object 5,oay5#+5
if oay5# > 360 then oay5# = 0
yrotate object 6,oay6#+5
if oay6# > 360 then oay6# = 0
yrotate object 7,oay7#+5
if oay7# > 360 then oay7# = 0
yrotate object 8,oay8#+5
if oay8# > 360 then oay8# = 0
rem Blackhole Collision
for b = 5 to 8
if object collision(1,b) > 0
fuel = 0
position object 1,0,0,0
endif
next b
rem Collision
for coltest = 2 to 3
bang=object collision(1,coltest)
if bang
delete object 1
goto Endsection:
exit
rem this exits the loop as soon as there is collision
endif
next coltest
sync
loop
Endsection:
do
cls
for AllObjects = 1 to 100
if object exist(AllObjects)=1
delete object AllObjects
endif
next AllObjects
center text 320,240,"Game Over!!"
center text 320,260,"Play Again?"
center text 320,280,"Y or N?"
if inkey$() = "y" then goto MainSection:
if inkey$() = "n" then end
sync
loop
Any help is good
Candy = good!