Question: For this question, you will write a simple game that uses stacks of colorful red, blue and green blocks. Playing the game involves two separate
For this question, you will write a simple game that uses stacks of colorful red, blue and green blocks.
Playing the game involves two separate stacks of blocks. On the lefthand side is a stack of blocks we will call the main stack. On the righthand side is a stack of blocks which we will call the scoring stack. The scoring stack is initially empty; the players goal is to repeatedly stack up blocks of the same color on the scoring stack.
Below is how your program should behave in more detail.
Display the main stack of blocks somewhere on the lefthand side of the screen. When your program starts, the main stack should contain blocks with randomlydetermined colors red blue or green for each block The stack should be placed flush against the bottom of the canvas, with the blocks directly on top of each other. See Figure below.
Display the players score somewhere on the canvas. Initially the score is
When the player presses the b key for new Block: A new block with a randomlydetermined color red green, or blue is placed on top of the main stack. Doing this costs the player point ie their score goes DOWN by
When the player presses the s key for Score: The top block of the main stack should be moved to the top of the scoring stack. However, this operation is NOT ALLOWED if the block being moved does not match the color of all of the blocks already in the scoring stack in this case, pressing s just does nothing Pressing s also does nothing if the main stack is empty. If there are ever blocks on the scoring stack after a move, the player scores points and the scoring stack is cleared.
When the player presses the d key for Destroy: Destroy the top block of the main stack
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
