悉尼大学
INFO1113 Object Oriented Programming
Task Description
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, balls spawn and move around the screen and the player can draw lines to direct them into holes of the same colour. When balls are reflected off a player-drawn line it disappears. If a ball enters a hole of a wrong colour, score is lost and it respawns. Once all balls are captured by holes, the player wins.
Gameplay
The game contains a number of entities that will need to be implemented within your application.
Each level is read from a text file of characters 18x18. The size of the window should be 576x640, meaning each character in the file corresponds to 32x32 pixels. The level layouts are defined in files provided in the “layout” attribute of the JSON configuration file described below. Each level must have an associated layout file.
Note that the file does not need to contain exactly 18x18=324 characters. It may have less than this if they are not necessary (such as spaces at the end of a line, or missing lines at the boRom). In such situations, your program should still work, and must reflect balls off the edges of the screen.
There are 5 main types of characters that could be present in the file:
• X – denotes a wall (wall0.png). Balls reflect off this, but do not change colour. The game board does not need to be surrounded by walls – balls should reflect off the edge of the screen.
• 1,2,3,4: walls 1,2,3 and 4 respectively, as provided in the scaffold resources. When a ball hits one of these walls, it is reflected and changes colour to that of the wall.
• S – Spawner. Balls spawn from this location (one spawner is chosen randomly of all available spawners in the current level, each Bme a ball is ready to be spawned).
• H – Holes. The hole takes up 4 tiles, where the ‘H’ character is the one in the top le`. The number in the character to the right of the H is the colour of the hole.
• B – Balls. Instead of spawning a`er the spawn interval, a ball may be present immediately from the level beginning, at a specific place on the board. The colour of the ball is denoted by the character to the right of the ‘B’.
• Spaces – empty space, just ignore it (blank tile).
For each level, the following properties are provided in the config:
The config file is in located in config.json in the root directory of the project (the same directory as build.gradle and the src folder). Use a json library to read it. Sample config and level files are provided in the scaffold.
The map layout files will also be located in the root directory of the project. However, sprites or images such as the
ballx.png, and wallx.png will be located in the resources folder (src/main/resources/inkball/) or (build/resources/main/inkball/).
• layout: the level file containing the characters determining the position of tiles in the grid for walls, holes, spawners and iniBal balls.
• time: the maximum number of seconds this level should last for. If the time is exceeded, the player loses the level and it restarts. If the time is invalid (eg, non-integer or negative value like -1) or missing, there is no timer for this level.
• spawn_interval: the number of seconds in between when balls spawn.
• score_increase_from_hole_capture: The amount of units score is increased for each ball type when they successfully enter a hole.
• score_increase_from_hole_capture_modifier: Multiply the score values gained on this level by this modifier.
• score_decrease_from_wrong_hole: The amount of units score is decreased for each ball type when they enter the wrong hole.
• score_decrease_from_wrong_hole_modifier: Multiply the score values lost (when a ball enters a wrong hole) on this level by this modifier.
Balls
Balls may appear in the level layout file, as “B0”, “B1”, “B2”, etc in which case they are spawned immediately in that location when the level begins. Alternatively, they may also be specified in the configuration file, which will cause them to be spawned at a spawner throughout the duraBon of the game. The frequency of spawning is determined by the spawn_interval configuration property of that level, which determines how many seconds in between when balls spawn. From being iniBally at that given value * App.FPS, it counts down on each frame and is displayed in the top bar, next to the display of where balls yet to be spawned appear. The order of balls in this display should be the same as the configuration file (only the next 5 balls yet to be spawned are shown). When the spawn interval counter reaches 0, the next ball is spawned in the game. All other balls remaining yet to be spawned, will gradually move to the le` in the display at a rate of 1 pixel per frame.
When balls spawn in the game, they have a random velocity vector which is either -2, or 2 pixels in the x direction, and -2, or 2 pixels in the y direction (assuming 30fps – if using 60fps, this would be halved). Throughout this document, vectors will be notated as (i,j) where i is the velocity in the x direction and j is the velocity in the y direction. Balls collide with walls and player-drawn lines which change their velocity vector trajectory, as described below.
Holes
Holes take up 2x2 regular tile spaces (64x64 pixels). When a ball is within 32 pixels of the centre of a hole (from the centre of the ball), it starts to be attracted into the hole. Its size reduces proportionally to how close it comes to the centre of the hole, until when it is on top of the centre, then it will be captured by the hole and disappears. The force of attraction is approximately 0.5% of the vector from the ball to the centre of the hole.
Score and Timer
The score value is persistent across levels. The timer for a level starts at the value specified in the config file, and should count down each second. When it reaches 0, the level will end, display the message === TIME’S UP === in the top bar. The player must then press ‘r’ to restart the level. In the ended state, balls do not move and the player cannot draw lines.
A level ends when all balls are captured by holes successfully, (ie, there are no more balls remaining to be spawned, and no balls currently in play). Any remaining time gets added to the player’s score, at a rate of 1 unit every 0.067 seconds. As this is occurring, two yellow tiles which begin in the top le` corner and boRom right corner will move in a clockwise direction around the edge of the game board, also at a rate of 1 tile every 0.067 seconds.
Application
Your application will need to adhere to the following specifications:
• The window must have dimensions 576x640
• The game maintains a frame rate of 30 or 60 frames per second (physics is frame rate dependent)
• Your application must be able to compile and run using Java 8 and gradle run. Failure to do so, will result in 0% for Final Code Submission. Later versions of Java may work, but you should not use any newer Java language features.
• Your program must not exhibit any memory leaks.
• You must use the processing library (specifically processing.core and processing.data), you cannot use any other framework for graphics such as javafx, awt or jogl
You have been provided a /resources folder which your code can access directly (please use a relative path). These assets are loadable using the loadImage method attached to the type. Please refer to the processing documentation when loading and drawing an image. You may decide to modify these images if you wish to customise your game. You will be required to create your own sprites for any extensions you want to implement.
咨询 Alpha 小助手,获取更多课业帮助