Lab 5 And 6

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Lab 5 And 6 as PDF for free.

More details

  • Words: 887
  • Pages: 3
Laboration 5 and 6

Dungeons and Dragons The labs of Dungeons and Dragons is based on the design example showed on OOD lecture 3. Make sure that you understand this lecture first. This lab had more classes than the design example because the lab also handles the Graphical User Interface to control the game. (The classes DungeonsAndDragons, GameFrame, GamePanel and StatusFrame). The classes from OOD Lecture 3 is located in the dungeonsanddragons.model package and its sub packages. Note that the class Bottle from the lecutre is now called AidKit instead! Make sure that read all instructions carefully and that you do task 1, task 2 and task 3 before the lab!!

Task 1 To start with, download the dungeons and dragons project from Moodle and open it in Netbeans.

Task 2 Generate the documentation for the project. Do this by choose “Build” and the “Generate javadoc for dungeons and dragons”. The generated documentation shall appear automatically, if not go to your project directory and then go into dist\javadoc and then double click the file “index.html”

Task 3 Go through the generated javadoc from Task 2 and read about the classes and the methods.

Task 4 Complete all methods in the player class. The method calculateTotalPoints is called when the game ends to get a total point for that round (based on the current state of the player) . You can descide by your own how the points shall be calculated. The method is probably the move method that shall make the player move through the correct door. When the user presses and releases a key on the keyboard the method keyReleased in the GamePanel class will be called (already fixed by me). The method isMoving checks if it is any of the arrow keys that is pressed (also fixed). If that is the case the player shall be moved (if there is a door in that direction). The move method of the Player class is used to check for doors and move the player. And you shall implement that method!

To help here is some pseudo code for the move method: //Declare a reference to a Door object in which you can save the door to move through //Check if it is the key code for any of the left arrow keys //In that case we shall save the west door of the current room //Otherwise, check if it is the key code for any of the right arrow keys //In that case we shall save the east door of the current room //Otherwise, check if it is the key code for any of the up arrow keys //In that case we shall save the north door of the current room //Otherwise, check if it is the key code for any of the down arrow keys //In that case we shall save the south door of the current room //if we found a door to go through //Let the player walk through it //Return the door (may be null, if there was no door in that direction)

The method isMoving of the GamePanel class can give you a hint of how to check which key that a keycode corresponds to. The documentation of the KeyEvent class can also be helpful: http://java.sun.com/javase/6/docs/api/java/awt/event/KeyEvent.html

Task 5 Measure the time from the board is created until the game is ended. If the player won the game the time shall be showed in the message dialog that is showed in the method endGame Tips: The code class java.util.Date will help you with this. Create a date object representing the start date as attribute in the class. When the game has ended you can create another Date object representing the end date and then you can take the differences in time between those objects. You will get the result in milliseconds.

Task 6 Add sounds to the monsters and to the player. Make sure that monster sounds are played when the player gets bitten and make sure that the sound of the player is played every time he kills a monster. Only wav-files will work as sounds. You are encouraged to create your own sounds.

Task 7 Create a new Monster of your own choice. Create a new class to represent the monster and put the class in the package dungeonsanddragons.model.monsters. Use a

picture of your own choice. Also make sure that the new monster appears on the gaming board.

Task 8 Create a new Weapon of your own choice. Create a new class to represent the weapon and put the class in the package dungeonsanddragons.model.weapons. Use a picture of your own choice to represent the weapon. Also make sure that the new weapon appears once on the gaming board and that the new weapon is useful to kill your new monster.

Task 9 Improve the method calculateTotalPoints to take into consideration the time measured in task 5. You can decide on your own how the points shall be calculated but the a fast (short time) game shall give the player better total points. Let the total time be input to the method.

Task 10 (optional) Implement a high score list that is written to file. Make sure that you read the high score file again next time the game starts up. Let the high score be represented by a class called “HighScore”.

Related Documents

Lab 5 And 6
November 2019 8
Lab 6
June 2020 12
Lab 6
October 2019 18
Lab 6
April 2020 12
6 Lab
June 2020 9
6. Lab
June 2020 10