XX University XX University

Department of Computer Science and Software Engineering SWEN20003 Object-Oriented Software Development Department of Computer Science and Software Engineering SWEN20003 Object-Oriented Software Development

Overview of the overview

Welcome to the first project of SWEN20003! We will use the oil slide library for Java’s, which can be found at http://slick.ninjacave.com/ . The 5th week of the seminar introduced the slick, if you have problems getting started Please REFER to AT at The at The the Tutorial at The the Table. This IS A separate Project in English . by by You CAN Talk to OTHER Students, But All Implementations at The the MUST BE your own Work . IS the Available for Purchase To AT At The First Project of SWEN20003! We By Will use at The the Java Slick Library of at The CAN In http://slick.ninjacave.com/ found .The 5th week of the seminar introduced the slick, if you have problems getting started, please refer to the tutorial table. This is a separate project in English . You can talk to other students, but all implementations must be your own work .

Project 2 will be expanded and built on Project 1 to create a complete game, so it’s important to write your submission so that it can beFyre extended . Below is a screenshot of the game after completing PROJECT1. Project 2 will be expanded and built on Project 1 to create a complete game, so it’s important to write your submission so that it can beFyre extended . Below is a screenshot of the game after completing PROJECT1.

Shadow the Build

Earlier versions of Shadow the Build included A Large the tile-based Map that Could BE Explored, AS Well AS A Reconnaissance Unit that Could BE Moved ON The Map. Only A Small Portion of The Map around The Reconnaissance Plane IS displayed AT the any GIVEN Time. Earlier Between of Shadow Build included a large tile-based map that could be explored, as well as a reconnaissance unit that could be moved on the map. Only a small portion of the map around the reconnaissance plane is displayed at any given time .

Game game

Below I will outline the different game elements you need to implement. Below I will outline the different game elements you need to implement.

Tile map tile map

Game homepage Homepage Homepage Homepage Homepage Homepage English- based tile-based . Each tile is 64 pixels wide and 64 pixels high, and the background is constructed from a collection of these tiles. The game’s homepage homepage homepage homepage background English- based block-based . Each of The The pixels 64 and the IS 64 The pixels Wide High the tile, and background of A of The Collection of The Constructed from the IS THESE Tiles.

Slick has some built-in objects and methods to handle this. You should use the documentation for the TiledMap class to understand how to use the assets/main.tmx file to create and draw the background map.

Tiles can have properties . To find the property associated with a given coordinate, you should first find the tile ID                     corresponding to that location. Tiled maps can have several layers, but the

renren.LI

Map you will be using has only one layer (in one dex 0). Once you have found the ID, you can find the

Corresponding property.

The tiled map you will be using has only one property: solid. This can have the value true, indicating that the tile should not be moved through, or false, indicating the tile can be moved through.

The player

The main character of the game is the player , represented by the image

For now, the player simply moves around the screen. When the user right clicks on the screen, the player should move in a straight line towards the location of the click at a rate of 0.25 pixels per millisecond. When the player is within 0.25 pixels Of their destination, they should stop moving.

If the player would move into a solid tile, the player should instead stop moving.

Some hints for calculating movement

You will need to use some trigonometry to calculate the correct movement in each frame. We

Recommend using the Math.atan2 function, which will give you the angle from (0,0) to the position described by its arguments, respecting quadrants correctly.

The camera

The tiled map is far too large to fit on the screen all at once. You should therefore only show a subset of it, defined to be 1024×768 pixels. This should be handled by an abstract “camera”, which stores which part of the map Is currently in view. T h e camera should be able to move so that the player stays in the middle of the screen, unless the player moves close to an edge of the map.

If the player moves close to an edge, the camera should stop moving once there is no more map left to view. In this way, the player should never be able to move o↵ the map.

The “how” of this functionality is up to you. We recommend using a class to store the relevant data, and calculate transformations from screen coordinates to world (map) coordinates.

Slick concepts

This section aims to clarify some common mistaken assumptions students make about the Slick engine, as well as to outline some important concepts.

A Slick game works according to the game loop . Dozens of times each second, a frame of the game is processed. In a frame, the following happens:

1. The game is updated by calling the update() method. The number of milliseconds since the last frame is passed as the argument delta; this value can be used to make sure objects move at the same speed no matter how fast the game is Running.

2. The game is rendered by calling the render() method. To do this, the entire screen is cleared so it displays only black; that way, no images from the previous frame can be seen. Images can only be drawn inside this method .

The number of frames that are processed each second is called the frames per second , or FPS. Di↵erent computers will likely have a di↵erent value for FPS., it is important to make sure your update() method works the same Way Regardless of this value.

In Slick, positions are given as pairs of ( x, y ) coordinates called pixels . Note that (0 , 0) is the top-left of the window; the y direction is therefore the opposite of what you may be used to from mathematics Keep in mind that while only integer locations can be rendered, it may make sense to store positions as floating-point values. For the purposes of this document, positions are given from the centre of the image .

A terminology note: an image with a defined position in the world that can move around or perform some other action is often called a sprite .

Your code

The skeleton we have provided has these three classes.

App – The outer layer of the game. Inherits from Slick’s BasicGame class. Starts up the game, handles the update and render methods, and passes them along to World.

World – Represents everything in the game, including the background and all sprites. For now, this is just the tiled map and the player.

Camera – Represents the subset of the world that can actually be viewed. It should be able to follow a particular sprite, so that di↵erent sections of the world can be viewed at di↵erent times. This class may need to do some Calculations on behalf of other classes.

You will likely find that creating more classes will make the project easier. This decision is up to you as a software engineer! Make sure your code follows object-oriented principles like abstraction and encapsulation.

Implementation checklist

This project may seem daunting. As there are a lot of things you need to implement, we have provided a checklist, ordered roughly in the order we think you should implement them in:

Draw the tiled map on the screen

2. Draw the player on the screen

3. Allow the player to move around the screen

4. Prevent the player from moving through solid tiles

5. Allow the camera to follow the player

The supplied package

You will be given a package, oosd-project1-package.zip, which contains all of the graphics and other files you need to build the game. You can use these in any way you want. Here is a brief summary of its contents:

src/ – The supplied source code.

App.java – A complete class which starts up the game and handles input and rendering.

World.java – A file with stub methods for you to fill in.

Camera.java – A file with stub methods for you to fill in.

assets/ – The images for the game.

credit.txt – The source for each of the images included.

main.tmx – The tiled map data.

planet.tsx – The image data for the tiled map. You do not need to explicitly use this file.

scout.png – The image for the player character.

Sub program and marking Technical 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 Slick library.

The program must compile fully without errors.

Please Will through the Take Place at The Submission LMS. Please ZIP your Project Folder in the ITS entirety, the this and the Submit .zip File. The Do not the Submit A .rar, .7z, .tar.gz, or the any OTHER of the type of Compressed Folder. ESPECIALLY do not Submit one of these files that has simply been renamed to have a .zip extension, as then we will be unable to open your file. 1

Ensure all your code is contained in this folder. We will provide a link on the LMS to the appropriate submission page closer to the due date.

Good Coding Style

Good 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.

You should be taking care to ensure proper use of visibility modifiers. unless you have a very good reason for it, all instance variables should be private.

Any constant should be defined as a static final variable. Don’t use magic numbers!

Think about whether your code makes assumptions about things that are likely to change for Project 2.

Make sure each class makes sense as a cohesive whole. A class should contain all of the data and methods relevant to its purpose.

Extensions and late submissions

If you need an extension for the project, please email Eleanor at mcmurtrye@unimelb.edu.au explaining your situation with some supporting documentation (medical certificate, academic ad- justment 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 7:00pm sharp . Any submissions received past this time (from 7:01pm onwards) will be studied 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 with your student ID so that we can ensure your late submission is marked correctly.

Marks Project 1 is worth 8 marks out of the total 100 for the subject. Features implemented correctly – 4 marks

Map is drawn correctly:      1  mark 1This may sound ridiculous, but it has happened several times in the past!

Player moves correctly: 1 mark

Camera follows player: 1 mark

Player cannot move through solid tiles: 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 complex methods ( 1 mark )

Cohesion – classes are complete units that contain all their data ( 1 mark )

Code style – Visibility modifier, consistent indentation, missing magic number, comment ( 1 code style – visibility modifier, consistent indentation, missing magic number, comment ( 1 point ) points )