Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 17 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


regenschauer

Member Since 10 Feb 2013
Offline Last Active Feb 10 2013 11:45 AM

Topics I've Started

Collision Correction

10 February 2013 - 11:48 AM

Dear Community; I have a Problem with the Correction after a Collision in a Platformer I try to create. I have tried many things and all have magically failed. Now, I turn to you, as I feel like I might need some external help with the Problem.

 

I use Java and I have a Entity class, which has a function called collide with a list of other Game Objects. If I find a Collision, I add it to an Array of colliding objects. Now, I would need to work out how to move the this object out all those collisions.

 

My coordinate System is also oriented with the y axis pointing downwards, meaning the bigger the y value, the lower the object on the screen.

 

Objects are represented like this:

 

J4DoyTo.png

And the Objects I collide are determined like this.

	public void collide(ArrayList<Entity> objectsToCollide){
		ArrayList<Entity> CorrectionEntities = new ArrayList<Entity>();
		
		for(int i = 0; i < objectsToCollide.size(); i++){
			Entity currentCollisionObject = objectsToCollide.get(i);
			if(currentCollisionObject == this)
				continue;
			if(Entity.entityBoxesIntersect(this, currentCollisionObject)){
				CorrectionEntities.add(currentCollisionObject);
			}
		}
		
		if(CorrectionEntities.size() == 0)
			return;
		
		for(int i = 0; i < CorrectionEntities.size(); i++){
			//TODO: Correct Position
			
			
		}
	}

 

Now the correction is supposed to happenn at the TODO marking, I put it there, as the other trials have failed horribly.

 

Thank you very much for your help,

 

regenschauer


PARTNERS