Starting from:

$30

INFO1113 -  Assignment 2 - Solved

Task 
You are working for a company called ArcadeRetro which recreates popular arcade games for modern audiences. The company is currently developing a game called Waka Waka. In the game, the player must guide Waka around the map, collecting all the fruit whilst avoiding enemy ghosts.

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.

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 the following link. For the reading of configuration files, you will be using JSON.simple. You can access the documentation for the library here.  

 

 
Gameplay
The game contains a number of entities that will need to be implemented within your application.

Map
  

The Map designates where Waka and ghosts are allowed to move. Laid out as a grid, entities can move along rows and columns where there is no wall (represented by a blue line). Maps are 36 rows tall, and 28 columns wide, however typically at least the top 3 and bottom 2 rows are left empty for additional UI elements. Each grid space is 16x16 pixels.

Map layouts are stored in text files, and the name of the map file can be found in config.json under the “map” attribute. Sample Map and config.json files can be found under resources on Ed. Map files store the maps as multidimensional character arrays, where each character represents what is in that cell. Note that a map is valid if it has a bounding border, a starting location for Waka, and at least one fruit. There is no minimum requirement for the number of Ghosts.

Character
Contents
Sprite
0
Empty cell
N/A
1
Horizontal wall
  
2
Vertical wall
  
3
Corner wall (up + left)
  
4
Corner wall (up + right)
  
5
Corner wall (down + left)
  
6
Corner wall (down + right)
  
7
Fruit
  
p
Waka starting location
 
g
Ghost starting location
 
 

Waka
  

Waka is the player-controlled character in the game. Waka can move vertically and horizontally on the map and cannot pass through walls. Waka is controlled with the arrow keys (up, down, left and right).

Unless colliding with a wall, Waka is always moving. The player can tell Waka what his next move should be, and Waka will turn accordingly when next possible. For example, if Waka were in the following position, moving right:

  

And the player was to press the down key, Waka would turn down when he reaches the end of the hall. If the player were to press the up key, Waka would make the next possible turn up. If the player were to press the left key, Waka would immediately turn around (Waka can always turn around). If the player were to press the right key, Waka would continue unchanged. Note that if the player presses multiple keys before Waka turns, the most recent key is used.

Waka moves at a constant speed, specified in the configuration file under the “speed” attribute. This speed will either be 1 or 2.  

Also present in the configuration file is the number of lives Waka has. The field is stored under the “lives” attribute. The number of lives remaining is represented on the screen with sprites of Waka facing right at the bottom. When Waka runs out of lives, the game is over.

  

Waka has five sprites that can be rendered: one with a closed mouth and one open mouth sprite for each cardinal direction. Waka’s sprite should alternate between open-mouth and closed-mouth every 8 frames, and should also have the open-mouth sprite relate to the direction he is moving. For example, if Waka is moving upwards, Waka’s mouth should be pointing upwards.  

Ghost
  

Ghosts are the antagonists of Waka Waka. Their goal is to prevent Waka from collecting all the fruit on the map. They do this by hunting him down and hitting him.  

Like Waka, Ghosts can move horizontally and vertically on the map. They cannot pass through walls, however can pass through each other. Ghosts move at the same speed as Waka (specified in the game configuration file).

Ghosts have two modes they can be in: SCATTER and CHASE. These modes determine the behaviour of the Ghosts when they reach an intersection.  

The durations of these modes are specified in the configuration file under the attribute “modeLengths”. The attribute is stored as an array of ints, representing the time (in seconds) each mode should be before alternating to the other, with the first mode being SCATTER. If the game has not ended by the time the array has been traversed through, the array restarts from the beginning in SCATTER mode.

When a Ghost reaches an intersection (a point at which it can make a turn), it determines its target location, and then moves in the direction of the adjacent grid space closest to the target, based on straight line distance. For example, if the target location for the Ghost in the image below was 3 rows up and 1 column left, the Ghost would move up. Conversely, if the target location were to be 1 row up and 3 columns left, the Ghost would turn left.

  

The mode the Ghost is in determines what the target location is:

•       If the Ghost is in SCATTER mode, the target location is the closest corner of the map

•       If the Ghost is in CHASE mode, the target location is the grid space occupied by Waka

Note that, unless trapped, a Ghost cannot turn around and move in the opposite direction to which it just moved. For example, if a Ghost has moved upwards to an intersection, it cannot then move down. Instead it must move in whichever of the other three cardinal directions is closest to the target location.

When a Ghost occupies the same grid space as Waka, all Ghosts and Waka return to their starting positions, and Waka loses a life. When Waka loses all of his lives, the game ends.

For testing purposes, ArcadeRetro has requested that you include a DEBUG mode for your game, which can be activated/deactivated by pressing the space key. While in DEBUG mode, a white line is drawn from each Ghost to their respective target location.

Fruit
  

Waka’s goal is to collect every fruit on the map. Waka does this by moving onto the grid space that the fruit occupies. When this occurs, the fruit is removed from the map. Fruit entities do not move, nor are they collected by ghosts. If Waka is hit by a ghost, fruits are not reset. Instead all fruit collected before the collision remain cleared from the map. Once Waka collects all fruit in the map, the game ends.

Application
Your application will need to adhere to the following specifications:

•       The window must have dimensions 448x576  

•       The game must maintain a frame rate of 60 frames per second.  

•       Your application must be able to compile and run on any the university lab machines (or Ubuntu VM) using gradle build & gradle run. Failure to do so, will result in 0% for Final Code Submission.  

•       Your program must not exhibit any memory leak.  

•       You must use the processing library, you cannot use any other framework such as javafx, awt or jogl.

Assets  
Artists within the company have produced sprites for your game. You have been provided a /resources folder which your code access directly. These assets are loadable using the loadImage method attached the PApplet type. Please refer to the processing documentation when loading and drawing an image.

More products