首页 > 其他分享 >INFO1113 / COMP9003 a prototype of the game

INFO1113 / COMP9003 a prototype of the game

时间:2024-10-12 17:22:27浏览次数:7  
标签:ball level game will COMP9003 INFO1113 balls prototype your

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:

  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:

标签:ball,level,game,will,COMP9003,INFO1113,balls,prototype,your
From: https://www.cnblogs.com/comp9313/p/18460533

相关文章

  • singlleton 的 bean 中注入 prototype 的bean
    在Spring中,prototypeBean注入prototypeBean和singletonBean注入prototypeBean是两个典型的场景,尤其在多线程、状态管理等复杂系统中,会有不同的行为和注意事项。1.prototypeBean中注入prototypeBean当一个prototypeBean注入另一个prototypeBean时,每次获......
  • 原型模式(Prototype Pattern)
    原型模式是一种创建型设计模式,使用克隆方法来复制现有对象,从而避免重复的初始化操作,特别适用于创建重复对象的场景。适用场景:当一个系统需要创建新对象的对象系统中,可通过克隆一个原型并对其进行改造。当对象的创建成本比较大(如复杂的初始化)时。示例代码:abstractclassSha......
  • [Javascript] Function.prototype.call
    .callmethodexitsonanyfunction,whichwillreferto Function.prototype.callforexample:console.log.call===Function.prototype.call//call AlsoitmeansthatFunction.prototype.call===Function.prototype.call.call Question:console.log.call.cal......
  • js中两种设置子类原型(prototype)来实现原型式继承的本质区别
    在JavaScript中,这两种设置子类(Child)原型(prototype)的方法虽然都能实现继承的基本功能,但它们之间存在一些重要的区别和潜在的陷阱。1. Child.prototype=Object.create(Parent.prototype);这个方法使用Object.create()来创建一个新对象,其原型(__proto__)被设置为Parent.prototy......
  • 设计模式-原型模式(Prototype)
    设计模式-原型模式(Prototype)  概要   记忆关键词:原型实例、拷贝  定义:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。    分析:原型模式就是从一个样板对象中复制出一个内部属性一致的对象。它是在内存中拷贝二进制流,比new一个对象的性能好很......
  • js/ts prototype最简单且深刻的理角
    最关健的二点:1.js任何对象(函数也是对象)都有__proto__私有属性,有的可能会显示[[Prototype]](chorme浏览器),代码直接访问属性会报错,但可以正常运行的。__proto__只是另一个对象的引用(一般是类型对象,也可以修改)。2.只有函数对象Function才有.prototype属性,它本身就是一个对象,给......
  • JavaScript prototype(原型对象)
     所有的JavaScript对象都会从一个prototype(原型对象)中继承属性和方法。在前面的章节中我们学会了如何使用对象的构造器(constructor):实例functionPerson(first,last,age,eyecolor){this.firstName=first;this.lastName=last;this.age=age;this.eye......
  • 网上 copy 的一段 javascript 代码 String.prototype.replaceAll = fucntion(){...}
    早些年,浏览器没有内置字符串的replaceAll()方法,就从网上copy了一段replaceAll()的实现:String.prototype.replaceAll=function(AFindText,ARepText){raRegExp=newRegExp(AFindText,"g");returnthis.replace(raRegExp,ARepText)}今天突然遇到一个问题,定位到了这段代码,我......
  • How to use JavaScript BigInt and Number.prototype.toString to handle the super l
    HowtouseJavaScriptBigIntandNumber.prototype.toStringtohandlethesuperlargeintegerproblemsAllInOne如何使用JavaScriptBigInt和Number.prototype.toStringg处理超大整数问题errorsfunctionplusOne(digits:number[]):number[]{letn=parseI......
  • 可视化理解constructor、prototype、__proto__形成的指向图
    Person类和person实例首先给出一段js代码:functionPerson(){}constperson=newPerson()根据以下规则:每个实例都有一个__proto__指向其原型对象。每个构造函数都有一个prototype属性指向其实例的原型对象每一个原型都有一个prototype指向其实例的构造函数。于是就......