Getting Started
Begin by downloading the a9 code package from lecture 35. It is close to what was used in the lab, but with more comments and a few added classes and methods. There is also some sample art. Finally, there is a test program, Example.java, that runs a zombie at a plant. Make sure that runs.
Do your work in this package. Rename the Example.java file (right-click the file in Eclipse package explorer and refactor->rename it) and to something more meaningful when you decide on your game theme.
Assignment Requirements
This assignment has two phases.
Phase 1
Phase 1 is due Nov. 25. You will need to submit a video showing how you have completed the Phase 1 requirements and your code up to that point.
In Phase 1, you should:
- Decide a theme that is plant vs zombie-like but of your own creation. You should consider if you can find any images to use as characters in the game. You can also draw your own. For example, you can usehttps://www.piskelapp.com(Links to an external site.)to draw and save simple sprite images. Make sure the theme makes sense for having stationary Plant-like things defend moving Zombie-like things. You cannot use a Plants vs. Zombies theme. You will likely want to resize the images to match how big you want them in the game. There are many tools to resize images.
- Adapt the example code and the ideas from lab to make a start to the game.
- Rather than having a user pick plants to place, have them appear randomly in a grid and at a reasonable rate of appearing - like the whack-a-zombie lab exercise.
- Have zombies appear on the right side aligned in rows, like the actual game does. Note that picking a row for a zombie is just like picking a row and column for a plant, it is just that the column is set to the far side of the screen.
- Zombies should move left until they encounter a plant. The zombie should attack the plant until its health is
- Plants should attack zombies that are touching them. Zombies with 0 health should be removed.
- You should make 2 Plant sub classes and when a Plant is randomly placed, randomly choose one of those two new sub class Plant types.
- For Phase 1, make the sub classes be very easy - just chose different images and make their attack strength, cooldown, and/or starting health different.
- You will mostly be making a constructor for these new classes and inheriting from Plant. Right now the Plant constructor allows for a lot of different parameters to be passed in. Your sub class constructor can call the super Plant constructor with the values needed for that sub class Plant type.
Submitting phase 1
Make a video showing random plants of two different types appearing on a grid, zombies randomly appearing in rows, and them attacking each other and being removed when destroyed.
Gradescope will allow one partner to submit and add their partner to the submission. Each partner should not submit independently. Confirm with your partner who is submitting and that the other has been added.
Phase 2 - the below is provided to give a sense of where you are headed as you complete Phase 1.
In the second phase, which will be due Dec. 5, you will turn this into a game.
- Replace the random plant generation with user activity.
- Add buttons for the plants. These should show the kind of plant and the cost of a new plant.
- Add a resource, like the sun in the original game. This can be something that just grows over time (like adding gold each time step), or you can be more like the actual game and make it something that needs to be clicked on to be collected.
- When a plant button is clicked, the next click should be on the game panel to see where to place the plant. You can decide what should happen if you click on another button instead or somewhere a plant cannot be placed.
- Calculate the col and row the click is in, then place the plant in a cell. Check to see if the cell is empty. Do not place the plant on top of another plant. Align the plant to the cell. Deduct the cost of the plant from the resource. Do not let the plant be placed if there are not enough resources.
- Make two derived Plant types and two derived Zombie types. One of each can be something simple, like fast or armored. The other must override some super class method to allow more interesting behavior (for example, override attack, move, collision, or removeAction).
- The lab next week will show how to make a healer type Zombie. You cannot use this idea for one of your subclasses, even if it matches your theme.
- Change the random Zombie appearance so that the two new subclasses of Zombie are used.
- If the Zombie makes it to the left side of the screen, the game is over.
- Add something to increase the difficulty as the game goes on - levels, types of zombies, rate of generation.
For phase 2, write up a short document explaining your types of plants and zombies and how the game gets harder. The final submission for the second phase will be a video, the document, and the code files. There will be a second assignment worth 100 points for the final phase 2 submission.