Tuesday, 29 January 2013

Most Recent Update

Have completed movement around the map and am working on an inventory system.
Main.Java:
import
java.util.*;
 
 
public
class Main {
public static void main(String[] args){
Item GameItems[][] =
new Item[5][5];{
GameItems[0][0] =
new Item();
GameItems[0][1] =
new Item();
GameItems[0][2] =
new Item();
GameItems[0][3] =
new Item();
GameItems[0][4] =
new Item();
GameItems[1][0] =
new Item();
GameItems[1][1] =
new Item();
GameItems[1][2] =
new Item();
GameItems[1][3] =
new Item();
GameItems[1][4] =
new Item();
GameItems[2][0] =
new Item();
GameItems[2][1] =
new Item();
GameItems[2][2] =
new Item();
GameItems[2][3] =
new Item();
GameItems[2][4] =
new Item();
GameItems[3][0] =
new Item();
GameItems[3][1] =
new Item();
GameItems[3][2] =
new Item();
GameItems[3][3] =
new Item();
GameItems[3][4] =
new Item();
GameItems[4][0] =
new Item();
GameItems[4][1] =
new Item();
GameItems[4][2] =
new Item();
GameItems[4][3] =
new Item();
GameItems[4][4] =
new Item();
}
int x;
int y;
String userinput;
Scanner Input =
new Scanner(System.in);
Boolean moved;
int InventorySpace;
Item Inventory[] =
new Item[10];
Item Blank =
new Item(0, false);
for(int i=0; i< 9 ; i++){
Inventory[i] = Blank;
}
Room[][] Rooms =
new Room[5][5];{
Rooms[0][0] =
new Room(1, true, true, false, false, "The Entrance Chamber");
Rooms[0][1] =
new Room(2, true, true, false, false, "The Main Hall");
Rooms[0][2] =
new Room(3, true, true, false, false, "The Pantry");
Rooms[0][3] =
new Room(4, true, true, false, false, "The Boudoire");
Rooms[0][4] =
new Room(5, true, true, false, false, "The Kitchen");
Rooms[1][0] =
new Room(6, true, true, false, false, "The Scullery");
Rooms[1][1] =
new Room(7, true, true, false, false, "The Throne Room");
Rooms[1][2] =
new Room(8, true, true, false, false, "The Toilet");
Rooms[1][3] =
new Room(9, true, true, false, false, "The Trophy Room");
Rooms[1][4] =
new Room(10, true, true, false, false, "The Dining Chamber");
Rooms[2][0] =
new Room(11, true, true, false, false, "The Bedrooms");
Rooms[2][1] =
new Room(12, true, true, false, false, "The Jousting Room");
Rooms[2][2] =
new Room(13, true, true, false, false, "The Garden");
Rooms[2][3] =
new Room(14, true, true, false, false, "The Fountain");
Rooms[2][4] =
new Room(15, true, true, false, false, "The Fishing Hut");
Rooms[3][0] =
new Room(16, true, true, false, false, "The Courtyard");
Rooms[3][1] =
new Room(17, true, true, false, false, "The Library");
Rooms[3][2] =
new Room(18, true, true, false, false, "The Hidden Chamber");
Rooms[3][3] =
new Room(19, true, true, false, false, "The Basement");
Rooms[3][4] =
new Room(20, true, true, false, false, "The Torture Chamber");
Rooms[4][0] =
new Room(21, true, true, false, false, "The Basement 2");
Rooms[4][1] =
new Room(22, true, true, false, false, "The Treasure Room");
Rooms[4][2] =
new Room(23, true, true, false, false, "The Annex Of Doom");
Rooms[4][3] =
new Room(24, true, true, false, false, "The Chamber Of Awakening");
Rooms[4][4] =
new Room(25, true, true, false, false, "The End Room");
}
 
InventorySpace = 0;
x = 0;
y = 0;
System.
out.print("Press N to move north, W for west, S for South and E for East");
System.
out.println();
System.
out.print("To pickup an Item in the room type in 'pickup'");
System.
out.println();
System.
out.print("At any time press help to display the help message");
while((true)){
moved=
false;
System.
out.println();
System.
out.print("You are currently in " + Rooms[x][y].RmName);
System.
out.println();
userinput = Input.next();
userinput = userinput.toUpperCase();
if(userinput.equals("N")){
if(Rooms[x][y].North == true){
y++;
System.
out.print("Player Moved North");
moved =
true;
}
}
if(userinput.equals("S")){
if(Rooms[x][y].South == true){
y--;
System.
out.print("Player Moved South");
moved =
true;
}
}
if(userinput.equals("W")){
if(Rooms[x][y].West == true){
y++;
System.
out.print("Player Moved North");
moved =
true;
}
}
if(userinput.equals("E")){
if(Rooms[x][y].East == true){
x++;
System.
out.print("Player Moved East");
moved =
true;
}
}
if(moved==false){
System.
out.print("");
System.
out.print("You cannot go that way");
}
}
}
}

Rooms.Java:
public
class Room {
int RmNo;
Boolean
North;
Boolean
East;
Boolean
South;
Boolean
West;
String
RmName;
Item
RmItem;
public Room(int number, Boolean N, Boolean E, Boolean S, Boolean W, String name, Item RmItem){
this.RmNo = number;
this.North = N;
this.South = S;
this.East = E;
this.West = W;
this.RmName = name;
this.RmItem = RmItem;
}
}

Item.Java:
public
class Item {
Boolean
usable;
int weight;
String
name;
public Item(int weight, Boolean usable, String name){
this.usable = usable;
this.weight = weight;
this.name = name;
}
}

Wednesday, 16 January 2013

Inventory

Inventory System Working

I have designed an Algorithim to pick up Items from the game world using an ItemMap similar to the game map but storing Items not rooms.

if(UserInput.equals("PICKUP")){
    int i =0;
     while(ItemTaken == false){
      if(inventory[i].Name.equals("Empty")){
       inventory[i].Name = ItemMap[x][y].Name;
       inventory[i].Usable = ItemMap[x][y].Usable;
       ItemMap[x][y].Name = "Empty";
       ItemMap[x][y].Usable = false;
       ItemTaken = true;
      }else i++;
      }                   
  }

Wednesday, 14 November 2012

Filling A 2-D Array with a Self Defined Room Class


I have just filled the 2-D Array that is store my map with different rooms. The rooms are defined in a Room Class which can be seen bellow as well as the code for the filling of the 2-D Array. As of yet I am having trouble accesing the data from these rooms. :(


public class Room {
 int RmNo;
 Boolean North;
 Boolean East;
 Boolean South;
 Boolean West;
 String RmName;

 public Room(int number, Boolean N, Boolean E, Boolean S, Boolean W, String name){

 int RmNo = number;
 Boolean North = N;
 Boolean East = E;
 Boolean South = S;
 Boolean West = W;
 String RmName = name;
 
 }
}



public class GlobalDataStore {
 public static Room[][] Rooms = new Room[5][5];{

 Rooms[1][1] = new Room(1, true, true, false, false, "Entrance Chamber");
 Rooms[1][2] = new Room(2, true, true, false, false, "Main Hall");
 Rooms[1][3] = new Room(3, true, true, false, false, "Pantry");
 Rooms[1][4] = new Room(4, true, true, false, false, "Boudoire");
 Rooms[1][5] = new Room(5, true, true, false, false, "Kitchen");
 Rooms[2][1] = new Room(6, true, true, false, false, "Scullery");
 Rooms[2][2] = new Room(7, true, true, false, false, "Throne Room");
 Rooms[2][3] = new Room(8, true, true, false, false, "Toilet");
 Rooms[2][4] = new Room(9, true, true, false, false, "Trophy Room");
 Rooms[2][5] = new Room(10, true, true, false, false, "Dining Chamber");
 Rooms[3][1] = new Room(11, true, true, false, false, "Bedrooms");
 Rooms[3][2] = new Room(12, true, true, false, false, "Jousting Room");
 Rooms[3][3] = new Room(13, true, true, false, false, "Garden");
 Rooms[3][4] = new Room(14, true, true, false, false, "Fountain");
 Rooms[3][5] = new Room(15, true, true, false, false, "Fishing Hut");
 Rooms[4][1] = new Room(16, true, true, false, false, "Courtyard");
 Rooms[4][2] = new Room(17, true, true, false, false, "Library");
 Rooms[4][3] = new Room(18, true, true, false, false, "Hidden Chamber");
 Rooms[4][4] = new Room(19, true, true, false, false, "Basement");
 Rooms[4][5] = new Room(20, true, true, false, false, "Torture Chamber");
 Rooms[5][1] = new Room(21, true, true, false, false, "Basement 2");
 Rooms[5][2] = new Room(22, true, true, false, false, "Treasure Room");
 Rooms[5][3] = new Room(23, true, true, false, false, "Annex Of Doom");
 Rooms[5][4] = new Room(24, true, true, false, false, "Chamber Of Awakening");
 Rooms[5][5] = new Room(25, true, true, false, false, "End Room");
}
}

Tuesday, 16 October 2012

Project Specification

Just handed in my project specification which includes:
- Scope And Boundaries
- Resources Required   
-Inputs, Processes And Outputs
-Feasability Study
-Comparison Of Programming Environments
- My Proposed User Interface
- A List Of Data Structures
Now going to continue reading Java and planning my code.


Tuesday, 4 September 2012

Project Proposal

Project Proposal


My project will be an adventure game where the player will navigate a series of rooms represented by a 2-D Array. The main objective of the game will to reach the boss room where they will battle a boss like creature (possibly randomly generated). After the boss room there will be a series of 'bonus' rooms sorted according to the difficulty (level) of each monster present in the room (will be randomly generated). The battles will be done via a function or procedure which I will right which will affect variable such as: Player Health, Player Energy, Enemy Health, Enemy Energy etc.

The program will either be presented in a completely text based format e.g. a C++ Console Program, A visual basic Interface where the main output will be in text but there will still be various buttons and GUI elements for the user to interact with or possibly coded in Java with a full GUI with moving sprites and background.