Video Game – Thu & Jen

Content

 

Project

For our project, we created a video game in which the player has to move a blue ball across the screen. The horizontal location of the ball is controlled by moving a motor. However, while this is happening, there are red balls bouncing between the top and bottom of the screen. If a blue ball touches a red ball, the game is over, and the screen will say “You lose.” If the person makes it to the other side of the screen, a picture will come up that says “You win.” The player can start off easy with one or two balls and then make the game more challenging by increasing the number of balls.

 

Structure

We created the game controller by attaching a motor and wheel to an EV3. The user must turn the wheel to move the horizontal location of the ball.

 

Coding

We randomly generated the x and y locations of the red balls and kept the y location in an array. These red balls would bounce up and down on the screen. The small blue ball’s x position is controlled by rotation of the motor. If the small blue ball overlapped with any of the red balls, the y location of that red ball became -100 in the array. We made a case structure, which said that if any of the values in the array were less than zero, the game would end and the screen would show “You lose.” The screen will say “You win” if the x position of the blue ball is greater than 1020 (the width of the picture) and if the y position of the red balls are all greater than zero. We also coded it so the user can increase the number of balls as they prefer it.

 

Challenges We Faced

Our initial idea for the project was to create a game in which the player had to fire a ball from the bottom of the screen up at the balls falling from the top of the screen when a button was pressed. However, we struggled when attempting to make the ball shoot upward and when figuring out the location of where the two balls intercepted. We then modified our idea to what our game is now.

 
Gallery
Video
Attachments
AttachmentTypeSize
video_5829f7bbebd18video.vi30.11 KB

Leave a Reply

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