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

Welcome to Dream.In.Code
Become an Expert!

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




Tetris Game

 

Tetris Game, How to mirror Tetris Blocks

Riz 01

14 Oct, 2009 - 11:37 AM
Post #1

New D.I.C Head
*

Joined: 27 Aug, 2009
Posts: 24

Hey guys im kinda new to C++ but im currently working on a tetris game i have everything working i drew all my graphics and such using SDL but i want to do something different as my tetris blocks fall from the top i want to have a mirror tetris piece up come from the bottom and they both meet at a half way point and stop and then the next block and mirror image fall and so on and so forth. Does anyone have any ideas on how i can implement this? I appreciate the help

User is offlineProfile CardPM
+Quote Post


SixOfEleven

RE: Tetris Game

14 Oct, 2009 - 03:22 PM
Post #2

lives.ToCode();
Group Icon

Joined: 18 Oct, 2008
Posts: 3,066



Thanked: 170 times
Dream Kudos: 775
Expert In: C, C#, XNA, Game Programming, Programming Concepts

My Contributions
In the mirror effect how did you want to control the blocks? For example, when the block is moving down you want the block moving up. However, when the player moves the block left do you want the mirrored block to move right? Sort of whatever the player does to the falling block you want the block moving up to do the reverse? Or when the player is moving the block horizontally do you want the block traveling up the screen to travel in the same direction?

Either way I don't think it would be all that hard. For example when a block it falling down the screen you set its initial position to say 0 and increment Y as it falls down the screen. For a block falling up the screen you would set its initial position to the screen height minus the height of the block and decrement Y to make it move up the screen. This is assuming that the when the block appears on the screen it is completely visible and doesn't start off the screen. If the block starts off the screen the initial position of a block falling down the screen would be 0 minus the height of the block and a block falling up the screen would start at the screen height plus the height of the block. To control how far down a block falls you would change the way you detect when a block hits the bottom of the screen. Instead of checking for the bottom of the screen you would be checking for half the height of the screen.

Horizontal movement wouldn't be that hard. If you want the block to move in the same direction as the block falling down the screen you would increment and decrement X in the same way. If you want the first scenario that I suggested all you would have to do is reverse it. When you increment X for the block falling down the screen you would decrement X for the block moving up the screen and do the reverse for decrementing X.

Hope that helps. smile.gif
User is offlineProfile CardPM
+Quote Post

Riz 01

RE: Tetris Game

14 Oct, 2009 - 05:34 PM
Post #3

New D.I.C Head
*

Joined: 27 Aug, 2009
Posts: 24

QUOTE(SixOfEleven @ 14 Oct, 2009 - 03:22 PM) *

In the mirror effect how did you want to control the blocks? For example, when the block is moving down you want the block moving up. However, when the player moves the block left do you want the mirrored block to move right? Sort of whatever the player does to the falling block you want the block moving up to do the reverse? Or when the player is moving the block horizontally do you want the block traveling up the screen to travel in the same direction?

Either way I don't think it would be all that hard. For example when a block it falling down the screen you set its initial position to say 0 and increment Y as it falls down the screen. For a block falling up the screen you would set its initial position to the screen height minus the height of the block and decrement Y to make it move up the screen. This is assuming that the when the block appears on the screen it is completely visible and doesn't start off the screen. If the block starts off the screen the initial position of a block falling down the screen would be 0 minus the height of the block and a block falling up the screen would start at the screen height plus the height of the block. To control how far down a block falls you would change the way you detect when a block hits the bottom of the screen. Instead of checking for the bottom of the screen you would be checking for half the height of the screen.

Horizontal movement wouldn't be that hard. If you want the block to move in the same direction as the block falling down the screen you would increment and decrement X in the same way. If you want the first scenario that I suggested all you would have to do is reverse it. When you increment X for the block falling down the screen you would decrement X for the block moving up the screen and do the reverse for decrementing X.

Hope that helps. smile.gif


Hey thanks a lot that really helps!!! smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 01:40PM

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