Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / shape collision in tetris c++

Author
Message
shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 25th May 2012 03:56 Edited at: 25th May 2012 03:56
I am having a problem that the shapes go through other shapes. How can I fix that?



shy wolf productions
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 25th May 2012 04:53
Ok, so I'm looking at the move shape command. All it does is clear the last and then place the new blocks.

Every time you place a new block, you should check to see if it is hitting (on top of) another block. Then if it is, wait for the moving to done, and then move everything back. This will really only work with sprites(or at least it will only look good with sprites), but it is not hard to change you code to use sprites.


shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 25th May 2012 05:24
I am not sure how to that

shy wolf productions
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 25th May 2012 05:46
do you have an array that keeps track of where blocks are and are not currently?


shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 25th May 2012 05:56
All I have right now is: grid[20][10], but it isn't being used right now.

shy wolf productions
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 25th May 2012 06:14 Edited at: 25th May 2012 06:14
Hmm, couldn't you just run through all the blocks and check for another block with the same coordinates?


shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 25th May 2012 06:16
I am really confused on how to do that

shy wolf productions
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 2nd Jun 2012 04:28
Ok, you have a grid array. I assume this holds info on where stationary blocks are held. Then all you need to do is find check to see if the grid location that you are moving a block to in the move method already has a block in it. If it does, return a value that lets the program know that you need to reverse all movements when you finish the movements.


Login to post a reply

Server time is: 2024-05-06 03:09:37
Your offset time is: 2024-05-06 03:09:37