EECS 1720 Lab 7 Mar 30 & 31, 2017
In this lab, your task is to understand and modify a Java
project that implements a shooter game app and follows the
Model-View-Controller (MVC) architecture. The app is in the following
Eclipse project archive
1720_W17_Lab07Exercises.zip.
Download the file and import it into Eclipse as a project.
The exercises appear below.
To get full marks for this lab assignment, you must:
-
Go to your lab and enter your name on the sign up sheet.
-
Complete the exercises and show your correct solution to
the TA before the end of the lab session;
if your solution is correct, the TA will record it.
Exercise 1
This exercise involves developing an understanding of the game app software.
You don't need to write any code or submit any answers.
Run the app by invoking AppDriver.java
. You can
shoot by pressing the space key. You can move the shooter using
the arrow keys. You can also rotate it by using that period and comma
keys.
Explore the project code to answer the following questions:
- Look in the
sprite
package.
What kind of sprites are there? How are the classes organized?
- Where are the target sprites created?
- Where are the projectile sprites created?
- How is a collision between a projectile and a target detected?
How is the target destruction implemented?
Exercise 2
Your task here is to modify the app to count the number of targets hit since
the app has started, and when a target is hit, to print a message
on the console Target hit! No of hits is
with the correct number of hits so far since the app started.
Exercise 3
Your task here is the following:
-
First, modify the app to count the number of shots fired
since the app has started, and when a shot is fired, to print a message
on the console
Shot fired! No of shots is
with the correct number of shots so far since the app has started.
-
Second, modify the console message printed when a target is hit
(as in Exercise 2) to also report the shooter success rate so far.
The success rate is the ratio of the number of target hits to the number
of shots fired. On a separate line print
Success rate is
followed by the success rate.
Optional further work
There are many ways to further extend this app. For instance, you may want
to add a second kind of target sprites, which have a different appearance and
move in different ways. Hitting the second kind of targets could have a
different value from hitting the existing targets and it would make
sense to keep a separate count of how many are hit.
You are encouraged to do further work along those lines. But note that this
work is completely optional and that there are no marks allocated for it.