Can someone help me with the code for my game I want to make a camera similar to the one in MarioKart but nothing works! I have tried set camera to follow but because the object is on a slope it doesn't work. Here is the code
rem variables
MySpeed=15
camdist#=15
trackangle=0
camsmooth=2000
Colflag=0
ReqCamHeight# = 10.0
cls 0 : backdrop on
rem images
Load image "E:\Carbonade\images\CarbonAde-wall.bmp",2
Load image "E:\Carbonade\images\CarbonAde-wall.bmp",3
Load image "E:\Carbonade\images\CarbonAde-wall.bmp",4
Load image "E:\Carbonade\images\CarbonAde-wall.bmp",5
load image "E:\Ore of World Textures\copper.jpg",8
load image "E:\Ore of World Textures\silver.jpg",9
load image "E:\Ore of World Textures\gold.jpg",10
load image "E:\Ore of World Textures\aluminum.jpg",11
load image "E:\Ore of World Textures\platinum.jpg",12
load image "E:\Ore of World Textures\titanium.jpg",13
load image "E:\Ore of World Textures\tin.jpg",14
rem 250
rem objects
rem Walls
make object cube 2000,50
position object 2000,-7258.2,-3215,83.7468
rem North Wall
make object box 2,14000,4000,10
rotate object 2,0,0,0
position object 2, 0,2000,7005
texture object 2,2
rem East Wall
make object box 3,14000,4000,10
rotate object 3,0,90,0
position object 3, 7005,2000,0
texture object 3,3
rem North Wall
make object box 4,14000,4000,10
rotate object 4,0,180,0
position object 4, 0,2000,-7005
texture object 4,4
rem West Wall
make object box 5,14000,4000,10
rotate object 5,0,270,0
position object 5, -7005,2000,0
texture object 5,5
set camera range 1,40000
G1X# = object position X(2000)
G1Y# = object position Y(2000)
G1Z# = object position Z(2000)
make object box 6,15000,1000,15000 : position object 6,0,-500,0 :
make object collision box 6,-15000,-500,-15000,15000,500,15000,0
texture object 6,6 : scale object texture 6,1,1
rotate object 6,0,0,25
make object cube 1,50
scale object 1,100,140,100
position object 1,0,100,0
make object collision box 1,-25,-25,-25,25,25,25,0
point object 1, G1X#,G1Y#,G1Z#
S = 250
firstOb = 7 : lastOb = 58
for f = firstOb to lastOb
make object sphere f,250
scale object f, 250, 125, 300
texture object f, 7
position object f,Rnd(13000)-5000,rnd(1000),Rnd(13000)-5000
next f
REM MOVE CAMERA rem 200
do
P1X# = object position X(1)
P1Y# = object position Y(1)
P1Z# = object position Z(1)
P1X# = object position X(1)
P1Y# = object position Y(1)
P1Z# = object position Z(1)
REM REFRESH SCREEN
A1X = object angle X(1)
A1Y = object angle Y(1)
A1Z = object angle Z(1)
REM CAMERA ORIENTATIONS
cpX# = camera position X()
cpY# = camera position Y()
cpZ# = camera position Z()
caX# = camera angle X()
caY# = camera angle Y()
caZ# = camera angle Z()
REM LIVE SCREEN DISPLAY
ink rgb(255,255,255),0 : set text size 16 : set text to bold : set text transparent
center text 320,420,"USE ARROW KEYS TO MOVE | PRESS SPACE BAR TO JUMP"
center text 320,440,"PRESS 'Q' TO QUIT"
set cursor 0,0
REM CONTROL INPUT
if KEYSTATE(17)=1 then move object 1,MySpeed
if KEYSTATE(31)=1 then move object 1,0-MySpeed
if KEYSTATE(30)=1 then A1Y = wrapvalue(A1Y-(MySpeed/3))
if KEYSTATE(32)=1 then A1Y = wrapvalue(A1Y+(MySpeed/3))
if upkey()=1 then position object 1,0,100,0
if spacekey()=1 then move object up 1,myspeed : Rem If the user hits the 'b' key, then move Object 1 down 5 units
if shiftkey()=1 then move object down 1,myspeed : Rem If the user hits the 'b' key, then move Object 1 down 5 units
Rem Gravity Effects
A1Y# = object angle Y(1) : rem Record the angle I'm facing
if MyAcceleration# = 0.0 : rem If I'm not moving up or down
EmptySpace = 0 : ObjectsChecked = 0 : rem Get ready to start checking collisions
for CheckObject =7 to 7 : rem Check the floor and every step object
if object collision(1,CheckObject)>0 : rem If I'm touching something
P1Y# = P1Y# - Gravity# : rem Look below me
position object 1, P1X#,P1Y#,P1Z# : rem Feel below me
if object collision(1,CheckObject) = 0 : rem If I feel only air
EmptySpace = EmptySpace + 1 : rem Mark up a free space
endif : rem I'm touching something, but it's not below me
P1Y# = P1Y# + Gravity# : rem Look up
position object 1, P1X#,P1Y#,P1Z# : rem Move back
else : rem If I'm not touching anything
EmptySpace = EmptySpace + 1 : rem rem Mark up a free space
endif
ObjectsChecked = ObjectsChecked + 1 : rem Done with that one!
next CheckObject : rem On to the next one!
if EmptySpace = ObjectsChecked : rem If I've checked all the objects and nothing is below me
MyAcceleration# = MyAcceleration# - Gravity# : rem Gravity begins to pull
endif
endif
if MyAcceleration# <> 0.0 : rem If I'm moving
P1Y# = P1Y# + MyAcceleration# : rem Find where I'm going
position object 1, P1X#,P1Y#,P1Z# : rem Put me there
EmptySpace = 0 : ObjectsChecked = 0 : rem Get ready to start checking collisions
for CheckObject = 7 to 7 : rem Check the floor and every step object
if object collision(1,CheckObject)>0 : rem If I hit an object
P1Y# = P1Y# - MyAcceleration# : rem Find where I was
position object 1, P1X#,P1Y#,P1Z# : rem Put me back
MyAcceleration# = 0.0 : rem Stop me from moving
else : rem If the space I'm going to is just air
EmptySpace = EmptySpace + 1 : rem rem Mark up a free space
endif
ObjectsChecked = ObjectsChecked + 1 : rem Done with that one!
next CheckObject : rem On to the next one!
if EmptySpace = ObjectsChecked : rem If I've checked all the objects and nothing is in my path
MyAcceleration# = MyAcceleration# - Gravity# : rem Gravity pulls more
endif
endif
Rem Gravity Effects
REM TRANSFORM OBJECTS
print "object x",P1X#
print "object y",P1Y#
print "object z",P1Z#
REM MOVE OBJECTS
Yrotate object 1,A1Y
REM CHECK FOR COLLISION
rem Now that I've moved, record the new position
P1Xcol# = object position X(1)
P1Zcol# = object position Z(1)
Rem Arena Collision - Keep the player inside the walls
if P1Xcol#<-6900 then P1Xcol#=-6900 : rem If I try to pass through the west wall, find the place I should stay
if P1Zcol#<-6900 then P1Zcol#=-6900 : rem If I try to pass through the south wall, find the place I should stay
if P1Xcol#>6900 then P1Xcol#=6900 : rem If I try to pass through the east wall, find the place I should stay
if P1Zcol#>6900 then P1Zcol#=6900 : rem If I try to pass through the north wall, find the place I should stay
camheight#=P1Y#+ReqCamHeight#
Rem Steps Collision
REM MOVE CAMERA rem 200
set camera to follow P1X#,P1Y#,P1Z#,WrapValue(Object Angle Y(1)+270),Camdist#,Camheight#,camsmooth,ColFlag
REM MOVE CAMERA rem 200
REM REFRESH SCREEN
if SecretScore=7
for x = 1 to 206 : rem Check all the game object
if object exist(x) = 1 then delete object x
next x
backdrop off
gosub EndSection5
endif
sync
loop
EndSection5:
cls 0
center text 320,200, "CONGRATS YOU COLLECTED ALL THE ORE"
center text 320,240, "WOULD YOU LIKE TO ADVANCE TO LEVEL 2 [Y/N]?"
delete object 3000
REM *** END SECTION LOOP
do
if scancode()=0 then exit
loop
do
REM CONTROL INPUT
if Inkey$()="y"
gosub MainSection2
endif
if Inkey$()="n"
cls : end
endif
REM REFRESH SCREEN
sync
loop
end