FLOVODOH #7

| May 27, 2018

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.Create a function getUserInput() to get the user inputs.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: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.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 4×4 2-D shapeArray map:Here is the swap: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.

Get a 25 % discount on an order above $ 100
Use the following coupon code:
25%OFF
Positive SSL