Skip to main content


By May 15, 2020留学咨询

题意:使用JAVA上的Bagel实现一个游戏解析:游戏需要以每秒60帧来运行,首先在屏幕上随机生成一系列钉子,建立正确的坐标系保证钉子生成在游戏的窗口内;生成一个小球向着鼠标的位置进行移动,当球接触到游戏窗口的左右边框时,小球的水平移动速度应该被反转,如果小球与钉子发生碰撞,钉子被销毁并从屏幕上面移除。可以创建小球类与钉子类进行实现,获取小球坐标,通过小球坐标与游戏窗口的边框位置以及钉子位置的判断完成游戏的交互功能。涉及知识点:2D数学,碰撞检测更多可加微信讨论微信号:yzr5211234pdf全文The University of MelbourneSchool of Computing and Information SystemsSWEN20003 Object Oriented Software DevelopmentProject 1, Semester 2, 2019Written by Eleanor McMurtryReleased: Friday 30th of August, 9:00pmDue: Friday 13th of September, 11:59pmOverviewWelcome to the rst project for SWEN20003! We will be using the Bagel library for Java, availableunder Projects on the LMS. Comprehensive documentation for Bagel can be found at Week 5’s workshop introduces Bagel, so refer to thetutorial sheet if you have trouble getting started. This is an individual project. You may discuss aspectsof it with other students, but all of the implementation must be your own work.Project 2 will extend and build on Project 1 to create a complete game, so it’s important to write yoursubmission in such a way that it can be easily extended. Below is a screenshot of the game after completing Project 1.This early version of Shadow Bounce includes several “pegs” and a ball that can be used to hit anddestroy the pegs. The goal of Shadow Bounce is to use the ball to destroy all of the pegs in as few shotsas possible.Background on graphics conceptsEvery coordinate on the screen is described by an (x, y) pair. (0, 0) represents the top-left of the screen,and coordinates increase towards the bottom-right. Each of these coordinates is called a pixel. TheBagel Point class encapsulates this, and additionally allows oating-point positions to be represented.60 times per second, the program’s logic is updated, the screen is cleared to a blank state, and all of thegraphics are drawn again. Each of these steps is called a frame.Often, we would like to draw moving objects. These are represented by a velocity: a pair (also calleda vector) (u_x,u_yux,uy) that represents how far the object should move each frame. Calculating the newposition can be done via vector addition of the position and velocity; Bagel contains the Vector2 classto facilitate this. You are not required to use this class; it is merely provided for convenience. Themagnitude (or length) of a vector (x, y) can be found via the formula \sqrt{x^2+y^2}x2+y2.It is sometimes useful to be able to tell when two images are overlapping. This is called collision detection and can get quite complex. For this game, you can assume images are rectangles. Bagel containsthe Rectangle class to help you.The gameBelow I will outline the dierent game elements you need to implement.The pegsThe game board is made up of a collection of pegs that appear on the screen. For this project, they willbe randomly generated. The game should choose 50 random positions on the screen with 푥 coordinatesbetween 0 and 1024, and 푦 coordinates between 100 and 768. Pegs should be drawn centred at theselocations.1The ballWhen the left mouse button is clicked, if the ball is not currently on screen, the ball should appearat the position (512, 32). It should start with a velocity towards the mouse, with a magnitude of 10pixels per frame. Each frame, the velocity should increase by 0.15 pixels per frame downwards, tosimulate gravity. When the ball’s centre reaches the left or right side of the window, the ball’s horizontalmovement should reverse so that it stays on screen. If the ball makes contact with a peg, the peg shouldbe “destroyed” and no longer displayed on screen.Your codeYou must submit a class called ShadowBounce with a main method that runs the game as describedabove. You may choose to create as many additional classes as you see t, keeping in mind the principlesof object oriented design discussed so far in the subject. You will be assessed based on your code runningcorrectly, as well as the eective use of Java concepts. As always in software engineering, appropriatecomments and variable/method/class names are important.Implementation checklistTo get you started, here is a checklist of the game features, with a suggested order for implementingthem:Draw a single peg on screenGenerate random positions and draw a peg at each of themDraw a ball on screen when the left mouse button is pressedMake the ball fall downwards over timeDetect when the ball touches pegs, and destroy the pegsMake the ball start o moving towards the mouseMake the ball “bounce” o the sides of the screenThe supplied packageYou will be given a package,, which contains all of the graphics and other les you need tobuild the game. You can use these in any way you want. Here is a brief summary of its contents:• res/ – The images for the game.– ball.png: the image for the ball object– peg.png: the image for the peg objectsSubmission and markingTechnical requirements• The program must be written in the Java programming language.• The program must not depend upon any libraries other than the Java standard library and the Bagel library (as well as Bagel’s dependencies).• The program must compile fully without errors.Submission will take place through the LMS. Please zip all of your source code into one folder andsubmit this .zip le. Do not submit a .rar, .7z, .tar.gz, or any other type of compressed folder.Especially do not submit one of these files that has simply been renamed to have a .zip extension, asthen we will be unable to open your file.2We highly encourage you to re-download and check that your submission contains all your code.Good Coding StyleGood coding style is a contentious issue; however, we will be marking your code based on the following criteria:• You should not go back and comment your code after the fact. You should be commenting as you go. (Yes, we can tell.)• You should be taking care to ensure proper use of visibility modiers. Unless you have a very good reason for it, all instance variables should be private.• Any constant should be dened as a static final variable. Don’t use magic numbers!• Think about whether your code is written to be easily extensible via appropriate use of classes.• Make sure each class makes sense as a cohesive whole. A class should have a single well-defined purpose, and should contain all the data it needs to fulfil this purpose.Extensions and late submissionsIf you need an extension for the project, please email Eleanor at [email protected] explaining your situation with some supporting documentation (medical certificate, academic adjustment plan, wedding invitation). If an extension has been granted, you may submit via the LMS as usual;please do however email Eleanor once you have submitted your project.The project is due at 11:59pm sharp. Any submissions received past this time (from 12:00am onwards) will be considered late unless an extension has been granted. There will be no exceptions. There is a penalty of 1 mark for a late project, plus an additional 1 mark per 24 hours. If you submit late, you must email Eleanor so that we can ensure your late submission is marked correctly.The distribution of marks is on the final page.MarksProject 1 is worth 8 marks out of the total 100 for the subject.• Features implemented correctly – 4 marks– Pegs are generated correctly: 1 mark– Ball appears on click: 1 mark– Ball starts moving towards the mouse and falls with gravity: 1 mark– Pegs disappear on contact with the ball: 1 mark• Code (coding style, documentation, good object-oriented principles) – 4 marks– Delegation – breaking the code down into appropriate classes (1 mark)– Use
of methods – avoiding repeated code and overly long/complex methods (1 mark)– Cohesion – classes are complete units that contain all their data (1 mark)– Code style – visibility modiers, consistent indentation, lack of magic numbers, commenting, etc. (1 mark)


Author admin

More posts by admin

Leave a Reply