Hi,
I just created this code based on the Binary Moons Tutorial for their game "Limit Rush". And so now I bring it to you for free of charge.
Rem Project: Object Collision Box Test
Rem Created: 10/17/2005 8:20:32 PM
Rem ***** Main Source File *****
sync on : sync rate 30
make object cube 1, 100 : show object bounds 1
make object collision box 1, -50,0,-50,50,50,50, 0
global startVar = 2 : global endVar = 2
for i = startVar TO endVar
make object cube i, 100
make object collision box i, -50,-50,-50,50,50,50, 0
position object i, rnd(1000)+200,0,rnd(1000)+200
objPosX# = object position x(i)
objPosY# = object position y(i)
objPosZ# = object position z(i)
show object bounds i
next i
do
controlObject(1,10)
objectCollision()
`text 0,0, str$(object collision(1,2))
point camera 0, object position x(1),object position y(1),object position z(1)
sync
loop
function objectCollision()
for i = startVar TO endVar
xPos#=object position x(i)
yPos#=object position y(i)
zPos#=object position z(i)
collision=object collision(i,0)
if collision > 0
`text 0,0, str$(collision)
xPos#=xPos#-(get object collision x()/2)
zPos#=zPos#-(get object collision z()/2)
endif
Position object i,xPos#,yPos#,zPos#
next i
endfunction
function controlObject(objNum,speed#)
if upkey()=1 THEN move object objNum,speed#
if downkey()=1 THEN move object objNum,speed# * -1
if rightkey()=1 THEN yrotate object objNum, object angle y(objNum)+speed# `turn object right objNum,3
if leftkey()=1 THEN yrotate object objNum, object angle y(objNum)-speed# `turn object left objNum,3
endfunction
It has no media and you control one square to push the other squares. Use the arrow keys for the controls. Just think of the possibilities for a real game if you added graphics! Bumper cars! Racing! Etc!
You all may thank me in turn.
www.fishbrosentertainment.com