Ejemplo n.º 1
0
bool KyraEngine_v2::directLinePassable(int x, int y, int toX, int toY) {
	Screen *scr = screen();

	while (x != toX || y != toY) {
		int facing = getFacingFromPointToPoint(x, y, toX, toY);
		x += _addXPosTable[facing];
		y += _addYPosTable[facing];
		if (!scr->getShapeFlag1(x, y))
			return false;
	}

	return true;
}
Ejemplo n.º 2
0
int KyraEngine_v1::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) {
	// only used for debug specific code
	//static uint16 unkTable[] = { 8, 5 };
	static const int8 facingTable1[] = {  7,  0,  1,  2,  3,  4,  5,  6,  1,  2,  3,  4,  5,  6,  7,  0 };
	static const int8 facingTable2[] = { -1,  0, -1,  2, -1,  4, -1,  6, -1,  2, -1,  4, -1,  6, -1,  0 };
	static const int8 facingTable3[] = {  2,  4,  4,  6,  6,  0,  0,  2,  6,  6,  0,  0,  2,  2,  4,  4 };
	static const int8 addPosTableX[] = { -1,  0, -1,  4, -1,  0, -1, -4, -1, -4, -1,  0, -1,  4, -1,  0 };
	static const int8 addPosTableY[] = { -1,  2, -1,  0, -1, -2, -1,  0, -1,  0, -1,  2, -1,  0, -1, -2 };

	// debug specific
	/*++unkTable[start];
	while (screen()->getPalette(0)[unkTable[start]] != 0x0F) {
		++unkTable[start];
	}*/

	int xpos1 = x, xpos2 = x;
	int ypos1 = y, ypos2 = y;
	int newFacing = getFacingFromPointToPoint(x, y, toX, toY);
	int position = 0;

	while (position != end) {
		int newFacing2 = newFacing;
		while (true) {
			changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]);
			if (!lineIsPassable(xpos1, ypos1)) {
				if (facingTable1[start*8 + newFacing2] == newFacing)
					return 0x7D00;
				newFacing2 = facingTable1[start*8 + newFacing2];
				xpos1 = x;
				ypos1 = y;
				continue;
			}
			newFacing = facingTable1[start*8 + newFacing2];
			break;
		}
		// debug drawing
		/*if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) {
			screen()->setPagePixel(0, xpos1, ypos1, unkTable[start]);
			screen()->updateScreen();
			delayWithTicks(5);
		}*/
		if (newFacing & 1) {
			int temp = xpos1 + addPosTableX[newFacing + start * 8];
			if (toX == temp) {
				temp = ypos1 + addPosTableY[newFacing + start * 8];
				if (toY == temp) {
					moveTable[position++] = facingTable2[newFacing + start * 8];
					return position;
				}
			}
		}

		moveTable[position++] = newFacing;
		x = xpos1;
		y = ypos1;

		if (x == toX && y == toY)
			return position;

		if (xpos1 == xpos2 && ypos1 == ypos2)
			break;

		newFacing = facingTable3[start*8 + newFacing];
	}

	return 0x7D00;
}