INFO1113 / COMP9003
Assignment
Due: 20 October 2024, 11:59PM AEST
This assignment is worth 20% of your final grade.
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 screenand the player can draw lines to direct them into holes of the same colour. When balls are reflected off aplayer-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.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 simple demonstration of the game and has posted it onyour online forum (Ed). You can also play a similar game here,orwatch a video of it here.You are encouraged to ask questions on Ed under the assignments category if you are unsure of thespecification – but staff members will not be able to do any coding or debugging in this assignment foryou. As with any assignment, make sure that your work is your own, and do not share your code orsolutions with other students.
Working on your assignment
You have been given a scaffold which will help you get started with this assignment. You can downloadthe scaffold onto your own computer and invoke gradle build to compile and resolve dependencies. Youwill be using the Processing library within your project to allow you to create a window and drawgraphics. You can access the documentation from here.INFO1113 / COMP9003
Page 2 of 10
Gameplay
The game contains a number of entities that will need to be implemented within your application.
Level
Each level is read from a text file of characters 18x18. The size of the window should be 576x640, meaningeach character in the file corresponds to 32x32 pixels.
The level layouts are defined in filesprovided in the “layout” attribute of theJSON configuration file described below.Each level must have an associated
layout file.
Note that the file does not need tocontain exactly 18x18=324 characters. Itmay have less than this if they are notnecessary (such as spaces at the end ofa line, or missing lines at the bottom). Insuch situations, your program shouldstill work, and must reflect balls off theedges 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 boarddoes 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 oneof these walls, it is reflected and changes colour to that of the wall.
- S – Spawner. Balls spawn from this location 代 写INFO1113 / COMP9003 a prototype of the game (one spawner is chosen randomly of all availablespawners in the current level, each time 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 left. The numberin the character to the right of the H is the colour of the hole.
- B – Balls. Instead of spawning after the spawn interval, a ball may be present immediately fromthe level beginning, at a specific place on the board. The colour of the ball is denoted by thecharacter to the right of the ‘B’.
- Spaces – empty space, just ignore it (blank tile).
Figure 1.
The second provided sample levelINFO1113 / COMP9003
Page 3 of 10
Config
The config file is in located in
config.json in the root directory of theproject (the same directory asbuild.gradle and the src folder). Use ajson library to read it. Sample config
and level files are provided in thecaffold.The map layout files will also be locatedin the root directory of the project.However, sprites or images such as theballx.png, and wallx.png will be
ocated in the resources folder(src/main/resources/inkball/) orbuild/resources/main/inkball/).For each level, the following properties are provided in the config:
- layout: the level file containing the characters determining the position of tiles in the grid forwalls, holes, spawners and initial balls.
- time: the maximum number of seconds this level should last for. If the time is exceeded, theplayer 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 eachball type when they successfully enter a hole.
- score_increase_from_hole_capture_modifier: Multiply the score values gainedon this level by this modifier.
- score_decrease_from_wrong_hole: The amount of units score is decreased for eachball type when they enter the wrong hole.
- score_decrease_from_wrong_hole_modifier: Multiply the score values lost (when aball enters a wrong hole) on this level by this modifier.Figure 2. Example config file. INFO1113 / COMP9003
Page 4 of 10
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 spawnerthroughout the duration of thegame. 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 initially at thatgiven value * App.FPS, it counts down on each frame and is displayed in the top bar, next to the display ofwhere 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 counterreaches 0, the next ball is spawned in the game. All other balls remaining yet to be spawned, willgradually move to the left 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 xdirection, 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 directionand j is the velocity in the y direction. Balls collide with walls and player-drawn lines which change theirvelocity vector trajectory, as described below.
Hitbox A hitbox is a series of points, which form a sequence of line segments. For example, a player-drawn line
may appear as below:The steps to calculate the new trajectory (u) could be as follows:
- Determine the line segment that the ball is hitting (if the ball will hit any line segments). To do
this, check the distance of the ball (x,y) + velocity of the ball, between two adjacent points, P1 and
P2. The distance formula is as below:
标签:ball,level,game,will,COMP9003,INFO1113,balls,prototype,your From: https://www.cnblogs.com/comp9313/p/18460533