Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Java Collision Trees (Stupidest project ever)

Featured Replies

[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

  • 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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.