If you remove the roof code from mine and just use the ground and wall it should work. I'll do a test code later But I have gotta sleep now. It should work. When wallhit = 1 you are hitting the wall/main level. When groundhit = 1 you are hitting the ground.
Make sure and change the
wall =
ground =
to be your object numbers.
I just seen you are using NGC 3.01

I haven't tested it with that yet as I went back to 2.03, 3.01 is wicked buggy. I'll try and do a small example code before I go to work. Can't make any promises though ... 999 out of 1000 I'm late for work
[edit] I think 3.01 can do poly to poly collision but it is left out of the wrapper for now as I think it too may be bugged. Hopefully they will come out of hiding and fix these problems soon.
[edit2] I know I will be running late so here is a modified example from the NGC examples. It is the multi_ellip example modified. The left ellip is the wall and the right is the ground.
rem Program: Nuclear Glory Collision
rem Version: 3.01 Final Release
rem Copyright: Nuclear Glory Enterprises - 2004
rem Website: http://www.nuclearglory.com
rem Author: Matthew DeWalt
rem Instructions: Make sure the include file "NGCollision.dba" is
rem linked on the DBPro IDE. To do this, first make sure your
rem Project Manager is open. (View->Show Project Manager)
rem Click on the "Files" button on the bottom left of the project manager.
rem Click on the "browse" button near the top of the project manager
rem Surf to the "NGCollision.dba" file, select it, and click "Open"
rem Now you should be all set.
Rem ***** Main Source File *****
Rem These are collision definitions to make the code easier to read.
Rem For simplicity reasons, I suggest you leave these as they are,
rem as when we release updates we may ask you to change this block to reflect
rem the changes we made.
rem SOME globals to make (SetCollisions) and ray-cast
rem statements easier to read
#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
rem End globals
rem
rem Startup settings
rem
rem sets our display mode
Set Window On
SET DISPLAY MODE 800, 600, 16
rem sync on
sync on : sync rate 60 : Autocam off
hide mouse
rem
rem Scene settings
rem
rem Starts the collision system, this MUST be called before you can call any other
rem collision commands
StartCollisionPRO(000000000,000000000,000000000)
rem This line puts the collision system in Debug mode. If there is an error
rem (like you try to set an object that doesn't exist) this will make a box
rem popup notifying you of the error. If you take this line out, the system
rem will do its best to silently stop any errors that occur. (without crashing
rem your program) It's recommended that you leave this line in while you're
rem developing the application, then take it out before you make the final release
StartCollisionDebugPRO()
rem The collision type ID of our collision object
#Constant TYPE_SPHERE = 10
rem A collision definition for sphere to sphere collision
SetCollisionsPro( TYPE_SPHERE, TYPE_SPHERE, ELLIP_2_ELLIP, RESP_SLIDE, DYN_NO_RESP, 0 )
rem *** Begin some world setup stuff
rem turns on the backdrop
backdrop on
rem defines some global variables
global camera=0
global sphere1=100, sphere2=101, sphere3=102
rem Global array to hold the "hold status" of each key pressed
global dim KeyHold(256)
rem Global array to hold the "hold status" of each key pressed
global dim LastKeyHold(256)
rem creates our camera and inits the properties
Set Camera Range 4, 15000
color backdrop camera, rgb(0,0,255)
rem Put the camera up in the sky a bit
position camera camera, 0, 20, 0
rem Point the camera dwon toward the ground
rotate camera camera, 90, 0, 0
rem Create some spheres
make object sphere sphere1, 2
make object sphere sphere2, 2
make object sphere sphere3, 2
rem position the 3rd sphere to the side
position object sphere3, 2, 0, 0
rem Color the spheres red
color object sphere1,rgb(255,0,0)
color object sphere2,rgb(255,0,0)
color object sphere3,rgb(255,0,0)
rem OKAY, collision system back at work here. This is the command you use to
rem stick objects with a "collision type ID" This ID would be you own defined
rem TYPE_ID from above. This line simply says:
rem Give the object (sphere) the "collision type ID" of (TYPE_SPHERE)
CollisionTypePRO( sphere1, TYPE_SPHERE )
Rem Set the proper radius settings for the ellip
SetObjRadiusPRO( sphere1, 4, 1, 1 )
rem Do the same thing for the 2nd sphere
CollisionTypePRO( sphere2, TYPE_SPHERE )
Rem Set the proper radius settings for the ellip
SetObjRadiusPRO( sphere2, 4, 1, 1 )
rem Do the same thing for the 3rd sphere
CollisionTypePRO( sphere3, TYPE_SPHERE )
Rem Set the proper radius settings for the ellip
SetObjRadiusPRO( sphere3, 4, 1, 1 )
Rem Bend the spheres into ellips
scale object sphere1, 400, 100, 100
scale object sphere2, 400, 100, 100
scale object sphere3, 400, 100, 100
rem Okay, we're going to store which mdoe the spheres are in now (moving up or moving down)
sphereMode1 = 1
sphereMode2 = 0
Rem Create a ticker for the 3rd sphere
ticker = 0
do
`assign variables to your objct numbers (I just used 1,2,3, as I don't know what you use)
rem Get number of collisions for object
collCount = CountCollisionsPRO( sphere1 )
`set hit vars to 0 before testing each time
wallhit = 0
groundhit = 0
rem goes through each collision
for t=1 to collCount
rem Gets the object that was hit
hitObj = CollisionHitObj( sphere1, t )
`save collisions
if hitObj = sphere2 then wallhit = 1
if hitObj = sphere3 then groundhit = 1
next t
rem Get the sphere positions
xpos# = 1.0 + ((object position x(sphere1) - 1.0) / 1.1)
ypos# = object position y(sphere1)
zpos# = object position z(sphere1)
rem Handle moving one sphere
if sphereMode1 = 1
if object position z(sphere1) > 10
sphereMode1 = 0
else
position object sphere1, xpos#, ypos#, zpos#+0.2
endif
endif
if sphereMode1 = 0
if object position z(sphere1) < -10
sphereMode1 = 1
else
position object sphere1, xpos#, ypos#, zpos#-0.2
endif
endif
rem Handle moving the second sphere
rem handle the ticker
ticker = ticker + 1
rem Get the data of the second sphere/ellip
xpos# = object position x(sphere3)
ypos# = object position y(sphere3)
zpos# = object position z(sphere3) / 1.01
rem Handle the ticker some more
if ticker>380 then ticker=0
rem handle x postition of second sphere/ellip
if ticker < 160
xpos# = xpos# + 0.05
else
xpos# = xpos# - 0.05
endif
rem position the sphere/ellip
position object sphere3, xpos#, ypos#, zpos#
rem And here's the best line! This commands runs the entire collision system
rem and updates all of your objects for you. Easy enough?
RunCollisionPRO()
rem Setup our notice
set cursor 0,0
print "Watch the ellipsoids collide..."
set cursor 0,20
print "Wallhit : ",wallhit
set cursor 0,40
print "groundhit : ",groundhit
rem Draw the screen
sync
loop
``***********
```**** INPUT FUNCTIONS ********
``***********
rem Checks keys down to notify us if a key is being held
function UpdateKeyHold()
for t=0 to 256
LastKeyHold(t) = KeyHold(t)
next t
for t=0 to 256
KeyHold(t) = Keystate(t)
next t
endfunction
rem Checks if a Key has been hit
function KeyHit(t)
retval=0
if not LastKeyHold(t)
if KeyHold(t)
retval=1
endif
endif
endfunction retval
