Hi!
Im making a game and need some help.
I have a car and a level(Both in x format).
Now the collision won't work!
the car is just falling right trough the level.
Here's the code i use:
`Load the intro screen
load image "media/2D/intro.bmp",1
`Normal settings
sync on
sync rate 60
hide mouse
`The loading screen
set cursor 0,0
sync
sprite 1,50,50,1
sync : print "loading..." : sync
`Start the collision system
startcollisionsystem()
`Constants
#Constant NCULL_COUNTER_CLOCK 1
#Constant NCULL_CLOCK 2
#Constant NCULL_NONE 3
#Constant TYPE_NGC_ELLIP=1
#Constant TYPE_NGC_MESH=2
#Constant ELLIP_2_ELLIP=1
#Constant ELLIP_2_POLY=2
#Constant RESP_STICK=1
#Constant RESP_SLIDE=2
#Constant RESP_SLIDE_NO_SLOPES=3
#Constant RESP_SLIDE_NO_GRAV=4
#Constant RESP_SLIDE_NO_ACCEL=5
#Constant RESP_NONE=6
#Constant DYN_NO_RESP=1
#Constant DYN_RESP=2
#Constant DYN_RESP_NOTURN=3
`Declare my own variables
LevelOne = 1
PlayerObject = 2
`My own constants
#constant type_Level = LevelOne
#constant type_playerObj = PlayerObject
`Set the collision types
the_collision_types()
`**LOAD ALL MEDIA HERE**
gosub load_levels
gosub load_models
gosub load_sounds_music
load_levels:
`Load level one
load object "media/tracks/test track.x",LevelOne
collisiontypePRO( LevelOne, type_Level)
position object LevelOne,0,0,0
load_models:
load object "media/models/New Racer.x",PlayerObject
collisiontypePRO( PlayerObject, type_playerObj)
resetobjPRO( PlayerObject )
position object PlayerObject,0,90,0
scale object PlayerObject,1000,1000,1000
load_sounds_music:
`**NO SOUNDS/MUSIC YET**
`**BETA MENU**
menu:
sync
show sprite 1
set cursor 0,0
print "Start Game : 1"
print "Credits : 2"
print "Quit : 3"
if keystate(2) = 1
goto start_game
endif
if keystate(3) = 1
goto see_credits
endif
`If you press "3" then you will quit the program
if keystate(4)= 1
end
endif
goto menu
`**SEE CREDITS**
see_credits:
cls
print "Credits : "
print "Programmer : kasper"
print "Modeller : Kasper"
print "press any key to return"
wait key
goto menu
start_game:
sync
cls
delete sprite 1
`Some variables
speed_limit# = 50
player_speed# = 0
player_turn_speed# = 3
push_button = 0
rem set radius for player as it is being used as an ellip collision
SetObjRadiusPRO(PlayerObject,object size x(PlayerObject)/2,object size y(PlayerObject)/2,object size z(PlayerObject)/2)
`set object gravity
SetObjGravityPRO( PlayerObject, 3 )
do
push_button = 0
`Car control
if keystate(200) = 1
push_button = 1
player_speed# = player_speed#+1
move object PlayerObject,player_speed#
endif
if keystate(208) = 1
push_button = 1
player_speed# = player_speed#-1
move object PlayerObject,-player_speed#
endif
if keystate(203) = 1
turn object left PlayerObject,player_turn_speed#
endif
if keystate(205) = 1
turn object right PlayerObject,player_turn_speed#
endif
`If push_button = 0 make sure that the car will de-accelerate
if push_button = 0
player_speed# = player_speed#-1
endif
`If the player speed is less than 1 player speed will be = 0
if player_speed# < 1
player_speed# = 0
endif
`If player speed is less than 1 make the player turn speed = 0
if player_speed# < 1
player_turn_speed# = 0
endif
`If the player speed is bigger than 1 make the player turn speed = 1
if player_speed# > 1
player_turn_speed# = 3
endif
`If the player speed is over the current speed limit. Then make the player speed = 50
if player_speed# > speed_limit#
player_speed# = 50
endif
position camera 0,object position x(PlayerObject), object position y(PlayerObject)+50, object position z(PlayerObject)-80
set cursor 0,0
print "Current speed : "; player_speed#
print "Current speed limit : "; speed_limit#
print "FRAMES PER SECOND : "; screen fps()
`**START RUNNING THE COLLISION SYSTEM**
runcollisionPRO()
sync
loop
`Functions to be used in the game
function startcollisionsystem()
startcollisionPRO( 000000000,000000000,000000000 )
startcollisiondebugPRO()
setcollisionexclusive( 0 )
endfunction
`Use this function to set the collision types
`**NOTE: Remember to change the collision types if you use your own ones**
function the_collision_types()
SetCollisionsPRO(Type_PlayerObj, Type_Level, ELLIP_2_POLY, RESP_SLIDE, DYN_NO_RESP,Auto_Priority )
endfunction
If someone knows what's wrong then please help!
Thanks!
-The Nerd