Ok, it works now. But it's not perfect. There is a reason for that: The objects are kind of static. They move but never rotate. Here is my code för pulling and pushing:
function Pull()
rem Pick the right object
obj = pick object(sw / 2, sh / 2, 1, player - 1)
if obj = 0 then obj = pick object(sw / 2, sh / 2, player + 1, 300)
if objects( obj ) = 0 then exitfunction
rem Set the vector
set vector3 1, object position x( player ) - object position x( obj ), object position y( player ) - object position y( obj ), object position z( player ) - object position z( obj )
normalize vector3 1, 1
rem Create the force
rbg# = phy get rigid body mass( obj )
if rbm# > 41
m# = 777 * (rbm# - 40)
else
m# = 777
endif
rem Apply the force
phy add rigid body force obj, x vector3( 1 ) * m#, y vector3( 1 ) * m#, z vector3( 1 ) * m#, 3
endfunction
function Push()
rem Pick the right object
obj = pick object(sw / 2, sh / 2, 1, player - 1)
if obj = 0 then obj = pick object(sw / 2, sh / 2, player + 1, 300)
if objects( obj ) = 0 then exitfunction
rem Set the vector
set vector3 1, object position x( obj ) - object position x( player ), object position y( obj ) - object position y( player ), object position z( obj ) - object position z( player )
normalize vector3 1, 1
rem Create the force
rbg# = phy get rigid body mass( obj )
if rbm# > 41
m# = 777 * (rbm# - 40)
else
m# = 777
endif
rem Apply the force
phy add rigid body force obj, x vector3( 1 ) * m#, y vector3( 1 ) * m#, z vector3( 1 ) * m#, 3
endfunction
. But I don't think the problem is there. Here is the code that contains the Dark Physics commands:
rem init the physics engine
if physx() = 0
phy start
else
phy start 1, 0, 1
endif
phy set gravity 0, -179, 0
phy set static friction 0
phy set dynamic friction 0
player:
if spacekey() = 1
position object other( 0 ), rnd( 5 ) * 600 + 50, 60, rnd( 5 ) * 600 + 50
position object other( 1 ), rnd( 5 ) * 600 + 50, 60, rnd( 5 ) * 600 + 50
position object other( 2 ), rnd( 5 ) * 600 + 50, 60, rnd( 5 ) * 600 + 50
endif
text 1, 1, "Screen FPS: " + str$( screen fps() )
text 1, 21, "Pos x: " + str$( camera position x() )
text 1, 41, "Pos y: " + str$( camera position y() )
text 1, 61, "Pos z: " + str$( camera position z() )
rem Player rotation
xrotate camera camera angle x() + mousemovey() / 2.2
yrotate object player, object angle y( player ) + mousemovex() / 2.2 - 2 * leftkey() + 2 * rightkey()
if camera angle x() > 50
xrotate camera 50
else
if camera angle x() < -90 then xrotate camera -90
endif
rem Player movement
if keystate( 17 ) = 1
phy move character controller player, 215
else
if keystate( 31 ) = 1
phy move character controller player, -213
else
phy move character controller player, 0
endif
endif
rem Strafing
if keystate( 30 ) = 1
move object left player, 5
endif
if keystate( 32 ) = 1
move object right player, 5
endif
if mouseclick() = 1
Push()
else
if mouseclick() = 2
Pull()
endif
endif
rem Position and angle the camera
position camera object position x( player ), object position y( player ) + 20, object position z( player )
yrotate camera object angle y( player )
position mouse sw / 2, sh / 2
circle sw / 2, sh / 2, 3
rem Update the light position and angle
position light 1, object position x( player ), object position y( player ), object position z( player )
rotate light 1, camera angle x(), camera angle y(), 0
return
rem The materials
MakeMaterials:
rem Make the unbouncy material
phy make material 1, "Drondtindum"
phy set material restitution 1, 0
phy set material dynamic friction 1, 35
phy build material 1
rem Make the bouncy material
phy make material 2, "Thodnumdumdum"
phy set material restitution 2, 1
phy set material dynamic friction 2, 15
phy build material 2
return
LoadWorld:
color backdrop 0
rem Make the floor
make object box 1, 10000, 500, 10000
position object 1, 500, -275, 500
color object 1, rgb(255, 255, 255)
set object specular 1, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 1, 255
set object specular power 1, 255
phy make rigid body static box 1
rem Make the roof
make object box 2, 10000, 50, 10000
position object 2, 500, 1250, 500
color object 2, rgb(255, 255, 255)
set object specular 2, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 2, 255
set object specular power 2, 255
phy make rigid body static box 2
rem Make the walls
make object box 3, 7200, 5000, 50
position object 3, 3500, 1000, 0
color object 3, rgb(255, 255, 255)
set object specular 3, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 3, 255
set object specular power 3, 255
phy make rigid body static box 3
make object box 4, 7200, 5000, 50
position object 4, 3500, 1000, 3500
color object 4, rgb(255, 255, 255)
set object specular 4, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 4, 255
set object specular power 4, 255
phy make rigid body static box 4
make object box 5, 50, 5000, 7200
position object 5, 0, 1000, 3500
color object 5, rgb(255, 255, 255)
set object specular 5, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 5, 255
set object specular power 5, 255
phy make rigid body static box 5
make object box 6, 50, 5000, 7200
position object 6, 3500, 1000, 3500
color object 6, rgb(255, 255, 255)
set object specular 6, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 6, 255
set object specular power 6, 255
phy make rigid body static box 6
MakeMaze()
FillMaze()
rem Make the light
make light 1
color light 1, rgb(255, 255, 255)
set light range 1, 1750
rem Make the player
player = GetNewObjectNumber()
make object box player, 20, 55, 20
position object player, rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
phy make box character controller player, rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50, 20, 45, 20, 1, 40, 50
dim other( 2 ) as integer
other( 0 ) = GetNewObjectNumber()
make object box other( 0 ), 20, 55, 20
position object other( 0 ), rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
other( 1 ) = GetNewObjectNumber()
make object box other( 1 ), 20, 55, 20
position object other( 1 ), rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
other( 2 ) = GetNewObjectNumber()
make object box other( 2 ), 20, 55, 20
position object other( 2 ), rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
return
phy end
flush video memory
end
function Pull()
rem Pick the right object
obj = pick object(sw / 2, sh / 2, 1, player - 1)
if obj = 0 then obj = pick object(sw / 2, sh / 2, player + 1, 300)
if objects( obj ) = 0 then exitfunction
rem Set the vector
set vector3 1, object position x( player ) - object position x( obj ), object position y( player ) - object position y( obj ), object position z( player ) - object position z( obj )
normalize vector3 1, 1
rem Create the force
rbg# = phy get rigid body mass( obj )
if rbm# > 41
m# = 777 * (rbm# - 40)
else
m# = 777
endif
rem Apply the force
phy add rigid body force obj, x vector3( 1 ) * m#, y vector3( 1 ) * m#, z vector3( 1 ) * m#, 3
endfunction
function Push()
rem Pick the right object
obj = pick object(sw / 2, sh / 2, 1, player - 1)
if obj = 0 then obj = pick object(sw / 2, sh / 2, player + 1, 300)
if objects( obj ) = 0 then exitfunction
rem Set the vector
set vector3 1, object position x( obj ) - object position x( player ), object position y( obj ) - object position y( player ), object position z( obj ) - object position z( player )
normalize vector3 1, 1
rem Create the force
rbg# = phy get rigid body mass( obj )
if rbm# > 41
m# = 777 * (rbm# - 40)
else
m# = 777
endif
rem Apply the force
phy add rigid body force obj, x vector3( 1 ) * m#, y vector3( 1 ) * m#, z vector3( 1 ) * m#, 3
endfunction
rem Create the environment
function MakeMaze()
rem Create the array
dim world(55, 55) as boolean
rem Loop through the "maze", and create it
for x = 0 to 5
for y = 0 to 5
if world(x, y) = 0
wall = rnd( 1000 )
height = rnd( 5 ) + 1
obj = GetNewObjectNumber()
rem Which sort of wall?
if wall <= 500
make object box obj, 250, 50 + 250 * height, 250
position object obj, 750 * x, 0, 750 * y
else
if wall > 500 and wall <= 750
t = rnd( 1000 )
if t < 500
make object box obj, 500, 50 + 250 * height, 250
position object obj, 700 * x + 25, 0, 700 * y
world(x + 1, y) = 1
world(x + 2, y) = 1
else
make object box obj, 250, 50 + 250 * height, 500
position object obj, 750 * x, 0, 750 * y + 25
world(x, y + 1) = 1
world(x, y + 2) = 1
endif
else
if wall > 750
t = rnd( 1000 )
if t < 500
make object box obj, 1000, 50 + 250 * height, 125
position object obj, 750 * x + 35, 0, 750 * y
world(x + 1, y) = 1
world(x + 2, y) = 1
world(x + 3, y) = 1
world(x + 4, y) = 1
world(x + 5, y) = 1
else
make object box obj, 250, 50 + 250 * height, 1000
position object obj, 750 * x, 0, 750 * y + 35
world(x, y + 1) = 1
world(x, y + 2) = 1
world(x, y + 3) = 1
world(x, y + 4) = 1
world(x, y + 5) = 1
endif
endif
endif
endif
rem The color
color object obj, rgb(255, 100, 50)
set object specular obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient obj, 100
set object specular power obj, 155
world(x, y) = 1
phy make rigid body static box obj
endif
next y
next x
undim world()
endfunction
function FillMaze()
rem Make the array
dim objects( 100 ) as integer
rem Fill the maze with 30 boxes
for x = 0 to 29
obj = GetNewObjectNumber()
sizeX = 25 + rnd( 120 )
sizeY = 25 + rnd( 120 )
sizeZ = 25 + rnd( 120 )
make object box obj, sizeX, sizeY, sizeZ
position object obj, rnd( 3550 ) + 100, 1000, rnd( 3550 ) + 100
rem The color
color object obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object specular obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient obj, 255
set object specular power obj, 255
rem Bring the object into the world of Dark Physics
phy make rigid body dynamic box obj, 1
phy set rigid body mass obj, sizeX / 5 + sizeY / 5 + sizeZ / 5
phy set rigid body linear velocity obj, rnd( 20 ) - 10, -1 - rnd( 10 ), rnd( 20 ) - 10
objects( obj ) = obj
next x
rem Fill the maze with 20 spheres
for x = 0 to 19
obj = GetNewObjectNumber()
radius = 40 + rnd( 120 )
make object sphere obj, radius
position object obj, rnd( 3550 ) + 100, 1000, rnd( 3550 ) + 100
rem The color
color object obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object specular obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient obj, 255
set object specular power obj, 255
rem Bring the object into the world of Dark Physics
phy make rigid body dynamic sphere obj, 2
phy set rigid body mass obj, (1.2453 * radius) / 2
phy set rigid body linear velocity obj, rnd( 480 ) - 240, -1 - rnd( 10 ), rnd( 480 ) - 240
objects( obj ) = obj
next x
endfunction
. I wonder if you can see why they don't rotate. Please help me.
EDIT:
Here is the entire source, in case you would need it:
REM Project: The Arena
REM Created: 2007-04-12 19:10:16
REM
REM ***** Main Source File *****
REM
set display mode 1024, 768, 32
sync on : sync rate 90
backdrop on
autocam off
randomize timer()
rem The globals
global sw as integer
global sh as integer
global player as integer
rem The locals
local menu as boolean
rem Screen width and height
sw = screen width()
sh = screen height()
rem init the physics engine
if physx() = 0
phy start
else
phy start 1, 0, 1
endif
phy set gravity 0, -179, 0
phy set static friction 0
phy set dynamic friction 0
rem Load the world
gosub MakeMaterials
gosub LoadMenu
ink rgb( 255, 255, 0 ), 0
null = make vector3( 1 )
repeat
if menu = 1
gosub theMenu
else
rem Receive multiplayer data
while TGetMessage()
RNetwork()
endwhile
rem The player
gosub player
if object in screen( other( 0 ) ) then text object screen x( other( 0 ) ), object screen y( other( 0 ) ), "1"
if object in screen( other( 1 ) ) then text object screen x( other( 1 ) ), object screen y( other( 1 ) ), "2"
if object in screen( other( 2 ) ) then text object screen x( other( 2 ) ), object screen y( other( 2 ) ), "3"
endif
phy update
sync
rem Send multiplayer data
if TConnected() = 1 then gosub network
until keystate( 14 ) = 1
theMenu:
rem Select the correct option
select Options()
case 1
endcase
case 2
menu = 0
Dispose()
gosub LoadWorld
Connect( "blatt", "Deathmatch", "User32", 7)
endcase
case 3
endcase
endselect
return
player:
if spacekey() = 1
position object other( 0 ), rnd( 5 ) * 600 + 50, 60, rnd( 5 ) * 600 + 50
position object other( 1 ), rnd( 5 ) * 600 + 50, 60, rnd( 5 ) * 600 + 50
position object other( 2 ), rnd( 5 ) * 600 + 50, 60, rnd( 5 ) * 600 + 50
endif
text 1, 1, "Screen FPS: " + str$( screen fps() )
text 1, 21, "Pos x: " + str$( camera position x() )
text 1, 41, "Pos y: " + str$( camera position y() )
text 1, 61, "Pos z: " + str$( camera position z() )
rem Player rotation
xrotate camera camera angle x() + mousemovey() / 2.2
yrotate object player, object angle y( player ) + mousemovex() / 2.2 - 2 * leftkey() + 2 * rightkey()
if camera angle x() > 50
xrotate camera 50
else
if camera angle x() < -90 then xrotate camera -90
endif
rem Player movement
if keystate( 17 ) = 1
phy move character controller player, 215
else
if keystate( 31 ) = 1
phy move character controller player, -213
else
phy move character controller player, 0
endif
endif
rem Strafing
if keystate( 30 ) = 1
move object left player, 5
endif
if keystate( 32 ) = 1
move object right player, 5
endif
if mouseclick() = 1
Push()
else
if mouseclick() = 2
Pull()
endif
endif
rem Position and angle the camera
position camera object position x( player ), object position y( player ) + 20, object position z( player )
yrotate camera object angle y( player )
position mouse sw / 2, sh / 2
circle sw / 2, sh / 2, 3
rem Update the light position and angle
position light 1, object position x( player ), object position y( player ), object position z( player )
rotate light 1, camera angle x(), camera angle y(), 0
return
network:
rem Send the data of the player
TPutFloat object position x( player )
TPutFloat object position y( player )
TPutFloat object position z( player )
TPutFloat object angle x( player )
TPutFloat object angle y( player )
rem Send the data of the objects
for n = 0 to 100
if objects( n ) > 0
TPutFloat object position x(objects( n ))
TPutFloat object position y(objects( n ))
TPutFloat object position z(objects( n ))
TPutFloat object angle x(objects( n ))
TPutFloat object angle y(objects( n ))
TPutFloat object angle z(objects( n ))
endif
next n
rem Send all data
TSendAll
TSync
return
LoadMenu:
rem Create the images
text 1, 1, "Join"
get image 1, 1, 1, 60, text height( "J" ) + 1
cls
text 1, 1, "Start"
get image 2, 1, 1, 60, text height( "S" ) + 1
cls
text 1, 1, "Options"
get image 3, 1, 1, 60, text height( "O" ) + 1
cls
text 1, 1, "End"
get image 4, 1, 1, 60, text height( "E" ) + 1
cls
rem Create the buttons
make object plain 1, 70, text height( "J" )
position object 1, -30, 50, 50
point object 1, 0, 30, 0
texture object 1, 1
scale object 1, 10, 10, 100
make object plain 2, 70, text height( "S" )
position object 2, -30, 40, 50
point object 2, 0, 30, 0
texture object 2, 2
scale object 2, 10, 10, 100
make object plain 3, 70, text height( "O" )
position object 3, -30, 30, 50
point object 3, 0, 30, 0
texture object 3, 3
scale object 3, 10, 10, 100
make object plain 4, 70, text height( "E" )
position object 4, -30, 20, 50
point object 4, 0, 30, 0
texture object 4, 4
scale object 4, 10, 10, 100
position camera 0, 30, 0
point camera 0, 30, 50
menu = 1
return
MakeMaterials:
rem Make the unbouncy material
phy make material 1, "Drondtindum"
phy set material restitution 1, 0
phy set material dynamic friction 1, 35
phy build material 1
rem Make the bouncy material
phy make material 2, "Thodnumdumdum"
phy set material restitution 2, 1
phy set material dynamic friction 2, 15
phy build material 2
return
LoadWorld:
color backdrop 0
rem Make the floor
make object box 1, 10000, 500, 10000
position object 1, 500, -275, 500
color object 1, rgb(255, 255, 255)
set object specular 1, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 1, 255
set object specular power 1, 255
phy make rigid body static box 1
rem Make the roof
make object box 2, 10000, 50, 10000
position object 2, 500, 1250, 500
color object 2, rgb(255, 255, 255)
set object specular 2, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 2, 255
set object specular power 2, 255
phy make rigid body static box 2
rem Make the walls
make object box 3, 7200, 5000, 50
position object 3, 3500, 1000, 0
color object 3, rgb(255, 255, 255)
set object specular 3, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 3, 255
set object specular power 3, 255
phy make rigid body static box 3
make object box 4, 7200, 5000, 50
position object 4, 3500, 1000, 3500
color object 4, rgb(255, 255, 255)
set object specular 4, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 4, 255
set object specular power 4, 255
phy make rigid body static box 4
make object box 5, 50, 5000, 7200
position object 5, 0, 1000, 3500
color object 5, rgb(255, 255, 255)
set object specular 5, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 5, 255
set object specular power 5, 255
phy make rigid body static box 5
make object box 6, 50, 5000, 7200
position object 6, 3500, 1000, 3500
color object 6, rgb(255, 255, 255)
set object specular 6, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient 6, 255
set object specular power 6, 255
phy make rigid body static box 6
MakeMaze()
FillMaze()
rem Make the light
make light 1
color light 1, rgb(255, 255, 255)
set light range 1, 1750
rem Make the player
player = GetNewObjectNumber()
make object box player, 20, 55, 20
position object player, rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
phy make box character controller player, rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50, 20, 45, 20, 1, 40, 50
dim other( 2 ) as integer
other( 0 ) = GetNewObjectNumber()
make object box other( 0 ), 20, 55, 20
position object other( 0 ), rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
other( 1 ) = GetNewObjectNumber()
make object box other( 1 ), 20, 55, 20
position object other( 1 ), rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
other( 2 ) = GetNewObjectNumber()
make object box other( 2 ), 20, 55, 20
position object other( 2 ), rnd( 5 ) * 700 + 50, 60, rnd( 5 ) * 700 + 50
return
phy end
flush video memory
end
function Pull()
rem Pick the right object
obj = pick object(sw / 2, sh / 2, 1, player - 1)
if obj = 0 then obj = pick object(sw / 2, sh / 2, player + 1, 300)
if objects( obj ) = 0 then exitfunction
rem Set the vector
set vector3 1, object position x( player ) - object position x( obj ), object position y( player ) - object position y( obj ), object position z( player ) - object position z( obj )
normalize vector3 1, 1
rem Create the force
rbg# = phy get rigid body mass( obj )
if rbm# > 41
m# = 777 * (rbm# - 40)
else
m# = 777
endif
rem Apply the force
phy add rigid body force obj, x vector3( 1 ) * m#, y vector3( 1 ) * m#, z vector3( 1 ) * m#, 3
endfunction
function Push()
rem Pick the right object
obj = pick object(sw / 2, sh / 2, 1, player - 1)
if obj = 0 then obj = pick object(sw / 2, sh / 2, player + 1, 300)
if objects( obj ) = 0 then exitfunction
rem Set the vector
set vector3 1, object position x( obj ) - object position x( player ), object position y( obj ) - object position y( player ), object position z( obj ) - object position z( player )
normalize vector3 1, 1
rem Create the force
rbg# = phy get rigid body mass( obj )
if rbm# > 41
m# = 777 * (rbm# - 40)
else
m# = 777
endif
rem Apply the force
phy add rigid body force obj, x vector3( 1 ) * m#, y vector3( 1 ) * m#, z vector3( 1 ) * m#, 3
endfunction
function GetNewObjectNumber()
newObj = 2
repeat : newObj = newObj + 1 : until object exist( newObj ) = 0
endfunction newObj
function MakeMaze()
rem Create the array
dim world(55, 55) as boolean
rem Loop through the "maze", and create it
for x = 0 to 5
for y = 0 to 5
if world(x, y) = 0
wall = rnd( 1000 )
height = rnd( 5 ) + 1
obj = GetNewObjectNumber()
rem Which sort of wall?
if wall <= 500
make object box obj, 250, 50 + 250 * height, 250
position object obj, 750 * x, 0, 750 * y
else
if wall > 500 and wall <= 750
t = rnd( 1000 )
if t < 500
make object box obj, 500, 50 + 250 * height, 250
position object obj, 700 * x + 25, 0, 700 * y
world(x + 1, y) = 1
world(x + 2, y) = 1
else
make object box obj, 250, 50 + 250 * height, 500
position object obj, 750 * x, 0, 750 * y + 25
world(x, y + 1) = 1
world(x, y + 2) = 1
endif
else
if wall > 750
t = rnd( 1000 )
if t < 500
make object box obj, 1000, 50 + 250 * height, 125
position object obj, 750 * x + 35, 0, 750 * y
world(x + 1, y) = 1
world(x + 2, y) = 1
world(x + 3, y) = 1
world(x + 4, y) = 1
world(x + 5, y) = 1
else
make object box obj, 250, 50 + 250 * height, 1000
position object obj, 750 * x, 0, 750 * y + 35
world(x, y + 1) = 1
world(x, y + 2) = 1
world(x, y + 3) = 1
world(x, y + 4) = 1
world(x, y + 5) = 1
endif
endif
endif
endif
rem The color
color object obj, rgb(255, 100, 50)
set object specular obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient obj, 100
set object specular power obj, 155
world(x, y) = 1
phy make rigid body static box obj
endif
next y
next x
undim world()
endfunction
function FillMaze()
rem Make the array
dim objects( 100 ) as integer
rem Fill the maze with 30 boxes
for x = 0 to 29
obj = GetNewObjectNumber()
sizeX = 25 + rnd( 120 )
sizeY = 25 + rnd( 120 )
sizeZ = 25 + rnd( 120 )
make object box obj, sizeX, sizeY, sizeZ
position object obj, rnd( 3550 ) + 100, 1000, rnd( 3550 ) + 100
rem The color
color object obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object specular obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient obj, 255
set object specular power obj, 255
rem Bring the object into the world of Dark Physics
phy make rigid body dynamic box obj, 1
phy set rigid body mass obj, sizeX / 5 + sizeY / 5 + sizeZ / 5
phy set rigid body linear velocity obj, rnd( 20 ) - 10, -1 - rnd( 10 ), rnd( 20 ) - 10
objects( obj ) = obj
next x
rem Fill the maze with 20 spheres
for x = 0 to 19
obj = GetNewObjectNumber()
radius = 40 + rnd( 120 )
make object sphere obj, radius
position object obj, rnd( 3550 ) + 100, 1000, rnd( 3550 ) + 100
rem The color
color object obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object specular obj, rgb( rnd( 255 ), rnd( 255 ), rnd( 255 ) )
set object ambient obj, 255
set object specular power obj, 255
rem Bring the object into the world of Dark Physics
phy make rigid body dynamic sphere obj, 2
phy set rigid body mass obj, (1.2453 * radius) / 2
phy set rigid body linear velocity obj, rnd( 480 ) - 240, -1 - rnd( 10 ), rnd( 480 ) - 240
objects( obj ) = obj
next x
endfunction
remstart
function StrafeLeft( player as integer )
x# as float
x# = object angle x( player )
xrotate object player, 0
yrotate object player, object angle y( player ) + 90
move object player, 5
yrotate object player, object angle y( player ) - 90
xrotate object player, x#
endfunction
function StrafeRight()
x# as float
x# = object angle x( player )
xrotate object player, 0
yrotate object player, object angle y( player ) + 90
move object player, 5
yrotate object player, object angle y( player ) - 90
xrotate object player, x#
endfunction
remend
function distance(obj as integer, x as integer, y as integer, z as integer)
dist = sqrt( abs( object position x( obj ) - x ) ^ 2 + abs( object position y( obj ) - y ) ^ 2 + abs( object position z( obj ) - z ) ^ 2 )
endfunction dist
function Options()
option as byte
obj = pick object( mousex(), mousey(), 1, 4 )
if obj = 1
yrotate object 1, 110
if mouseclick() = 1 then option = 1
else
point object 1, 0, 50, 0
if obj = 2
yrotate object 2, 110
if mouseclick() = 1 then option = 2
else
point object 2, 0, 40, 0
if obj = 3
yrotate object 3, 110
if mouseclick() = 1 then option = 3
else
point object 3, 0, 30, 0
if obj = 4
yrotate object 4, 110
if mouseclick() = 1 then end
else
point object 4, 0, 20, 0
endif
endif
endif
endif
endfunction option
function Dispose()
for n = 1 to 500
if object exist( n ) then delete object n
next n
endfunction
function Connect(gname as string, gtype as string, user as string, timeL as integer)
THost "0.0.0.0", 4, user
TRegisterGame gname, gtype, "Random maze", timeL * 60000
endfunction
function RNetwork()
rem Get the sender
sender = TGetSender()
posX# = TGetFloat()
posY# = TGetFloat()
posZ# = TGetFloat()
ax# = TGetFloat()
ay# = TGetFloat()
rem Position the sender
position object other( sender - 1 ), posX#, posY#, posZ#
rotate object other( sender - 1 ), ax#, ay#, 0
rem Get the new positions of the objects
for n = 0 to 100
if objects( n ) > 0
ox# = TGetFloat()
oy# = TGetFloat()
oz# = TGetFloat()
oax# = TGetFloat()
oay# = TGetFloat()
oaz# = TGetFloat()
phy set rigid body position objects( n ), ox#, oy#, oz#
phy set rigid body rotation objects( n ), oax#, oay#, oaz#
endif
next n
endfunction