HTML代写｜Websites And Applications
In this assignment, you will create a game in the Java programming language using the Processing library for graphics and gradle as a dependency manager. In the game, the player must avoid enemies that are bouncing around the map, whilst capturing area. Once a percentage of the map area has been captured,the level is won.
You have been given the task of developing a prototype of the game. A full description of gameplay mechanics and entities can be found below. An artist has created a simple demonstration of the game and has posted it on your online forum (Ed). You can also play a similar game here.
You are encouraged to ask questions on Ed under the assignments category if you are unsure of the specification – but staff members will not be able to do any coding or debugging in this assignment for you. As with any assignment, make sure that your work is your own, and do not share your code or solutions with other students.
Working on your assignment
You have been given a scaffold which will help you get started with this assignment. You can download the scaffold onto your own computer and invoke gradle build to compile and resolve dependencies. You will be using the Processing library within your project to allow you to create a window and draw graphics. You can access the documentation from here.
The game contains a number of entities that will need to be implemented within your application.
The map consists of a grid of tiles 64×32. Each tile is 20×20 pixels, so the total is 1280×640 pixels. The player always begins in the top-left corner of this grid. However, the top 80 pixels of the window are reserved for the information bar which contains text to display the current number of lives, progress towards the goal, level number, and timer remaining on the powerup’s effect. The window size is therefore 1280×720.
There are 3 main types of tiles:
- Grass (filled)
- Dirt (empty)
- Path (green – in progress)
- Path (red – hit by enemy)
The map is always surrounded by cement tiles. Additional cement tiles may be placed as specified by the level file in the config (see below).
The config file is in located in config.json in the root directory of the project. Use the simple json library to read it. Sample config and level files are provided in the scaffold.
The config sample as shown to the left, contains the names of the level files. These are also located in the root directory of the project. The level files will contain a grid of text characters, where each character represents what should be in that tile cell. X marks where cement tiles should be placed. Spaces are empty space (dirt/soil). Note that a map is valid if it has a bounding border of cement tiles. (all maps used for marking will be valid, but you should write your own tests for invalid maps and handle them as you see fit).
Type 0 enemy is the standard worm. Type 1 is the beetle.
The spawn location of the enemies can either be “random” (within the current empty space) or a specified coordinate value such as “10,23” to signify row 10, column 23 on the tile grid. Or “3,18” to signify row 3, column 18”. The enemy should spawn in a random pixel location within that tile.
The player character is controlled using the arrow keys (up, down, left, right). Movement should be smoothly transitioning from one tile space to another. The player always begins in the top-left corner of the map. While on cement tiles, the user must be actively holding the movement key for movement to occur, otherwise movement stops. When the player enters a dirt (empty) region, movement continues even if the user releases the movement key. The same velocity and direction is maintained until another direction key is pressed (if it’s the opposite direction, nothing happens).
For example: the down key is pressed. The player enters the soil region. The down key is released, but the player keeps moving downwards. If the up key is pressed, the player continues moving downwards. If the left key is pressed, then the player makes a left turn and starts moving left. This behaviour is the same for filled regions (grass).
The player’s goal is to fill as much of the soil with grass while avoiding enemies. It does so by laying a green path behind it as it moves, and when it closes the path by reaching a safe tile (either a concrete tile or a grass tile), the regions enclosed on either side of the path will be filled with grass if there are no enemies within them. If there are enemies within both, then only the path itself becomes grass.
If an enemy hits the path while the player is laying it out and before it has reached a safe tile, the path tile it hits will turn red and propagate outward towards the player at a rate of one tile every 3 frames. If the red path hits the player before it reaches a safe tile, one life is lost and the player respawns in the top left corner.
If the player circles back and hits their own in-progress path, they lose a life and respawn.
The player’s movement speed is 2 pixels per frame.
There are two main enemies: worms and beetles. The worm is the basic one and the beetle has the same functionality as the worm, except when it hits a grass tile, it becomes soil (empty) again. And it also has a different sprite.
These enemies move always in only one of 4 diagonal directions. Upon hitting a wall, they bounce off and start moving in the reflected direction.
The initial enemy positions are determined by the configuration file. It can either be “random”, to spawn randomly in a location within the empty space, or a specified coordinate value on the board.
Enemy movement speed is 2 pixels per frame in both the x and y directions.
A powerup is an item that can be collected by the player upon moving to that location on the board (player character collides with it directly). Powerups should always spawn in the empty area (soil) so there is some risk for the player in retrieving them. Please be creative in designing the sprite for the powerup you decide to implement. The functionality could be any one of the following things:
- Make enemies slow down for a timed period
- Make the player speed up for a timed period
- Make the player invincible for a timed period (if enemies hit the path being laid, then they just bounce off) – (optional: if the player hits an enemy, it respawns somewhere else on the empty areas of the map). Enemies should have some kind of visual indication that their behaviour has changed – maybe a border around them, or different colour.
- Make enemies freeze for a timed period
- Decrease the propagation speed of red path tiles for a timed period
Please ensure that the duration of the timer remaining is made clear to the player. (maybe there is a counter in the top bar, with the name of the powerup’s effect). You should determine the time interval it lasts for (maybe around 10 seconds is reasonable). You may also choose to implement a sound effect when the powerup is collected, and choose to animate it.
The powerup should not spawn immediately when the level loads, but only after some delay interval (within 10 seconds). And when collected, only after another randomised delay interval, with this process continuing. You may choose to implement multiple powerups and choose which one to randomly spawn
- Note that the powerup system must be able to work with all map types.
If a powerup is captured within a region that turns to grass, it is removed (discarded) with no effect.
Win and lose conditions
The current level is completed when the area of soil is covered with grass matching at least the proportion defined in the goal (round up fractional values). If there is another level, that level is then loaded with the player starting in the top-left corner again. The player retains the number of lives they had previously.
If there are no more levels and the player wins, display a screen saying “You win”.
If the player loses all of their lives, display a screen saying “Game over”.