Build a Pong Game App for CMSC436 Project 5

School
University of Maryland, College Park**We aren't endorsed by this school
Course
CMSC 436
Subject
Computer Science
Date
Dec 12, 2024
Pages
4
Uploaded by MateJellyfish4266
CMSC436 Project 5 – Assigned Thursday March 14, 2024 Due Thursday April 4, 2024 11:59PM 0 – You can do this app/project with another CMSC436 student (you do not have to). One submission only for 2 students if you choose to do it as a pair. Include both names in the top comments of your code (inside MainActivity) and submit as a group/pair. The project must be called project5 and the package must be com.example.project5. The project will be tested on emulator Pixel 5 API 34. 1 - Create an Android App using the Empty Views Activity template 2 – The app works in vertical orientation only (but you do not need to submit the AndroidManifest.xml file). This app has only 1 screen. This app is the game of pong. 3 – When the app starts, the user is ready to play the game of pong. There is a small ball somewhere (you choose) at the top of the screen and a "paddle" somewhere (you choose) at the bottom of the screen. The paddle should be a drawn rectangle (Android may or may not animate a TextView) and the ball should be a drawn circle. When the user touches the screen, the game starts. The ball comes down at a 45 degrees angle (either left or right, you choose) and will bounce off the walls and bounce off the paddle at that same 45 degrees angle. 4 – The user can move the paddle from left to right and right to left (always horizontally) by moving the finger (note that the finger does nothave to be on the paddle for the paddle to move). 5 – If the ball goes through without hitting the paddle, then the current game is over (but the app is still running). At this point, you should draw somewhere on the screen reporting the number of times the user hit the ball with the paddle and the best score and whether this is or not the new best score. 6 – After the game is over, the user can restart the game by touching the screen; obviously, the current score needs to be reset. 7– Every time the ball hits the paddle, it makes a sound. You should name your sound file hit.wavand place it in the raw directory(so that the TAs do not have to copy and paste your file).
Background image
8 – You should keep track of how many times the ball hits the paddle for the current game. This is your score. The app stores (persistent data, in shared preferences) the user's best score (the first time we use the app, the default best is 0). 9 - Your app should include a Model (class Pong in file Pong.kt) that encapsulates the functionality of the game of pong. Obviously, the model needs to be used (and used in a way that makes sense) within the app. Some things that should be included in the Model: ball position, speed, size, paddle position, size?, …, methods to move the paddle, the ball, detect if the ball has hit the paddle, has hit a wall, .. Submission Details: on Gradescope, 4 Kotlin files: MainActivity.kt, Pong.kt (the Model), GameView.kt and GameTimerTask.kt Grading Details: Item Points Ball and paddle show at beginning of the app 10 Game starts when user touches the screen 5 Paddle moves correctly 10 Ball moves correctly 10 Ball bounces off the wall correctly 5 Ball bounces off the paddle correctly 10 A sound is played when the ball hits the paddle 5 When the paddle misses the ball, (correct) text shows 10 After the game is over, user can restart the game by touching the screen 3 When the user touches the screen, the score is reset correctly 2 Persistent data is handled correctly 10 Model (Pong class) is coded and is correct 10 Model (Pong class) is used correctly 10 Total 100 Grading notes: 1 – In canvas, zipping the files will result in a 10 points penalty. 2 – Not naming the files as specified above will result in a 10 points penalty.
Background image
Suggested Plan: 1 - Show the ball at the top of the screen 2 – Show the paddle at the bottom of the screen 3 – Make the ball come down 4 – Make the ball change direction when it hits the wall 5 – Make the ball change direction when it hits the paddle 6 – Keep a count of the number of hits 7 – Only make the ball come down after the user touches the screen 8 – Move the paddle as the user's finger moves 9 – Draw the text when the game is over 10 – Handle persistent data At the start of the app
Background image
The ball is moving Possible last screen
Background image