Treasure Game

Hey guys I'm pretty new to java. I need to make a game based on a grid 12 x 12. Uncovering a tile on the grid will either reveal a piece of treasure or nothing. Each piece of treasure is worth a certain amount of points and can take up several spaces on the grid.

Now like I said I'm not that brilliant with java, I don't even know where to start.

I presume the best way to do this would be using a 2d array.

So far I have

publicclass Board{

int grid [][] =newint [12][12];

privatestaticfinalint Row = 12;

privatestaticfinalint Column = 12;

privatestaticfinalint RowHeight = 50;

privatestaticfinalint ColumnWidth = 50;

What I need to do is be able to randomise the pices of treasure each time a new game is started. I have no idea how to do this. So far my code for the treasure looks like this.

publicclass Treasure{

publicfinalint EMPTY = 0;//No treasure found at this location

publicfinalint RING = 1;//Ring found at this locational

publicfinalint SWORD = 2;//Diamond encrusted

publicfinalint STATUE = 3;//Gold statue found at this locationsword found at this location

publicfinalint CHEST = 4;//Treasure chest found at this location

publicfinalint ORIENTATION_UP = 0;//Treasure orientation up

publicfinalint ORIENTATION_RIGHT = 1;//Treasure orientation right

publicfinalint ORIENTATION_DOWN = 2;//Treasure orientation down

publicfinalint ORIENTATION_LEFT = 3;//Treasure orientation left

privateint type;//Integer variable to track type

privateint orientation;//Integer variable to track orientation

privateint column;//Integer variable to track column

privateint row;//Integer variable to track row

privateint area;//Integer variable to track size of treasure

private Treasure(int TreasureType,int dir,int row,int col,int length){

this.type = TreasureType;

this.orientation = dir;

this.column = col;

this.row = row;

this.area = area;

Am i going along the right lines? A pointer in the right direction would be incredibly helpful.

Thanks for any help

[4913 byte] By [jmascisa] at [2007-11-26 13:22:09]
# 1

Youre Board class should look more like this:

public class Board {

private static final int Row = 12;

private static final int Column = 12;

private static final int RowHeight = 50;

private static final int ColumnWidth = 50;

int grid [][] = new int [Row][Column];

//...

}

For the Treasure class, you could create several subclasses representing each type of treasure, but what you have can work too.

CaptainMorgan08a at 2007-7-7 17:52:47 > top of Java-index,Other Topics,Java Game Development...
# 2
Wow, how random.I got set the same thing except mine needs to be an 8x7 grid...
IfAllElseFailsa at 2007-7-7 17:52:47 > top of Java-index,Other Topics,Java Game Development...