Jump to content

Java Collision Trees (Stupidest project ever)


Recommended Posts

[sorry can you move my post to programming....apologies]

Hi Guys,

I'm working on a stupid uni project which I am totally stuck on and I've been going over and over and now I've got to the point where I've basically got to hand it in and I really need some help.

Basically I've got to make a ball bounce around off some fixed walls and we HAVE to use collision trees. (I mean don't even get me started on how stupid that is) The ball has to move at a constant speed, bounce off the walls and then keep moving post-collision

All I can do is get the ball to move.....thats it.

I'd be really grateful for ANY help you can give me, can't find this ANYWHERE and you guys have always been so good helping me out in the past.......I just feel so dumb for not being able to do this

Here's what I got so far:

for(int i = 0; i <=3; i++)

{

if(ballx >= rootNode.child.xstart && bally >= rootNode.child.ystart

&& ballx <= rootNode.child.xend && bally <= rootNode.child.yend)

{

System.out.println("ball found in sector"+rootNode.child.name);

}

if (rootNode.child.name=="A")

{

for(int a = 0; a <=3; a++){

if (ballx >= rootNode.child[0].child[a].xstart && bally >= rootNode.child[0].child[a].ystart

&& ballx <= rootNode.child[0].child[a].xend && bally <= rootNode.child[0].child[a].yend)

{

System.out.println("ball found in sector"+rootNode.child[0].child[a].name);

}

}

}

else if(rootNode.child.name=="B")

{ for(int a = 0; a <=3; a++){

if (ballx >= rootNode.child[0].child[a].xstart && bally >= rootNode.child[0].child[a].ystart

&& ballx <= rootNode.child[0].child[a].xend && bally <= rootNode.child[0].child[a].yend)

{

System.out.println("ball found in sector"+rootNode.child[0].child[a].name);

}

}

}

}

I urgently and eagerly await your help!!!!! Thanks Becs

Edited by beccatigger
Link to comment
Share on other sites


  • 3 weeks later...

I created a javascript game once that had a few of these functions you require.

Leave a message if you want to take a look at the source, but remember is Jscript, not Java.

Edited by MMx
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...