Computer Science Canada collision detection in tetris |
Author: | omni [ Mon Mar 08, 2004 5:24 pm ] |
Post subject: | collision detection in tetris |
I got the rotation down pat, now I need some help on the collision detection. The current piece is stored as a 1..4*4 array of int . A '1' says that this place is taken up by a block and a 0 says its free. The board itself is also one huge one dimensional array 1..12*39 of int Note these aren't 2 dimensional arrays I want to keep them 1 dimensial. |
Author: | McKenzie [ Mon Mar 08, 2004 5:38 pm ] | ||
Post subject: | |||
Ouch. 2-Dim is the way to go. Ignoring that, you are obviously trying to compare your piece vs the board to find collisions. I assume that you are already restricting the piece so that it can't go off the edges. The check will look something like:
|
Author: | omni [ Mon Mar 08, 2004 6:20 pm ] |
Post subject: | |
if I were to change the 1 and 0's to boolean true and false, in order to compare the two I would have to use the boolean operators right? ex: OR XOR AND ? |
Author: | Tony [ Mon Mar 08, 2004 6:46 pm ] |
Post subject: | |
as oppose to not using and/or ? ![]() |
Author: | omni [ Mon Mar 08, 2004 7:34 pm ] |
Post subject: | |
what do you mean? |
Author: | Tony [ Mon Mar 08, 2004 7:39 pm ] |
Post subject: | |
ohh... I think i get what you mean by boolean operators... and you could use them... you can also use if = comparison. |
Author: | omni [ Mon Mar 08, 2004 8:02 pm ] |
Post subject: | |
ya thats what I was planning to do with them. using in if statement, but still having trouble |
Author: | McKenzie [ Tue Mar 09, 2004 8:35 am ] |
Post subject: | |
ya, you would use AND because you only care about the case where the collision occurs. |
Author: | omni [ Tue Mar 09, 2004 5:41 pm ] |
Post subject: | |
thanks sir, err.. McKenzie |
Author: | omni [ Tue Mar 09, 2004 8:45 pm ] |
Post subject: | |
here is my program so far, bugs are evident, but I just want to get some opinions and whether it is worth programming for the People. edit: has someone else previously made a tetris game like mine? Ctrl and ALT are to rotate and 'j' and 'l' to move left and right |
Author: | Paul [ Tue Mar 09, 2004 8:58 pm ] |
Post subject: | |
hm, a couple of bugs, the next piece appears in the x coordinate of where the last peice fell. When you turn it near the edge, it goes all wacky. The piece rotates funny (or does it?) oh, and I can turn it when there isn't space. |
Author: | omni [ Tue Mar 09, 2004 9:03 pm ] |
Post subject: | |
i've got the first few problems fixed, but the detection of whether the piece has enough room to rotate or not is going to be hard. Note: if I can get the bugs fixed, should there be a cooperative mode, or vs or both? |