Collision Detection

Not sure how to finish my code

Page 1 of 1

1 Replies - 1235 Views - Last Post: 02 November 2009 - 02:33 PM Rate Topic: -----

#1 Riz 01   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-August 09

Collision Detection

Posted 02 November 2009 - 12:44 PM

Hey everyone,

Im creating a puyo puyo game,
At the moment i seem to be stuck, im trying to implement collision detection by checking if a particular point(s) is being occupied by a puyo or not.

If it is when the next puyo tries to fit into that same position it wont be able to due to another puyo being there "collision". So far ive specified two locations on my board and if they are not equal to null then when a puyo falls within those two points i have a print statement which displays "it works".

But after this the other puyo(s) fall like in "Tetris" and from here i have no idea where to go.

How i would check this new puyo against the puyo that has already fallen and now resides at the bottom of the board, and have it stop on top of it?
I appreciate any help and advice that anyone can provide. Here is the code i have so far:

 // Check to see if the position located at p1 and p2 is holding a set of puyo's.
	public boolean positionEmpty()
		p1 = puyolist[0][11];
		  p2 = puyolist[1][11];
		  if((p1 != null) && (p2 != null)){
			   	System.out.println("it works");
			   return true;

This post has been edited by Riz 01: 02 November 2009 - 12:59 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Collision Detection

#2 modi123_1   User is online

  • Suitor #2
  • member icon

Reputation: 14094
  • View blog
  • Posts: 56,471
  • Joined: 12-June 08

Re: Collision Detection

Posted 02 November 2009 - 02:33 PM

Have a one-dimensional array to represent the "floor" of the screen. As 'gravity' pulls each object down check it's bottom plane against the appropriate column for a "depth check". If the bottom value is that value stop the fall and update the appropriate columns for the new depth. When a row is removed move the values down across the whole array.

Just one thought.

This post has been edited by modi123_1: 02 November 2009 - 02:33 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1