While I'm here I would also like to post this code. I am working on a simple football(soccer?) game (probably more like air hokey but not so fast and you can go over the half way line!). It's supposed to be a two player game on one computer. Just something simple to start with 3d. I have made the pitch, the ball and the players(though very simple and i'm going to something else with them at some point.)I have also enabled movement of the players-arrow keys and wasd.
Anyway I was wondering if any one could help with collision detection? I don't understand any of the collision detection stuff yet and I basically want to be able to push the ball around with the players. I would also like to put invisible walls around the edge of the pitch to stop the ball or the players going off into space. It would be good if the ball can still actually go hrough the goals though.
The code probably generally needs tidying up too.
Help would be really appreciated on this and please look at my previous posts too!(Nothing too complicated please though if poss!)
sync on
hide mouse
autocam off
backdrop on
ink rgb(0,255,0),0
box 0,0,60,100
ink rgb(255,255,255),0
line 0,0,59,0
line 59,0,59,99
line 59,99,0,99
line 1,99,0,0
line 15,0,15,20
line 15,20,45,20
line 45,20,45,0
circle 30,50,7
ink rgb(0,255,0),0
circle 30,50,6
ink rgb(255,255,255),0
line 0,50,60,50
line 15,100,15,80
line 15,80,45,80
line 45,80,45,100
get image 1,0,0,60,100
cls
color backdrop rgb(0,0,0)
make object plain 1,700,1000
rotate object 1,90,0,0
texture object 1,1
make object plain 2,5,150
position object 2,-100,0,-500
make object plain 3,5,150
position object 3,100,0,-500
make object plain 4,200,5
position object 4,0,75,-500
make object plain 5,5,150
position object 5,-100,0,500
make object plain 6,5,150
position object 6,100,0,500
make object plain 7,200,5
position object 7,0,75,500
make object sphere 8,30
position object 8,0,15,0
make object cylinder 9,50
position object 9,0,25,200
make object cylinder 10,50
position object 10,0,25,-200
position camera -550,550,0
point camera 0,0,0
make static collision box -300,0,-500,-300,0,500
set global collision on
set object collision on 8
set object collision on 9
set object collision on 10
set object collision on 2
set object collision on 3
set object collision on 5
set object collision on 6
sync
do
oldx=x
oldz=x
y=object position y(10)
z=object position z(10)
x=object position x(10)
y1=object position y(9)
z1=object position z(9)
x1=object position x(9)
if leftkey()=1 then z=z+5
if rightkey()=1 then z=z-5
if upkey()=1 then x=x+5
if downkey()=1 then x=x-5
if keystate(17)=1 then x1=x1+5
if keystate(31)=1 then x1=x1-5
if keystate(30)=1 then z1=z1+5
if keystate(32)=1 then z1=z1-5
if object collision(10,0)>0
x=oldx
z=oldz
endif
position object 10,x,y,z
position object 9,x1,y1,z1
sync
loop
Thanks guys.
Matt