Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

FLOVODOH #7

You have already displayed the Tetris Bucket, started dropping the shapes, stopped them at the bottom of the Bucket, and dropped another shape from the top. During this Module, you move/rotate the shape in response to the player input. Add plenty of narrative comments. Your program must be compilable and executable.

If you need guidance, you will find some detailed instruction (below) to assist you.

    1. Create a function getUserInput() to get the user inputs.
    2. Create a moveShape(int input, int& newShapeTopLeftX, int& newShapeTopLeftY)function. This will have a switch case block that will include a default case which will increase the Y by 1, (i.e., by default the shape will keep falling). Other values of the switch case would be the arrow keys. Here is an enumeration of the arrow key values that you will use.

enum {UP_ARROW=72,DOWN_ARROW=80, LEFT_ARROW=75, RIGHT_ARROW=77};

Handling "left", "right", and "down" arrow keys are easy. However, the "up" arrow key rotates the shape which is little more challenging. Here are two (2) approaches:

    1. Multi-dimensional arrays: You can assign all the rotational shapes into multi-dimensional arrays (as outlined in the previous Module). There is no trick to it but it is little laborious and lengthy.
    2. Swap the values of the shape array: Visualize the 2-D array map like a chess board. If you rotate the shape clock-wise, do you see which cells' values go to which cells? You will do just that. With each rotate you will do a clock-wise rotation just by swapping the values of the shape array cells. It will be little inaccurate, but is enough for this project. Feel free to add more conditions to make it correct. Here is how the swap would look.

Here is a 4x4 2-D shapeArray map:

Here is the swap:

  1. If you are passing values in the intention of changing it, verify whether you are passing by value/reference. You need to tweak your steps depending on how you implement.
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question