School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,130 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,020 people online right now. Registration is fast and FREE... Join Now!




Collision Detection

 

Collision Detection, Not sure how to finish my code

Riz 01

2 Nov, 2009 - 11:44 AM
Post #1

New D.I.C Head
*

Joined: 27 Aug, 2009
Posts: 24

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:

CODE
// 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: 2 Nov, 2009 - 11:59 AM

User is offlineProfile CardPM
+Quote Post


modi123_1

RE: Collision Detection

2 Nov, 2009 - 01:33 PM
Post #2

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,839



Thanked: 80 times
Dream Kudos: 150
My Contributions
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: 2 Nov, 2009 - 01:33 PM
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 02:34PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month