“Brick Says” by Faizan and Adan

Content
 bricksays_582a67e777595



We made an EV3 version of the popular game "Simon Says" and "Bop It!", called Brick Says. The Brick asks you to do certain tasks like turn the wheel, press the button, tilt the brick or slap the ultrasonic sensor and you are suppposed to do these tasks in an increasingly shorter period of time.

The mechanical design of this game is very simple and obvious but the programming is much more complicated:

capture_582a692a07b93
The top section is basically a countdown to the beginning of the game. The important part is the while loop under it that has two case statements in it. In every while loop, a random number between 0 and 1 is generated that is multiplied by 4 and then its floor is taken. This means that we have random integers 0, 1, 2 and 3 coming in. The first case statement associates these number with a task each so that random tasks are given. A timer is started in every loop to see how long does it take for the user to do the task. The time is checked after the task is done. The loop counter is used to decrease the time per task after every loop. It is initially 2500 ms but decreases by 50ms every time.

The first case statement can produce a true or a false which controls the next case statement. If there is a true, it means the game is not over and the program clears the screen and updates the score. If it is false the program displays game over, user score and the high score. The second case statement can also produce a true and false. A true means that the the next loop should come and false means that loops should stop. This is linked to the continue if true part of the main while loop.

The actual code and a video explanation/demonstration is available below.

 

Gallery
Video
Attachments
AttachmentTypeSize
main_582a6d15ea696Main.vi44.29 KB

Leave a Reply

Your email address will not be published. Required fields are marked *