This project is a game designed to raise awareness about the importance of taking preventive measures against COVID-19. Players must use knowledge and resources to defend against the virus and protect their community. The game is inspired by the popular game "Plants vs. Zombies."
In the face of the COVID-19 pandemic, players must be prepared to take action. Players can collect knowledge from books, use masks to defend against the virus, and use alcohol to eliminate it. The game emphasizes the importance of knowledge, responsibility, and taking action in the fight against COVID-19.
The game field consists of a 3x10 grid. Players can place various objects on the grid to defend against the virus.
The home base represents the player's community. Players must protect the home base from the virus.
Players can place various preventive measures on the grid to defend against the virus. Each preventive measure has different attributes, such as health points (HP), attack points (ATK), cost, and speed.
The virus represents the enemy in the game. There are different types of viruses with varying attributes, such as health points (HP), attack points (ATK), and speed.
- Normal Virus
- Strong Virus
- Teleporting Virus
Name | HP | ATK | speed |
---|---|---|---|
Normal Virus | 40 | 10 | 4 |
Strong Virus | 100 | 10 | 4 |
Teleporting Virus | 50 | 10 | Waits 8 seconds and then teleports to the front line |
The game is implemented in Java and uses a 2D array to manage objects on the game field. The game has multiple timers to handle various game events, such as generating sunlight, spawning viruses, detecting collisions, and updating the game field.
The game uses three separate 2D arrays to manage the objects displayed on the game field. Each array corresponds to a specific type of object: plants, viruses, and projectiles. The game field is represented as a 3x10 grid, and each cell in the grid can hold one object.
plant
: A 3x10 array that holds the plant objects placed by the player. Each cell can contain one plant, such as a Book, Alcohol, Mask, Thermometer, or QR Code.virus
: A 3x10 array that holds the virus objects that spawn on the right side of the game field. Each cell can contain one virus, such as a Normal Virus, Strong Virus, or Teleporting Virus.bullet
: A 3x10 array that holds the projectile objects fired by certain plants. Each cell can contain one projectile, such as an alcohol droplet. The game's user interface (UI) reads these arrays to display the corresponding objects on the game field.
The game uses four timers to handle various game events:
suntimer
: This timer runs every 5 seconds and adds 10 units of sunlight to the player's resources. Sunlight is used to place plants on the game field.virustimer
: This timer runs every 5 seconds and spawns a virus on the rightmost side of the game field. The virus then moves towards the left side of the game field.detectiontimer
: This timer runs every second and checks for collisions between objects. It handles events such as viruses attacking plants, projectiles hitting viruses, and viruses reaching the leftmost side of the game field.repainttimer
: This timer runs every second and updates the three object arrays to reflect the current state of the game.
Due to the use of 2D arrays, overlapping objects of the same type are not recorded separately. However, the game handles overlapping objects by stacking their attributes. For example, if two viruses occupy the same cell, one virus inherits the other's health points (HP) and attack points (ATK).