The error is because you are loading the same objects again with the same object numbers
Only load each object once, and just switch which object is being used
You need to set up your program differently and have all your subroutines and functions come AFTER your main loop
rem program structure...
rem initialize code goes here
rem main loop
rem 1 main loop - 1 sync, etc.
do
sync
loop
rem subroutine go here
change:
return
change2nd:
return
Try this code...but change the 4 load lines first!
Rem Project: Dark Basic Pro Project
Rem Created: Monday, March 07, 2011
Rem ***** Main Source File *****
sync on
sync rate 80
set text opaque
global which_car = 1
phy start
gosub build_car_1
gosub build_car_2
gosub make_ground
rem point to car 1
`position camera 1,-1,-11
`point camera 10,0,0
position camera 1,20,-40
point camera 10,0,0
do
if leftkey()
which_car = 1
endif
if rightkey()
which_car = 2
endif
point camera object position x(which_car),object position y(which_car),object position z(which_car)
set cursor 0,0
print "Pointing camera at car #";which_car
phy update
sync
loop
end
make_ground:
make object box 3,100,10,100
phy make rigid body static box 3
position object 3,-50,0,-50
return
rem - build vehicle 1
build_car_1:
`load object "C:/Documents and Settings/lee hough/Desktop/car select/media/beach.x", 1
`load image "C:/Documents and Settings/lee hough/Desktop/car select/media/beachBu2.TGA",1
Rem - rem out my 2 load lines below and use your own above!!!
load object "beach.x", 1
load image "beachBu2.TGA",1
position object 1, 0, 70, 0
scale object 1,100,100,100
texture object 1,1 : set blend mapping on 1,1,3,2,16
rem Create vehicle physics body
width# = 0.75
height# = 0.4
length# = 2.2
wheelX# = 1.1
wheelY# = 0.3
wheelZ# = 1.5
radius# = 0.6
wheelHeight# = 0.2
rem Be aware the vehicle width and length orientation
phy create vehicle 1
phy add vehicle body 1, length#, height#, width#, 0.0, height#, 0.0
phy add vehicle body 1, width#, height#, width#, 0.0, height#*2, 0.0
phy add vehicle wheel 1, 5, wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 0, 0
phy add vehicle wheel 1, 7, wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 0, 1
phy add vehicle wheel 1, 3, -wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 1, 0
phy add vehicle wheel 1, 9, -wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 1, 1
phy build vehicle 1
return
rem - build vehicle 2
build_car_2:
`load object "C:/Documents and Settings/lee hough/Desktop/car select/media/H-Police Car-Move.x", 2
`load image "C:/Documents and Settings/lee hough/Desktop/car select/media/policeCa.DDS",2
Rem - rem out my 2 load lines below and use your own above!!!
load object "beach.x", 2
load image "beachBu2.TGA",2
texture object 2,2 : set blend mapping on 2,1,3,2,16
position object 2, 5, 70, -5
scale object 2,100,100,100
rem Create vehicle physics body
width# = 0.75
height# = 0.4
length# = 2.2
wheelX# = 1.1
wheelY# = 0.3
wheelZ# = 1.5
radius# = 0.6
wheelHeight# = 0.2
rem Be aware the vehicle width and length orientation
phy create vehicle 2
phy add vehicle body 2, length#, height#, width#, 0.0, height#, 0.0
phy add vehicle body 2, width#, height#, width#, 0.0, height#*2, 0.0
phy add vehicle wheel 2, 4, wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 0, 0
phy add vehicle wheel 2, 2, wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 0, 1
phy add vehicle wheel 2, 5, -wheelZ#, wheelY#, -wheelX#, radius#, wheelHeight#, 1, 0
phy add vehicle wheel 2, 3, -wheelZ#, wheelY#, wheelX#, radius#, wheelHeight#, 1, 1
phy build vehicle 2
return