Not a tame lion...
Join Date: May 2004
Location: Narnia
|
Here's a good one,
Does anyone know an algorithm to find the center of a tetris block ? I'm storing my blocks as x, y coordinates in multiples of 20, so the square looks like this: blockOneX = 0; blockOneY = 0; blockTwoX = 20; blockTwoY = 0; blockThreeX = 0; blockThreeY = 20; blockFourX = 20; blockFourY = 20; and the three way looks like this: blockOneX = 20; blockOneY = 0; blockTwoX = 0; blockTwoY = 20; blockThreeX = 20; blockThreeY = 20; blockFourX = 40; blockFourY = 20; Now, when I'm showing the next piece that the player will get, I want it to show up centered in a box on the side. The only problem is, I'm having trouble finding the center of the shape to make the correction when I draw it in my window (short of specifying the correction for each shape individually). So, anybody come across this before ? I'm going to work on some more mundane parts of the game in the meantime. |
quote |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
Maybe I'm not seeing something, but it looks as simple as this:
(0.5*(x_min+x_max),0.5*(y_min+y_max)) No? |
quote |
Not a tame lion...
Join Date: May 2004
Location: Narnia
|
Quote:
Thank you Brad, unfortunately I just got tasked with making dinner so I'll have to try it out in an hour or two. I'll most certainly let you know how it goes. Last edited by AsLan^ : 2005-11-17 at 05:19. Reason: I just dont like the :lol: |
|
quote |
Veteran Member
Join Date: Jun 2005
Location: State of Flux
|
Damn you Brad, you beat me to it, again.
|
quote |
Not a tame lion...
Join Date: May 2004
Location: Narnia
|
Howabout that, it mostly worked !
Seriously though, the lowest value in all cases was zero, so that didn't really do much to be added to the highest. I had to add twenty to each value, pick the highest one (with twenty added) and add half of that. I had to add the twenty to allow for odd block lengths to have an oddish offset. For example the square should have an offset of 20 but the three prong should have an offset of 30. Works great now, thank you gentlemen. |
quote |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
Aww, how nice.
I trust that you saw the video, though, and realized I was trying to make a funny. |
quote |
Not a tame lion...
Join Date: May 2004
Location: Narnia
|
Quote:
|
|
quote |
Posting Rules | Navigation |
|
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Windows Media center edition... I'm impressed | Wrao | General Discussion | 25 | 2005-08-15 12:07 |
Tetris on iPod leaks on Apple's own site? | VL-Tone | Speculation and Rumors | 16 | 2005-06-03 14:44 |
Reformat drive and change block size | alcimedes | General Discussion | 16 | 2004-07-04 15:56 |