Due: December 9
For this part of the adventure game project you will make a GUI with tiled images for the map display. You will also implement take, drop, and inventory commands, and keep track of the locations of items in the game. As before, the main class for your program should be called Adventure. Your program should do all the commands described in previous parts of the project and do similar checks before executing commands. Also as before, your program should take a command-line parameter that tells the name of the map file to use.
Your program's GUI should have a pane for the map display, a button pane, a text field for command input, and a text area for a transcript of commands and command results. The button pane should have buttons for Quit, Save, and Open commands. You can use any layout that works well, but make sure you have a large area for the map display and for the text area.
The text area should display a transcript of commands and command results that is similar to what the player saw in Project 3. However, you don't need to show the mini map of terrain characters that you did in Project 3, because in this project you will show images for the surrounding terrain. You should display the coordinates of the character's location after every command, as you did in the previous Adventure projects. The first number should be the north-south coordinate, with larger numbers being further south, and the second number should be the east-west coordinate with larger numbers being further east.
The map file should be as before (Part 2) except that there
will be some additional information after the character terrain grid.
The first line after the terrain grid will be a line that tells the
size of each tile in the map display.
Next will be the name of a text file that tells what items are present
in squares of the map.
See the following section for more information about how the program
After the item file name will be some lines that tell which image
should be displayed for each terrain character.
The format of each terrain image line should be:
<TERRAIN CHARACTER>;<TERRAIN DESCRIPTION>;<TERRAIN
For example, the following line
indicates that a dot represents plains and should be displayed with the image MapPics/plain.png.
Here is an example of the contents of a map file:
10 12 ~~~~....MMMM ~~~....MMMM. ~~...MMMMMMM ~~~.MMMM*MMM ~~~..MMMMMMM ~~...fMMMMMM ~~.ffffMMMMM ~~..ffffff.. ~~~~fffffff. ~~~~~~~fffff 60 60 map1items.txt .;plains;MapPics/plain.png; M;mountain;MapPics/mountain.png; f;forest;MapPics/forest.png; ~;water;MapPics/water.png; *;goal;MapPics/treasure.png; -;out;MapPics/out.png; 1;person;MapPics/person.png;
The image for out-of-bounds squares will always be specified by a dash in the last section of a map file. The image for the character will be specified by the digit 1.
The character should start out at (0,0), which should be the top left corner of the map.
The map display should show a 5x5 section of the grid, with the player's location being in the center square. If the character is near the edge of the map then some out-of-bounds squares will be in the 5x5 square and should be displayed as the image specified for the terrain - (out.png in the preceding map file example).
Here is a jar file that has some pictures you can use for the map display if you'd like: mapPics.jar
Whenever the character moves into a square that contains one or more items (for instance a sword, a bag of coins, or a scroll), the program should display a message (in the text area) that tells what items are present at that location.
If the player types the command take, followed by the name of an object in the current location, that item should be moved from the location to the player's inventory. Likewise, if the player types the command drop, followed by the name of an object in the player's inventory, that item should be moved from the player's inventory to the location.
Note that for purposes of this program, an item is represented only by a string that is the item's name. In general, an item would have various attributes relating to its use by the character in the game.
The format of the item file is the location (row and column) followed by the item's name. Use a semicolon for the delimiter.
Here is an example of the contents of an item file:
2;5;a dagger; 4;7;a magic sword; 2;5;a bag of coins;
When the file is opened, the program should restore the game state from
the file, including:
-the map used for the game
-position of the player's character
-items in the player's inventory
-items in map locations
Use serialization to implement the Save and Open commands. These commands should not alter the game's map file or item file.
Set up the arrow keys to move the character on the map. The character should move north, south, east, and west for the up, down, right, and left arrows respectively.
Put your source files into a jar or zip file and turn the jar or zip file in on Canvas. The class with the program's main method should be named Adventure. Your files should not be inside a folder in the jar file, and there should not be any files other than source files, class files, and an optional README.txt file. (The files and directories that are automatically added by the jar command are okay.)
|50||Tiled images for map display|
|15||Show items at location|
|25||Save and open game|
|25||Arrow keys for moving Extra Credit|