First of all, I'm not sure if DarkPhysics is the issue, but I couldn't come up with a better name
Now, for my problem. Ok, so I did Zaibatsu's Dodging Game Tutorial :
http://forum.thegamecreators.com/?m=forum_view&t=153346&b=7. And it all worked great (which is why I didn't just post this in that topic). Then I started experimenting with DarkPhysics and such, and getting fancy. Now, I have a problem.
What's supposed to happen in the game is, you control the ball moving it only left and right. Then, other balls are rolling towards you. You have to avoid the balls and let them roll past you. For every ball that hits you, you lose 20 health points (out of 100), and that ball moves to the starting point, only with a random x level (that is hopefully within the level
). If a ball rolls past you (or, to be more specific, if it's Z value is larger than 145), then the player gets 1 point and then the ball is supposed to jump back to the start with a random x value.
Well, everything works fine except for the jumping back part. Once they get past that point, they just disappear. I'm not really sure what's wrong, all I know is that all the code worked fine before I added DarkPhysics. Then, once I added DarkPhysics, everything worked except for, apparently, the position object command. Can you not use that command with a dynamic rigid body? If so, what can I use instead?
If that's not the problem, then I'm not sure what is. Here is all my source code (I tried my best to give informative remarks, especially since you won't easily be able to run it without removing or replacing the textures)-
REM Project: First Full 3D Game
REM Created: 12/9/2009 8:21:01 PM
REM
REM ***** Main Source File *****
REM
`various stuff
set window title "Dodging Game"
set display mode 1024,758,32
phy start
sync on
sync rate 60
hide mouse
autocam off
`turning on global shadows
set global shadows on
`loading rock textures for ground and enemy balls
load image "rock.png",4
load image "detail1.png",5
load image "rock2normal.png",6
`making floor
make object box 9999,75,5,200
`making the floor a rigid body ala (sp?) darkphysics
phy make rigid body static box 9999
`various texturing things for the floor
texture object 9999,5
SCALE OBJECT TEXTURE 9999, 8, 16
set bump mapping on 9999,6
set detail mapping on 9999,4
`making and positioning player
make object sphere 1,5
position object 1,0,5,95
yrotate object 1,180
`loading player textures
load image "pipe_metal.png",1
load image "detail1.png",2
load image "pipe_metalnormal.png",3
`texturing and etc... player
texture object 1,1
set detail mapping on 1,2
set bump mapping on 1,3
`making player a dynamic rigid body ala darkphysics
phy make rigid body dynamic sphere 1
`setting up player for collisions ala Sparky's Collision dll
SC_setupObject 1 , 1 , 1
`loading wall textures
load image "Mixed01Diffuse.tga",7
load image "Mixed01Height.tga",8
load image "Mixed01Normal.tga",9
`making left wall
make object box 800,8,32,200
position object 800,-39.5,5,0
`making left wall rigid body static box
phy make rigid body static box 800
`setting up left wall collisions ala Sparky's again. I probably don't need to do this, but I am anyways.
SC_setupObject 800 , 0 , 2
`making right wall
make object box 801,8,32,200
position object 801,39.5,5,0
`making right wall rigid body static box
phy make rigid body static box 801
`setting up right wall collisions ala Sparky's again. I probably don't need to do this, but I am anyways.
SC_setupObject 801 , 0 , 2
`texturing left wall
texture object 800,7
SCALE OBJECT TEXTURE 800, 16, 2
set bump mapping on 800,9
set detail mapping on 800,8
`texturing right wall
texture object 801,7
SCALE OBJECT TEXTURE 801, 16, 2
set bump mapping on 801,9
set detail mapping on 801,8
`making enemy ball 1
make object sphere 2,5
position object 2,rnd(37.5),5,-90
`making enemy ball 1 a rigid body dynamic sphere ala darkphysics
phy make rigid body dynamic sphere 2
`texturing enemy ball 1
texture object 2,4
SCALE OBJECT TEXTURE 2, 2, 2
set bump mapping on 2,6
set detail mapping on 2,5
`setting up collisions for enemy ball 1 ala sparky's collision dll
SC_setupObject 2 , 2 , 1
`making enemy ball 2
make object sphere 3,5
position object 3,rnd(37.5)*-1,5,-90
`making enemy ball 2 a rigid body dynamic sphere ala darkphysics
phy make rigid body dynamic sphere 3
`texturing enemy ball 2
texture object 3,4
SCALE OBJECT TEXTURE 3, 2, 2
set bump mapping on 3,6
set detail mapping on 3,5
`setting up collisions for enemy ball 2 ala sparky's collision dll
SC_setupObject 3 , 2 , 1
`making enemy ball 2
make object sphere 4,6
POSITION OBJECT 4,RND(20),5,-95
`making enemy ball 2 a rigid body dynamic sphere ala darkphysics
phy make rigid body dynamic sphere 4
`texturing enemy ball 2
texture object 4,4
SCALE OBJECT TEXTURE 4, 3, 3
set bump mapping on 4,6
set detail mapping on 4,5
`setting up collisions for enemy ball 1 ala sparky's collision dll
SC_setupObject 4 , 2 , 1
`making enemy ball 2
make object sphere 5,8
POSITION OBJECT 5,RND(20)*-1,5,-95
`making enemy ball 2 a rigid body dynamic sphere ala darkphysics
phy make rigid body dynamic sphere 5
`texturing enemy ball 2
texture object 5,4
SCALE OBJECT TEXTURE 5, 4, 4
set bump mapping on 5,6
set detail mapping on 5,5
`setting up collisions for enemy ball 2 ala sparky's collision dll
SC_setupObject 5 , 2 , 1
`making enemy ball 2
make object sphere 6,10
POSITION OBJECT 6,0,5,-95
`making enemy ball 2 a rigid body dynamic sphere ala darkphysics
phy make rigid body dynamic sphere 6
`texturing enemy ball 2
texture object 6,4
SCALE OBJECT TEXTURE 6, 5, 5
set bump mapping on 6,6
set detail mapping on 6,5
`setting up collisions for enemy ball 2 ala sparky's collision dll
SC_setupObject 6 , 2 , 1
`old collision code, I kept it here for reference
` for x=1 to 6
` set object collision on x
` set object collision to boxes x
` next x
`lighting stuff
set shadow light 0,100,100,100,1000
position light 0,100,100,100
set light range 0,1000
`shadow stuff
for x=1 to 6
set shadow shading on x,-1,200,1
next x
`setting up player health and score variables
PlyrHlth#=100
PlyrScr#=0
`main loop begin
do
`setting ink and text size
ink rgb(255,0,0),rgb(0,0,0)
set text size 50
`displaying player health
text 10,20,"Player Health : "+ STR$(PlyrHlth#)
`displaying player score - duh
text 10,60,"Player Score : "+ STR$(PlyScr#)
`camera stuff
position mouse screen width()/2,screen height()/2
position camera 0,10,110
point camera 0,10,95
`moving player left
if leftkey()=1 and object position x(1)<34.5
phy set rigid body linear velocity 1, 10, 0, 0
endif
`moving player right
if rightkey()=1 and object position x(1)>-34.5
`move object right 1,.2
phy set rigid body linear velocity 1, -10, 0, 0
endif
`moving enemy ball 1 down/south
phy set rigid body linear velocity 2, 0, 0, 38
`checking to see if enemy ball 1 is by the back/south end of the "level"
if object position z(2)>145
`positioning enemy ball 1 back to start (with a random x value hopefully within the "level")
position object 2,rnd(37.5),10,-90
`adding 1 point to player score
PlyrScr#=PlyrScr#+1
endif
`moving enemy ball 2 down/south
phy set rigid body linear velocity 3, 0, 0, 34
`checking to see if enemy ball 2 is by the back/south end of the "level"
if object position z(3)>145
`positioning enemy ball 2 back to start (with a random x value hopefully within the "level")
position object 3,rnd(37.5)*-1,10,-90
`adding 1 point to player score
PlyrScr#=PlyrScr#+1
endif
`moving enemy ball 3 down/south
phy set rigid body linear velocity 4, 0, 0, 30
`checking to see if enemy ball 3 is by the back/south end of the "level"
IF OBJECT POSITION Z(4)>145
`positioning enemy ball 3 back to start (with a random x value hopefully within the "level")
POSITION OBJECT 4,RND(25),10,-95
`adding 1 point to player score
PlyrScr#=PlyrScr#+1
ENDIF
`moving enemy ball 4 down/south
phy set rigid body linear velocity 5, 0, 0, 32
`checking to see if enemy ball 4 is by the back/south end of the "level"
IF OBJECT POSITION Z(5)>145
`positioning enemy ball 4 back to start (with a random x value hopefully within the "level")
POSITION OBJECT 5,RND(25)*-1,10,-95
`adding 1 point to player score
PlyrScr#=PlyrScr#+1
ENDIF
`moving enemy ball 5 down/south
phy set rigid body linear velocity 6, 0, 0, 35
`checking to see if enemy ball 5 is by the back/south end of the "level"
IF OBJECT POSITION Z(6)>145
`positioning enemy ball 5 back to start (with a random x value hopefully within the "level")
POSITION OBJECT 6,RND(3),10,-95
`adding 1 point to player score
PlyrScr#=PlyrScr#+1
ENDIF
`checking if player collides with enemy ball 1, ala Sparky's Collision DLL
if SC_objectCollision (1,2)=1
`positioning enemy ball 1 back to start (with a random x value hopefully within the "level")
position object 2,rnd(37.5),5,-90
`removing 20 points from the player's health
PlyrHlth#=PlyrHlth#-20
endif
`checking if player collides with enemy ball 2, ala Sparky's Collision DLL
if SC_objectCollision (1,3)=1
`positioning enemy ball 2 back to start (with a random x value hopefully within the "level")
position object 2,rnd(37.5),5,-90
`removing 20 points from the player's health
PlyrHlth#=PlyrHlth#-20
endif
`checking if player collides with enemy ball 3, ala Sparky's Collision DLL
if SC_objectCollision (1,4)=1
`positioning enemy ball 3 back to start (with a random x value hopefully within the "level")
position object 2,rnd(37.5),5,-90
`removing 20 points from the player's health
PlyrHlth#=PlyrHlth#-20
endif
`checking if player collides with enemy ball 4, ala Sparky's Collision DLL
if SC_objectCollision (1,5)=1
`positioning enemy ball 4 back to start (with a random x value hopefully within the "level")
position object 2,rnd(37.5),5,-90
`removing 20 points from the player's health
PlyrHlth#=PlyrHlth#-20
endif
`checking if player collides with enemy ball 5, ala Sparky's Collision DLL
if SC_objectCollision (1,6)=1
`positioning enemy ball 5 back to start (with a random x value hopefully within the "level")
position object 2,rnd(37.5),5,-90
`removing 20 points from the player's health
PlyrHlth#=PlyrHlth#-20
endif
`making sure player's health never goes below 0
if PlyrHlth#<0
PlyrHlth#=0
endif
`checking if player's health is equal to 0
if PlyrHlth#=0
`hiding player object
hide object 1
`moving player object out of the way
position object 1,0,object position y(1)-1,0
`displaying various game over stuff
text screen width()/2-100,screen height()/2,"GAME OVER!"
text screen width()/2-100,screen height()/2+40,"Your Score is : "+ STR$(PlyrScr#)
text screen width()/2-100,screen height()/2+80,"Press 'Escape' to exit"
endif
`darkphysics update
phy update
`sync
sync
`ending main loop
loop
Any help is much appreciated. Thanks for helping a DBPro n00b out!