Advertisement
| 04.23.2008 at 06:10AM PDT, ID: 23346345 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: |
import javax.swing.JFrame;
import java.awt.GraphicsConfiguration;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class MovingTilesApp extends JFrame {
//SG_Board myBoard;
MyEnhancedBoard myBoard;
public Container contentPane;
public MovingTilesApp() {
setTitle("Labyrinth");
setVisible( true ) ;
setSize(450,300); // Any size, reset it later.
contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//Note This image is 640x480 pixels
// public SG_Board (String file_name, int buffer,
// int x0, int y0,
// int posnsWide, int posnsDown,
// int posnPixelsWide, int posnPixelsDown){
myBoard = new MyEnhancedBoard("Blank.jpg",0,0,10,8,64,60);
// Note: The image in 'Uluru.jpg' becomes the background graphic, covering
// the whole board. It will be divided into rectangles automatically, by
// default.
myBoard.setNoOfTiles(5); // Total number of playing tiles to Initialise
//setTile(int tileId, int boardCoordX,int boardCoordY,String iconName)
myBoard.setTile(1,1,1,"Cool1.jpg");
contentPane.add("Center",myBoard);
//contentPane.add();
JButton goUpButton = new JButton("Up");
JButton goDownButton = new JButton("Down");
JButton goLeftButton = new JButton("Left");
JButton goRightButton = new JButton("Right");
goUpButton.addActionListener(myBoard);
goDownButton.addActionListener(myBoard);
goLeftButton.addActionListener(myBoard);
goRightButton.addActionListener(myBoard);
contentPane.add("West",goLeftButton);
contentPane.add("East",goRightButton);
contentPane.add("North",goUpButton);
contentPane.add("South", goDownButton);
PrintMap();
resize(770,575);
show();
}
public static void main(String[] args) {
MovingTilesApp myBoardGame = new MovingTilesApp();
}
public void PrintMap()
{
for(int a=0;a<LODServer.mapHeight;a++)
{
for(int b=0;b<LODServer.mapWidth;b++)
{
switch(LODServer.map[a][b])
{ /*tileId,x,y*/
case LODServer.EMPTY : myBoard.setTile(2,a,b,"floor.jpg"); break;
case LODServer.HEALTH : myBoard.setTile(3,a,b,"health.jpg"); break;
case LODServer.LANTERN : myBoard.setTile(4,a,b,"lantern.jpg"); break;
case LODServer.SWORD : myBoard.setTile(5,a,b,"sword.jpg"); break;
case LODServer.ARMOUR : myBoard.setTile(6,a,b,"armour.jpg"); break;
case LODServer.EXIT : myBoard.setTile(7,a,b,"exit.jpg"); break;
case LODServer.WALL : myBoard.setTile(8,a,b,"wall.jpg"); break;
}
}
}
}
}
|
Advertisement