9 package micropolisj.engine;
11 import static micropolisj.engine.TileConstants.*;
21 static int [] Cx = { 0, 16, 0, -16 };
22 static int [] Cy = { -16, 0, 16, 0 };
23 static int [] Dx = { 0, 4, 0, -4, 0 };
24 static int [] Dy = { -4, 0, 4, 0, 0 };
25 static int [] TrainPic2 = { 1, 2, 1, 2, 5 };
26 static final int TRA_GROOVE_X = 8;
27 static final int TRA_GROOVE_Y = 8;
29 static final int FRAME_NORTHSOUTH = 1;
30 static final int FRAME_EASTWEST = 2;
31 static final int FRAME_NW_SE = 3;
32 static final int FRAME_SW_NE = 4;
33 static final int FRAME_UNDERWATER = 5;
35 static final int DIR_NORTH = 0;
36 static final int DIR_EAST = 1;
37 static final int DIR_SOUTH = 2;
38 static final int DIR_WEST = 3;
39 static final int DIR_NONE = 4;
44 this.
x = xpos * 16 + TRA_GROOVE_X;
45 this.
y = ypos * 16 + TRA_GROOVE_Y;
55 frame = TrainPic2[this.dir];
59 if (city.acycle % 4 == 0) {
61 x = (
x/16) * 16 + TRA_GROOVE_X;
62 y = (
y/16) * 16 + TRA_GROOVE_Y;
63 int d1 = city.PRNG.nextInt(4);
64 for (
int z = d1; z < d1 + 4; z++) {
66 if (this.dir != DIR_NONE) {
67 if (d2 == (this.dir + 2) % 4)
71 int c =
getChar(this.
x + Cx[d2], this.
y + Cy[d2]);
72 if (((c >= RAILBASE) && (c <= LASTRAIL)) ||
76 if ((this.dir != d2) && (this.dir != DIR_NONE)) {
77 if (this.dir + d2 == 3)
78 this.
frame = FRAME_NW_SE;
80 this.
frame = FRAME_SW_NE;
83 this.
frame = TrainPic2[d2];
86 if ((c == RAILBASE) || (c == (RAILBASE+1))) {
88 this.
frame = FRAME_UNDERWATER;
94 if (this.dir == DIR_NONE) {