COMP1040 Assignment 2 COMP1040 Programming Fundamentals Assignment 2 Prepared by Michael Ulpen August 2017 CONTENTS Introduction...

This assignment is to complete a small game code there are 11 classes ready and the required one are 5 classes to complete, my recomindation is to make the code 100% like theSpecification please.Kind Regards


COMP1040 Assignment 2 COMP1040 Programming Fundamentals Assignment 2 Prepared by Michael Ulpen August 2017 CONTENTS Introduction ........................................................................................................................................................................ 1 GameEngine1 Provided Classes 1 engine.GameEngine1 engine.interfaces.IPaintable....................................................................................................................................... 1 engine.interfaces.IUpdatable2 engine.Game2 engine.math.Vector2D2 engine.math.BoundingBox2 UML Diagram3 EcoSim4 Provided Classes4 ecosim.game.Main4 ecosim.world.Tile4 ecosim.world.GrassTile4 ecosim.world.SandTile4 ecosim.entity.Entity4 ecosim.entity.GrassTuft4 Required Classes5 ecosim.game.EcoSim5 ecosim.entity.Animal5 ecosim.entity.Wombat6 ecosim.entity.Snake6 ecosim.exception.OutOfBoundsException7 Source Code Documentation7 UML Diagram8 How To Start9 Additions9 Submission Details10 Extensions and Late Submissions10 Academic Misconduct11 Marking Criteria11 INTRODUCTION This document describes Assignment 2 for Programming Fundamentals. The assignment will require you to write classes to represent Animals and Plants in an ecosystem simulator, called EcoSim. This will be a graphical application, utilizing your own classes and code with help from a provided game engine. You will be required to demonstrate the use of arrays, inheritance, polymorphism and exception handling. This document outlines how to use the game engine. Documentation for the game engine may be found in Javadoc format, written as comments in the source code and organized into html files in the doc folder. This document also provides instructions for how to complete the ecosystem simulator. This assignment is an individual task that will require an individual submission. You will be required to submit this project in week 12 of the study period. In the case that you do not fully understand the assignment, please ask your lecturer. GAMEENGINE The assignment files include a GameEngine which will automatically handle graphics, input and object updates. Part of the assignment is learning how to use the provided GameEngine to create a graphical application. There are many classes in the GameEngine and many methods in those classes. You will need to read the source code documentation to get a full understanding of how to use them. Provided Classes The following is a summary of some of the important classes that have been provided… engine.GameEngine GameEngine manages a resizable array of IPaintable, IUpdatable and ICollidable objects. It also manages the Keyboard, Mouse, GraphicsWindow and Game objects. All methods in the GameEngine are static, which means they can be accessed from anywhere without constructing a GameEngine object. The following is a list of the most important static methods in the GameEngine: · GameEngine.loadGame(Game g) Calls that game's load method and makes the window visible. It then starts the GameEngine update and paint loops. · GameEngine.add(Object o) If the object is an IPaintable, ICollidable and/or IUpdatable, it will be added to the GameEngine's array and will automatically be painted and updated. · GameEngine.addToBackground(IPaintable p) If the object is an IPaintable, ICollidable and/or IUpdatable, it will be added to the GameEngine's background and will automatically be updated and painted behind other IPaintables. · GameEngine.remove(Object o) If the object has been added to the GameEngine it will be removed. · GameEngine.getGameObjs() Returns all game objects in the GameEngine's array. · GameEngine.getGameObjs(String classPath) Returns all objects in the GameEngine's array that are instances of the argument classPath. The classPath must be fully qualified, including the package path. For example, getGameObjs("ecosim.entity.Wombat") will return all the Wombat objects in the GameEngine. engine.interfaces.IPaintable The IPaintable interface has one method, paint(Graphics g). The Entity and Tile classes implement IPaintable and already have a suitable paint method. 1 of 11 engine.interfaces.IUpdatable The IUpdatable interface has one method, update(long millisElapsed). Entity implements the IUpdatable interface and you will have to write your own update method. This method will be called automatically by the GameEngine 60 times per second. engine.Game Game is an abstract class including the following abstract methods: · loadKeyFunctions() Creates executable functions and binds them to Keyboard keys. · loadMouseFunctions() Creates executable functions and binds them to Mouse buttons. · loadImages() Calls ImageLibrary.load(String alias, String imagePath) for each image in the assets folder. · getWinWidth() Returns the width of the game window. · getWinHeight() Returns the height of the game window. · update(long millisElapsed) Updates the state of the game. Any code that should be executed 60 times a second should be added here. The above methods will have to be implemented in any class that derives from Game. Game has one non static method, load(), which will automatically call loadImages(), loadMouseFunctions() and loadKeyFunctions(). engine.math.Vector2D A Vector2D contains x and y coordinates. It can be interpreted as a point in space or a direction with an origin. The Vector2D contains the following methods: · add(Vector2D other) Adds the argument x to this x and the argument y to this y. · subtract(Vector2D other) Subtracts the argument x from this x and the argument y from this y. · scale(float scale) Multiplies both the x and y by the argument scale. · normalize() Divides the x and y components by the Vector's length. The result is a Vector with a length of 1, also known as a unit vector. · distance(Vector2D other) Returns the distance between this Vector and the argument Vector. engine.math.BoundingBox A BoundingBox contains a position, as a Vector2D, and a width and height. The position is the top left point of the box. It contains the following methods: · move(Vector2D movement) Adds the argument vector to this object's position. · distance(BoundingBox other) Returns the distance between this BoundingBox's position and the argument's position. · contains(Vector2D point) Returns true if the given point is inside this BoundingBox. · intersects(BoundingBox other) Returns true if any corner point in the argument is inside this BoundingBox. 2 of 11 2 of 11 3 of 11 UML Diagram The following UML diagram is a summary of most of the classes and methods in the engine package. You will need to read the source code documentation to get a full understanding of each class and the methods therein. Note that any underlined methods are static and any methods in italics are abstract. Note that this diagram does not follow the rules of UML exactly. If you are confused by the diagram please ask your lecturer. 3 of 11 ECOSIM EcoSim attempts to simulate the relationship between predators and prey in the environment. Each animal will have to find food to survive. If they survive for long enough they will reproduce to create more animals. Some animals eat other animals. Some animals eat plants. In this assignment our animals will be wombats and snakes. The snakes will eat the wombats, the wombats will eat grass. The wombats will breed faster than the snakes but will have to eat more to stay alive. You will need to complete the ecosim package and add its game objects to the GameEngine. In this assignment, you will have to define five classes. You will need to define the Animal, Wombat and Snake classes. You will also need to define the EcoSim and OutOfBoundsException classes. You have been provided some complete classes to get you started. These include Main, Entity, GrassTuft, Tile, SandTile and GrassTile. Provided Classes The following classes have been provided for you… ecosim.game.Main Main is the starting point of the program. It constructs an EcoSim object and adds it to the GameEngine. Execute the main method in the Main class to start the EcoSim application. ecosim.world.Tile Tile contains a BoundingBox and a BufferedImage. Tile implements IPaintable so it has a paint method which will paint its image to its bounding box position. Tiles will be created and arranged into a grid. This will act as a background image and determine the area in which the Wombats and Snakes are allowed to move. Once added to the GameEngine, using GameEngine.addToBackground(tile), it will automatically be painted to the screen and will appear behind images added on top of it. It also contains the constants Tile.WIDTH and Tile.HEIGHT which should be used as the width and height of every Tile. ecosim.world.GrassTile GrassTile extends from Tile. GrassTufts are only allowed to be created in the same position as a GrassTile. GrassTiles should be added to the GameEngine background. ecosim.world.SandTile SandTile extends from Tile. A GrassTuft
Jan 12, 2020COMP 1040University Of South Australia
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here