wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Collission detection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collission detection" Watch "Collission detection" New topic

Collission detection

Tomm Schuman

Joined: Mar 04, 2005
Posts: 11
I'm doing collission detection to my game.
I already have bounding boxes and the game checks if they intersects.
But my problem is how do i get the player stop when the boxes intersect.
I have been trying to do it without success.
The movement of the player goes like this.

Could someone help me?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You should probably use an if statement. In pseudocode, it would look something like this:

(Note: "x += dx" is a shortcut for "x = x + dx".)

I'll leave it to you to find out the exact syntax for an if statement as well as the logic for "player does not collide with another object".



Java API Documentation
The Java Tutorial
Tomm Schuman

Joined: Mar 04, 2005
Posts: 11
I still have the same problem i always had when the players collide they get stuck and can't move. The problem is that they can move from 0-8 pixels in one direction because i have 360� movement. It would be easier if it always was 1 pixel. Any suggestions about how i should change my code?

Here is my code
wood burning stoves
subject: Collission detection
Similar Threads
Alpha beta pruning with negamax
problem with program hanging
how can I get my game to pause in between rounds?
Help in connect four
Function not returning values.