120 lines
2.6 KiB
Java
120 lines
2.6 KiB
Java
package org.artisanlogiciel.games.maze;
|
|
|
|
/*
|
|
|
|
2x2 Tile to represent a labyrinth position with some walls
|
|
|
|
this is 2x2 downright most part of 3x3 centered tile.
|
|
|
|
center right
|
|
down downright
|
|
|
|
ab
|
|
cd
|
|
|
|
a is 'H' or '.' or ' '
|
|
bcd is within 'H' or ' '
|
|
|
|
*/
|
|
public class Brick
|
|
{
|
|
|
|
public final static short LEFT = 1;
|
|
public final static short DOWN = 2;
|
|
public final static short RIGHT = 4;
|
|
public final static short UP = 8;
|
|
public final static short ENTRY = 16;
|
|
public final static short GOAL = 32;
|
|
|
|
char a;
|
|
char b;
|
|
char c;
|
|
char d;
|
|
short walls; // according to LabyModel.getWalls();
|
|
|
|
public Brick(char center, char right, char down, char downright, short walls)
|
|
{
|
|
a = center;
|
|
b = right;
|
|
c = down;
|
|
d = downright;
|
|
this.walls = walls;
|
|
}
|
|
|
|
public Brick(String up, String low, short walls)
|
|
{
|
|
a = up.charAt(0);
|
|
b = up.charAt(1);
|
|
c = low.charAt(0);
|
|
d = low.charAt(1);
|
|
this.walls = walls;
|
|
}
|
|
|
|
private boolean check()
|
|
{
|
|
// Not Yet Implemented
|
|
return false;
|
|
}
|
|
|
|
public String getUpString()
|
|
{
|
|
return "" + a + b;
|
|
}
|
|
|
|
public String getLowString()
|
|
{
|
|
return "" + c + d;
|
|
}
|
|
|
|
public static String getDirLine()
|
|
{
|
|
char dir[] = new char[16];
|
|
String s = "";
|
|
|
|
/*
|
|
* dir[LEFT | DOWN | RIGHT | UP]='O'; dir[LEFT | DOWN | RIGHT]='U';
|
|
* dir[LEFT | UP | RIGHT]='M'; dir[LEFT | UP | DOWN]='['; dir[RIGHT | UP
|
|
* | DOWN]=']'; dir[UP | DOWN]='='; dir[LEFT | RIGHT]='|'; dir[RIGHT |
|
|
* DOWN]='J'; dir[LEFT | DOWN]='L'; dir [LEFT | UP]='T'; dir[UP |
|
|
* RIGHT]='7'; dir[LEFT] = '!'; dir[RIGHT] ='|'; dir[DOWN]= '_';
|
|
* dir[UP]= '¨'; dir[0]=' ';
|
|
*/
|
|
|
|
dir[LEFT | DOWN | RIGHT | UP] = 'O';
|
|
dir[LEFT | DOWN | RIGHT] = 'U';
|
|
dir[LEFT | UP | RIGHT] = 'M';
|
|
dir[LEFT | UP | DOWN] = '[';
|
|
dir[RIGHT | UP | DOWN] = ']';
|
|
dir[UP | DOWN] = '=';
|
|
dir[LEFT | RIGHT] = 226;
|
|
dir[RIGHT | DOWN] = 'J';
|
|
dir[LEFT | DOWN] = 'L';
|
|
dir[LEFT | UP] = 169;
|
|
dir[UP | RIGHT] = 170;
|
|
dir[LEFT] = 173;
|
|
dir[RIGHT] = '|';
|
|
dir[DOWN] = '_';
|
|
dir[UP] = '¨';
|
|
dir[0] = ' ';
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
{
|
|
s = s + dir[i];
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
public char getChar()
|
|
{
|
|
// return getDirLine().charAt(walls & 0xFFF0);
|
|
return getDirLine().charAt(walls);
|
|
}
|
|
|
|
public short getWalls()
|
|
{
|
|
return walls;
|
|
}
|
|
}
|