1. Homepage
  2. Programming
  3. INFO1113 COMP9003 Object-Oriented Programming - Assignment: Ink Ball

INFO1113 COMP9003 Object-Oriented Programming - Assignment: Ink Ball

Engage in a Conversation
SydneyINFO1113COMP9003Object-Oriented ProgrammingOOP

INFO1113 / COMP9003 Assignment CourseNana.COM

CourseNana.COM

Task Description
CourseNana.COM

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. CourseNana.COM

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 on your online forum (Ed). You can also play a similar game here, or watch a video of it here. CourseNana.COM

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. CourseNana.COM

Working on your assignment CourseNana.COM

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. CourseNana.COM

Gameplay
CourseNana.COM

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

Level CourseNana.COM

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. CourseNana.COM

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. CourseNana.COM

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 bottom). In such situations, your program should still work, and must reflect balls off the edges of the screen. CourseNana.COM

There are 5 main types of characters that could be present in the file: CourseNana.COM

  • 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. CourseNana.COM

  • 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. CourseNana.COM

  • S Spawner. Balls spawn from this location (one spawner is chosen randomly of all available spawners in the current level, each time a ball is ready to be spawned). CourseNana.COM

  • H – Holes. The hole takes up 4 tiles, where the ‘H’ character is the one in the top left. The number in the character to the right of the H is the colour of the hole. CourseNana.COM

  • B Balls. Instead of spawning after 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’. CourseNana.COM

  • Spaces empty space, just ignore it (blank tile). CourseNana.COM

INFO1113 / COMP9003 CourseNana.COM

Page 2 of 10 CourseNana.COM

Figure 1.
The second provided sample level
CourseNana.COM

For each level, the following properties are provided in the config: CourseNana.COM

  • layout: the level file containing the characters determining the position of tiles in the grid for walls, holes, spawners and initial balls. CourseNana.COM

  • 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. CourseNana.COM

  • spawn_interval: the number of seconds in between when balls spawn. CourseNana.COM

  • score_increase_from_hole_capture: The amount of units score is increased for each CourseNana.COM

    ball type when they successfully enter a hole. CourseNana.COM

  • score_increase_from_hole_capture_modifier: Multiply the score values gained CourseNana.COM

    on this level by this modifier. CourseNana.COM

  • score_decrease_from_wrong_hole: The amount of units score is decreased for each CourseNana.COM

    ball type when they enter the wrong hole. CourseNana.COM

  • score_decrease_from_wrong_hole_modifier: Multiply the score values lost (when a ball enters a wrong hole) on this level by this modifier. CourseNana.COM

INFO1113 / COMP9003 CourseNana.COM

Config CourseNana.COM

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. CourseNana.COM

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/). CourseNana.COM

Figure 2.
Example config file.
CourseNana.COM

Balls CourseNana.COM

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 CourseNana.COM

configuration file, which will cause them to be spawned at a spawner throughout the duration 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 initially 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 left in the display at a rate of 1 pixel per frame. CourseNana.COM

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. CourseNana.COM

Hitbox CourseNana.COM

A hitbox is a series of points, which form a sequence of line segments. For example, a player-drawn line may appear as below: CourseNana.COM

The steps to calculate the new trajectory (u) could be as follows: CourseNana.COM

  1. 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: CourseNana.COM

    𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒(𝐴, 𝐵) = (𝐵𝑥 − 𝐴𝑥)2 + (𝐵𝑦 − 𝐴𝑦)2 CourseNana.COM

    If distance(P1, ball+v) + distance(P2, ball+v) < distance(P1,P2) + ball’s radius, then the ball is considered to be colliding with the line segment connecting P1 and P2. CourseNana.COM

  2. Calculate the normal vectors of this line segment, N1 and N2 from P1(x1,y1) and P2(x2,y2). If we define dx = x2 - x1 and dy = y2 - y1, then the normals are (-dy, dx) and (dy, -dx).1 CourseNana.COM

1 Source: https://stackoverflow.com/questions/1243614/how-do-i-calculate-the-normal-vector-of-a-line-segment Page 4 of 10 CourseNana.COM

Figure 3.
CourseNana.COM

The hitbox comprises of points (shown in red) that create line segments. V is the velocity vector of the ball, and U is the new velocity vector when it hits the line, shown in purple. N1 and N2 are the normal vectors of the line, shown in green. CourseNana.COM

  1. Normalise the normal vectors so that their magnitude is 1. (ie, divide by √𝑖2 + 𝑗2). CourseNana.COM

  2. Find the normal vector on the side of the line that we want to use, either N1 or N2. The one that should be used is the one which is closer to the ball. To do this, perhaps check the distance of the midpoint of the line segment + normal vector with the ball’s position (these are the blue points shown in the diagram), and choose the vector which results in a closer distance. CourseNana.COM

  3. Calculate the new trajectory of the ball. This is given by the following formula: 2 CourseNana.COM

    Where v ⋅ n is the dot product, and n must be normalised the normal vector of the line CourseNana.COM

Hitboxes for player-drawn lines are rendered on the game board with a black line of thickness 10 units. CourseNana.COM

Once a collision occurs, the line is removed from the game. CourseNana.COM

Walls CourseNana.COM

A wall is a tile with a hitbox comprising of the points of each of its 4 corners. Collision handling for walls will work the same as above for line segments in player-drawn lines. When a ball hits an orange, blue, green or yellow wall, it will change its colour to that of the tile. CourseNana.COM

Even if the game board is not surrounded by walls at the edges, balls should still reflect off the edges. CourseNana.COM

Holes CourseNana.COM

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. CourseNana.COM

If the hole colour matches the ball’s colour (or it’s a grey ball, or grey hole), it is a success and the score increases by the amount given in the configuration file, multiplied by the level multiplier. Grey balls are allowed to enter any holes, and balls of any colour can enter a grey hole to count as a success. CourseNana.COM

If the colour capture was not successful, the ball rejoins the queue of balls yet to be spawned, and score will instead decrease by the amount specified in the configuration file. CourseNana.COM

2 Source: https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector CourseNana.COM

INFO1113 / COMP9003 CourseNana.COM

Page 5 of 10 CourseNana.COM

u = v − 2(v ⋅ n)n CourseNana.COM

segment. CourseNana.COM

Figure 4.
Your program needs to show a proportional reduction in
the ball’s size, to give the illusion of it falling into the hole. To do this, specify width and height of the sprite when drawing it. You must calculate the force (ie, acceleration) of attraction by adding a proportion of the vector from the ball to the hole, to the ball’s velocity on each frame. CourseNana.COM

Player Actions CourseNana.COM

During the game, players can cause the following actions to occur: CourseNana.COM

  • Press ‘r’ to restart the level, or if the game has ended because all levels were completed, restart the game. The level returns to its original state, including the timer, balls, and clearing any player drawn lines. Score will return to the state it was at before the level started. CourseNana.COM

  • Press spacebar to pause the game. Balls should not move until the spacebar is pressed again to un-pause the game. The player can still draw lines while the game is paused. To indicate that the game is paused, display *** PAUSED *** in the middle of the top bar. CourseNana.COM

    Players can draw lines with the left mouse button, and can remove those lines by right-clicking over them. CourseNana.COM

    Score and Timer CourseNana.COM

    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. CourseNana.COM

    Level End and Game End CourseNana.COM

    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 left corner and bottom 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. CourseNana.COM

    When the last level ends, the game ends display === ENDED === in the top bar. The user may press ‘r’ to restart the game. CourseNana.COM

    Application CourseNana.COM

    Your application will need to adhere to the following specifications: CourseNana.COM

  • The window must have dimensions 576x640 CourseNana.COM

  • The game maintains a frame rate of 30 or 60 frames per second (physics is frame rate dependent) CourseNana.COM

  • Your application must be able to compile and run using Java 8 and gradle run. Failure to do so, will CourseNana.COM

    result in 0% for Final Code Submission. Later versions of Java may work, but you should not use CourseNana.COM

    any newer Java language features. CourseNana.COM

  • Your program must not exhibit any memory leaks. CourseNana.COM

  • You must use the processing library (specifically processing.core and processing.data), you cannot CourseNana.COM

    use any other framework for graphics such as javafx, awt or jogl CourseNana.COM

    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 PApplet 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. CourseNana.COM

Extension CourseNana.COM

The extension is worth 2 marks maximum. For an extension, you must choose to implement one of the following. COMP9003 students must complete an extension that involves multiple additional tile types that have an action associated with them, in order to achieve marks for the extension component. CourseNana.COM

Bricks become progressively more damaged when balls hit them, and then disappear after being hit 3 times CourseNana.COM

o Different colour bricks can only be damaged by the ball of corresponding colour, unless it’s a grey brick. CourseNana.COM

One-way wall. Allows balls to pass through in one direction but not the other.
o Optional colour can indicate that only balls of a certain colour can pass through CourseNana.COM

  • Colour restricting walls only balls of a certain colour can pass through, in both directions CourseNana.COM

  • Timed tiles they progressively become transparent over time CourseNana.COM

  • Acceleration tiles accelerate the ball in the given direction CourseNana.COM

  • Key wall and key wall activator. When a ball hits a key wall activator, the key wall is toggled to be CourseNana.COM

    either retracted (balls can pass through) or solid (balls collide and cannot pass through). CourseNana.COM

o Optional colour can indicate that only balls of a certain colour can activate the key wall Variations of key wall activator an object which when hit will a ball, enables or disables holes CourseNana.COM

(show an indication above the hole to show that it’s disabled, such as a grate for example) CourseNana.COM

OR, a feature you come up with which is of a similar or higher level of complexity (confirm with your tutor first) CourseNana.COM

Please ensure you submit a config and level layout file with the features of your extension in the first level, and ensure the extension doesn’t break any of the default behaviour. Also, describe your extension functionality in the report. CourseNana.COM

Marking Criteria (20%) CourseNana.COM

Your final submission is due on Sunday 20 October 2024 at 11:59PM. To submit, you must upload your build.gradle file and src folder to Ed. Please also include sample config and layout files that you have tested with your program to ensure it works. Do NOT submit the build folder (unless you only include the build/reports/ folder which contains the results of your testing and code coverage). Ensure src is in the root directory with the other files, and not part of a zip, then press MARK. Submit your report and UML to canvas. CourseNana.COM

Figure 5.
CourseNana.COM

The inkball sprite sheet has been provided in the scaffold resources to assist you with the sprites that may be needed for your extension. CourseNana.COM

Final Code Submission and Demo (12%) CourseNana.COM

You will need to have implemented and satisfied requirements listed in this assignment. Make sure you have addressed the following and any other requirements outlined previously. The demonstration is worth 2% and is conducted during tutorials in week 12, where you will be asked to show the functionality to your tutor and they will ask you questions about your codebase and how you implemented the functionality. CourseNana.COM

  • Window launches and shows level layout correctly (empty tiles, spawners and walls). CourseNana.COM

  • Initial ball and hole display is correct. CourseNana.COM

  • Unspawned balls are shown in the top left corner (max 5) and move left 1px/f when one spawns. CourseNana.COM

  • Ball spawn timer, and level time is correct according to the configuration file CourseNana.COM

  • Level time decreases each second, and ball spawn timer decreases each second in increments of CourseNana.COM

    0.1 seconds. CourseNana.COM

  • Balls spawn when the spawn timer reaches 0. A random spawner is chosen. CourseNana.COM

  • Balls have a random (x,y) trajectory when spawned that is (±2, ±2) px/frame and cannot be 0. CourseNana.COM

  • Balls collide with walls, and the new trajectory is calculated correctly to reflect the velocity vector CourseNana.COM

    off the surface CourseNana.COM

  • No bugs exist with ball / wall collisions (ie, balls cannot clip into walls, or cling unnaturally to the CourseNana.COM

    edge of walls) CourseNana.COM

  • The player can draw lines in the game with left mouse button, which are black and have a CourseNana.COM

    thickness of 10 units CourseNana.COM

  • Players can remove drawn lines with the right mouse button or alternatively ctrl+left click CourseNana.COM

  • Player-drawn lines have a hitbox that reflects balls based on the normal vector of the line CourseNana.COM

    segment that’s hit. When a collision occurs, they are removed. CourseNana.COM

  • When a ball comes close to a hole, it is attracted towards it with a force proportional to how close CourseNana.COM

    it is CourseNana.COM

  • When a ball comes close to a hole, its size reduces proportionally to how close it is to the hole CourseNana.COM

  • When a ball is directly above a hole, it is captured by the hole CourseNana.COM

  • When a ball of a different colour to the hole is captured by it, the ball enters the respawn queue, CourseNana.COM

    unless it is a grey ball or grey hole CourseNana.COM

  • Score changes correctly when balls are captured successfully or unsuccessfully, to increase or CourseNana.COM

    decrease respectively based on the colour of that ball and the score values specified in the config CourseNana.COM

    file, including the level multiplier. CourseNana.COM

  • Spacebar causes the game to pause, and the top bar displays *** PAUSED *** CourseNana.COM

  • The current level ends in a win when no balls remain to be spawned, and no balls are currently on CourseNana.COM

    the game board. CourseNana.COM

o Remaining time gets added to the player’s score at a rate of 1 unit every 0.067 seconds. o Yellow tiles originating in the top left corner and bottom right corner move around the CourseNana.COM

edge of the game board in a clockwise direction at a rate of 1 tile every 0.067 seconds. CourseNana.COM

  • When the level ends in a win, the next level is loaded. CourseNana.COM

  • When the level timer reaches 0, the level ends in a loss, meaning balls stop moving and the player CourseNana.COM

    can no longer draw lines. Display === TIME’S UP === in the top bar. CourseNana.COM

  • The player can press ‘r’ to restart a level at any time, including when time has run out. CourseNana.COM

  • Once the game has ended, a player can restart the game by pressing ‘r’ CourseNana.COM

  • Ensure that your application does not repeat large sections of logic CourseNana.COM

  • Ensure that your application is bug-free CourseNana.COM

Testcases (3%) CourseNana.COM

During development of your code, add testcases to your project and test as much functionality as possible. You will need to construct unit test cases within the src/test folder using JUnit. To test the state of your entities without drawing, implement a simple loop that will update the state of each object but not draw the entity. CourseNana.COM

Ensure your test cases cover over 90% of execution paths (Use jacoco in your gradle build) average of branches and instructions. Ensure your test cases cover common cases. Ensure your test cases cover edge cases. Each test case must contain a brief comment explaining what it is testing. To generate the testing code coverage report with gradle using jacoco, run “gradle test jacocoTestReport”. CourseNana.COM

Design, Report, UML and Javadoc (3%) CourseNana.COM

You will need to submit a report that elaborates on your design. This will include an explanation of any object-oriented design decisions made (such as reasons for interfaces, class hierarchy, etc) and an explanation of how the extension has been implemented. This should be no longer than 500 words. This report will be submitted through Canvas. CourseNana.COM

You will need to submit a UML diagram in PDF form to Canvas to provide a brief graphical overview of your code design and use of Object Oriented Principles such as inheritance and interfaces. Markers will use this to determine whether you have appropriately used those principles to aid you in your design, as well as figure out whether more should have been done. A general guideline is that markers will be looking for some use of inheritance or interfaces, how extensible the code is, and penalising repeated code. Note that you should not simply use a UML generator from an IDE such as Eclipse, as they typically do not produce diagrams that conform to the format required. We suggest using software such as LucidChart or draw.io for making your diagrams. CourseNana.COM

Your code should be clear, well commented and concise. Try to utilise OOP constructs within your application and limit repetitive code. The code should follow the conventions set out by the Google Java Style Guide. As part of your comments, you will need to create a Javadoc for your program. This will be properly covered in week 11 but the relevant Oracle documentation can be found here. CourseNana.COM

Report, UML and OO design: 2% Javadoc, comments, style and readability: 1% CourseNana.COM

Extension (2%) CourseNana.COM

Implement an extension as described above. Partial marks may be awarded if you choose a more limited extension or it is partially completed. Please specify what extension you decided to implement within your report, and show it during your demo in week 12. CourseNana.COM

Suggested Timeline CourseNana.COM

Here is a suggested timeline for developing the project. Note that it is released on September 10 (start of week 7) and due October 20 (end of week 11). CourseNana.COM

Week 7: Familiarise yourself with gradle and processing, utilising the processing Javadoc and week 8 supplementary lecture. Identify opportunities to utilise Object Oriented Design principles such as inheritance and interfaces and begin to plan a design for the codebase with regards to the classes that you will need to make. Make a rough UML diagram for your design that you can base your codebase from. CourseNana.COM

Week 8: Begin writing the actual code for the program. Start small, for example by initially creating the level layouts and tiles, then gradually add more like balls and spawners. At the end of the week, you should have loading in the map and ball movement finished, as well as some sprite management. If confident, use Test Driven Development (writing test cases at same time as writing the code). Conduct a large amount of user testing to ensure the initial mechanics work as expected.
CourseNana.COM

Weeks 9-10: Develop more gameplay features, such as the collision handling, player drawn lines, ball spawning and scores. Sprite management should be streamlined at this point. You should have a fairly high code coverage for your test cases at this stage. If you are noticing any questionable design decisions, such as God classes or classes that are doing things they logically should not be doing, this is the time to refactor your code. Think about what extension you want to make and start to implement it. CourseNana.COM

Week 11: Finish developing the remaining features for your program, notably the configuration file, GUI enhancements, timers and level progression. Additionally, finish writing your testing suite. Create the UML and Javadoc for the program. Fix any remaining bugs that your code exhibits. Submit your code to Ed (by uploading the entire project and pressing MARK) and submit your UML to Canvas in PDF form. CourseNana.COM

Week 12: Demonstrate the completed program to your tutor during the week 12 lab. They will check each criteria item has successfully been completed, and may ask you questions about how you implemented it to test your understanding. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Sydney代写,INFO1113代写,COMP9003代写,Object-Oriented Programming代写,OOP代写,Sydney代编,INFO1113代编,COMP9003代编,Object-Oriented Programming代编,OOP代编,Sydney代考,INFO1113代考,COMP9003代考,Object-Oriented Programming代考,OOP代考,Sydneyhelp,INFO1113help,COMP9003help,Object-Oriented Programminghelp,OOPhelp,Sydney作业代写,INFO1113作业代写,COMP9003作业代写,Object-Oriented Programming作业代写,OOP作业代写,Sydney编程代写,INFO1113编程代写,COMP9003编程代写,Object-Oriented Programming编程代写,OOP编程代写,Sydneyprogramming help,INFO1113programming help,COMP9003programming help,Object-Oriented Programmingprogramming help,OOPprogramming help,Sydneyassignment help,INFO1113assignment help,COMP9003assignment help,Object-Oriented Programmingassignment help,OOPassignment help,Sydneysolution,INFO1113solution,COMP9003solution,Object-Oriented Programmingsolution,OOPsolution,