Flipped up and down in code
This commit is contained in:
@@ -132,11 +132,11 @@ namespace Marro.PacManUdon
|
|||||||
if (startState == PacManGhostStartState.TargetingIdlePosition1)
|
if (startState == PacManGhostStartState.TargetingIdlePosition1)
|
||||||
{
|
{
|
||||||
SetOffGridTarget(idlePosition1, false);
|
SetOffGridTarget(idlePosition1, false);
|
||||||
SetTargetDirection(Direction.Up);
|
SetTargetDirection(Direction.Down);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetTargetDirection(Direction.Down);
|
SetTargetDirection(Direction.Up);
|
||||||
}
|
}
|
||||||
ghostState = PacManGhostState.Entering;
|
ghostState = PacManGhostState.Entering;
|
||||||
OffGridTargetReached();
|
OffGridTargetReached();
|
||||||
|
|||||||
@@ -24,20 +24,20 @@ namespace Marro.PacManUdon
|
|||||||
public readonly Vector2[] directionVectors =
|
public readonly Vector2[] directionVectors =
|
||||||
{
|
{
|
||||||
Vector2.zero, // 0
|
Vector2.zero, // 0
|
||||||
Vector2.down, // 1
|
Vector2.up, // 1
|
||||||
Vector2.up, // 2
|
Vector2.down, // 2
|
||||||
Vector2.zero, // 3
|
Vector2.zero, // 3
|
||||||
Vector2.left, // 4
|
Vector2.left, // 4
|
||||||
Vector2.down + Vector2.left, // 5
|
Vector2.up + Vector2.left, // 5
|
||||||
Vector2.up + Vector2.left, // 6
|
Vector2.down + Vector2.left, // 6
|
||||||
Vector2.left, // 7
|
Vector2.left, // 7
|
||||||
Vector2.right, // 8
|
Vector2.right, // 8
|
||||||
Vector2.down + Vector2.right, // 9
|
Vector2.up + Vector2.right, // 9
|
||||||
Vector2.up + Vector2.right, // 10
|
Vector2.down + Vector2.right, // 10
|
||||||
Vector2.right, // 11
|
Vector2.right, // 11
|
||||||
Vector2.zero, // 12
|
Vector2.zero, // 12
|
||||||
Vector2.down, // 13
|
Vector2.up, // 13
|
||||||
Vector2.up, // 14
|
Vector2.down, // 14
|
||||||
Vector2.zero, // 15
|
Vector2.zero, // 15
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,11 +122,11 @@ namespace Marro.PacManUdon
|
|||||||
{
|
{
|
||||||
if (vertical < 0)
|
if (vertical < 0)
|
||||||
{
|
{
|
||||||
return Direction.Up;
|
return Direction.Down;
|
||||||
}
|
}
|
||||||
if (vertical > 0)
|
if (vertical > 0)
|
||||||
{
|
{
|
||||||
return Direction.Down;
|
return Direction.Up;
|
||||||
}
|
}
|
||||||
return Direction.Zero;
|
return Direction.Zero;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,37 +69,37 @@ namespace Marro.PacManUdon
|
|||||||
// Jagged or 2D arrays can't be static so we work with 1D arrays
|
// Jagged or 2D arrays can't be static so we work with 1D arrays
|
||||||
public static byte[] GetMazeCollisionInfo() => new byte[]
|
public static byte[] GetMazeCollisionInfo() => new byte[]
|
||||||
{
|
{
|
||||||
192, 192, 192, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 192, 192, 192,
|
192, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 192, 192, 192,
|
||||||
192, 192, 200, 010, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 014, 076, 076, 014, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 006, 196, 192, 192,
|
192, 192, 200, 009, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 013, 076, 076, 013, 076, 076, 076, 076, 076, 076, 076, 076, 076, 076, 005, 196, 192, 192,
|
||||||
192, 192, 200, 067, 133, 193, 193, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 193, 193, 137, 067, 196, 192, 192,
|
192, 192, 200, 067, 134, 194, 194, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 194, 194, 138, 067, 196, 192, 192,
|
||||||
192, 192, 200, 067, 134, 194, 194, 194, 194, 192, 192, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 192, 192, 194, 194, 194, 194, 138, 067, 196, 192, 192,
|
192, 192, 200, 067, 133, 193, 193, 193, 193, 192, 192, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 192, 192, 193, 193, 193, 193, 137, 067, 196, 192, 192,
|
||||||
192, 192, 200, 009, 076, 014, 076, 076, 006, 196, 200, 010, 076, 076, 005, 196, 200, 009, 076, 076, 006, 196, 200, 010, 076, 076, 014, 076, 005, 196, 192, 192,
|
192, 192, 200, 010, 076, 013, 076, 076, 005, 196, 200, 009, 076, 076, 006, 196, 200, 010, 076, 076, 005, 196, 200, 009, 076, 076, 013, 076, 006, 196, 192, 192,
|
||||||
192, 192, 192, 193, 137, 067, 133, 137, 067, 196, 200, 067, 133, 193, 193, 192, 192, 193, 193, 137, 067, 196, 200, 067, 133, 137, 067, 133, 193, 192, 192, 192,
|
192, 192, 192, 194, 138, 067, 134, 138, 067, 196, 200, 067, 134, 194, 194, 192, 192, 194, 194, 138, 067, 196, 200, 067, 134, 138, 067, 134, 194, 192, 192, 192,
|
||||||
192, 192, 192, 194, 138, 067, 196, 200, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 196, 200, 067, 134, 194, 192, 192, 192,
|
192, 192, 192, 193, 137, 067, 196, 200, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 196, 200, 067, 133, 193, 192, 192, 192,
|
||||||
192, 192, 200, 010, 076, 005, 196, 200, 011, 076, 076, 013, 076, 076, 030, 076, 076, 030, 076, 076, 013, 076, 076, 007, 196, 200, 009, 076, 006, 196, 192, 192,
|
192, 192, 200, 009, 076, 006, 196, 200, 011, 076, 076, 014, 076, 076, 029, 076, 076, 029, 076, 076, 014, 076, 076, 007, 196, 200, 010, 076, 005, 196, 192, 192,
|
||||||
192, 192, 200, 067, 133, 193, 192, 200, 067, 133, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 137, 067, 196, 192, 193, 137, 067, 196, 192, 192,
|
192, 192, 200, 067, 134, 194, 192, 200, 067, 134, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 138, 067, 196, 192, 194, 138, 067, 196, 192, 192,
|
||||||
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 194, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 194, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
|
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 193, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 193, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
|
||||||
192, 192, 200, 009, 076, 076, 076, 076, 015, 076, 076, 014, 076, 076, 005, 196, 200, 009, 076, 076, 014, 076, 076, 015, 076, 076, 076, 076, 005, 196, 192, 192,
|
192, 192, 200, 010, 076, 076, 076, 076, 015, 076, 076, 013, 076, 076, 006, 196, 200, 010, 076, 076, 013, 076, 076, 015, 076, 076, 076, 076, 006, 196, 192, 192,
|
||||||
192, 192, 192, 193, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 192, 192, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 193, 192, 192, 192,
|
192, 192, 192, 194, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 192, 192, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 194, 192, 192, 192,
|
||||||
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
|
||||||
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 011, 076, 076, 076, 076, 076, 076, 076, 076, 007, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
|
||||||
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
||||||
194, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 194,
|
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 011, 076, 076, 076, 076, 076, 076, 076, 076, 007, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
||||||
108, 108, 108, 108, 108, 108, 108, 076, 015, 076, 076, 007, 196, 192, 192, 192, 192, 192, 192, 200, 011, 076, 076, 015, 076, 108, 108, 108, 108, 108, 108, 108,
|
|
||||||
193, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 193,
|
|
||||||
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
||||||
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 009, 076, 076, 030, 076, 076, 030, 076, 076, 005, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
193, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 193,
|
||||||
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 192, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 192, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
108, 108, 108, 108, 108, 108, 108, 076, 015, 076, 076, 007, 196, 192, 192, 192, 192, 192, 192, 200, 011, 076, 076, 015, 076, 108, 108, 108, 108, 108, 108, 108,
|
||||||
192, 192, 192, 194, 194, 194, 194, 138, 067, 196, 192, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 192, 200, 067, 134, 194, 194, 194, 194, 192, 192, 192,
|
194, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 196, 192, 192, 192, 192, 192, 192, 200, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 194,
|
||||||
192, 192, 200, 010, 076, 076, 076, 076, 007, 196, 200, 010, 076, 076, 005, 196, 200, 009, 076, 076, 006, 196, 200, 011, 076, 076, 076, 076, 006, 196, 192, 192,
|
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
||||||
192, 192, 200, 067, 133, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 192, 192, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 137, 067, 196, 192, 192,
|
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 200, 010, 076, 076, 029, 076, 076, 029, 076, 076, 006, 196, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
||||||
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
|
192, 192, 192, 192, 192, 192, 192, 200, 067, 196, 192, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 192, 200, 067, 196, 192, 192, 192, 192, 192, 192, 192,
|
||||||
192, 192, 200, 011, 076, 076, 076, 076, 015, 076, 076, 013, 076, 076, 014, 076, 076, 014, 076, 076, 013, 076, 076, 015, 076, 076, 076, 076, 007, 196, 192, 192,
|
192, 192, 192, 193, 193, 193, 193, 137, 067, 196, 192, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 192, 200, 067, 133, 193, 193, 193, 193, 192, 192, 192,
|
||||||
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
|
192, 192, 200, 009, 076, 076, 076, 076, 007, 196, 200, 009, 076, 076, 006, 196, 200, 010, 076, 076, 005, 196, 200, 011, 076, 076, 076, 076, 005, 196, 192, 192,
|
||||||
|
192, 192, 200, 067, 134, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 192, 192, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 138, 067, 196, 192, 192,
|
||||||
|
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 193, 193, 193, 193, 137, 067, 133, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
|
||||||
|
192, 192, 200, 011, 076, 076, 076, 076, 015, 076, 076, 014, 076, 076, 013, 076, 076, 013, 076, 076, 014, 076, 076, 015, 076, 076, 076, 076, 007, 196, 192, 192,
|
||||||
|
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 194, 194, 194, 138, 067, 134, 138, 067, 134, 194, 194, 194, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
|
||||||
192, 192, 200, 067, 196, 192, 192, 200, 067, 196, 192, 192, 192, 200, 067, 196, 200, 067, 196, 192, 192, 192, 200, 067, 196, 192, 192, 200, 067, 196, 192, 192,
|
192, 192, 200, 067, 196, 192, 192, 200, 067, 196, 192, 192, 192, 200, 067, 196, 200, 067, 196, 192, 192, 192, 200, 067, 196, 192, 192, 200, 067, 196, 192, 192,
|
||||||
192, 192, 200, 067, 134, 194, 194, 138, 067, 134, 194, 194, 194, 138, 067, 196, 200, 067, 134, 194, 194, 194, 138, 067, 134, 194, 194, 138, 067, 196, 192, 192,
|
192, 192, 200, 067, 133, 193, 193, 137, 067, 133, 193, 193, 193, 137, 067, 196, 200, 067, 133, 193, 193, 193, 137, 067, 133, 193, 193, 137, 067, 196, 192, 192,
|
||||||
192, 192, 200, 009, 076, 076, 076, 076, 013, 076, 076, 076, 076, 076, 005, 196, 200, 009, 076, 076, 076, 076, 076, 013, 076, 076, 076, 076, 005, 196, 192, 192,
|
192, 192, 200, 010, 076, 076, 076, 076, 014, 076, 076, 076, 076, 076, 006, 196, 200, 010, 076, 076, 076, 076, 076, 014, 076, 076, 076, 076, 006, 196, 192, 192,
|
||||||
192, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 192, 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 192, 192, 192,
|
192, 192, 192, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 192, 192, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 192, 192, 192,
|
||||||
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
|
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
verticalValue = Math.Abs(value);
|
verticalValue = Math.Abs(value);
|
||||||
if (value < -0.5)
|
if (value > 0.5)
|
||||||
{
|
{
|
||||||
inputVertical = Direction.Up;
|
inputVertical = Direction.Up;
|
||||||
if (verticalValue >= horizontalValue)
|
if (verticalValue >= horizontalValue)
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
SetPriority(false);
|
SetPriority(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value > 0.5)
|
else if (value < -0.5)
|
||||||
{
|
{
|
||||||
inputVertical = Direction.Down;
|
inputVertical = Direction.Down;
|
||||||
if (verticalValue >= horizontalValue)
|
if (verticalValue >= horizontalValue)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Marro.PacManUdon.Dev
|
|||||||
map[rightTileIndex] = (int)PacManConsumableType.FruitRight;
|
map[rightTileIndex] = (int)PacManConsumableType.FruitRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrintMazeMap()
|
private static void PrintMazeMap()
|
||||||
{
|
{
|
||||||
int[] map = new int[width * height];
|
int[] map = new int[width * height];
|
||||||
var collisionMap = GetCollisionMap();
|
var collisionMap = GetCollisionMap();
|
||||||
@@ -73,7 +73,7 @@ namespace Marro.PacManUdon.Dev
|
|||||||
for (int i = 0; i < map.Length; i++)
|
for (int i = 0; i < map.Length; i++)
|
||||||
{
|
{
|
||||||
byte result = 0;
|
byte result = 0;
|
||||||
var tile = collisionMap[i];
|
var tile = GetTileAtIndex(collisionMap, i);
|
||||||
|
|
||||||
if (tile == (byte)CollisionMap.Wall)
|
if (tile == (byte)CollisionMap.Wall)
|
||||||
{
|
{
|
||||||
@@ -92,34 +92,34 @@ namespace Marro.PacManUdon.Dev
|
|||||||
|
|
||||||
result |= GetGhostTurnInformation(collisionMap, i, width, height);
|
result |= GetGhostTurnInformation(collisionMap, i, width, height);
|
||||||
|
|
||||||
map[(i % width) + (height - i / width - 1) * width] = result;
|
map[i] = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintMap(map, width);
|
PrintMap(map, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte GetGhostTurnInformation(byte[] collisionMap, int i, int width, int height)
|
private static byte GetGhostTurnInformation(byte[] collisionMap, int i, int width, int height)
|
||||||
{
|
{
|
||||||
byte result = 0;
|
byte result = 0;
|
||||||
var totalAvailableDirections = 0;
|
var totalAvailableDirections = 0;
|
||||||
if (collisionMap[GetTilemapIndex(i, Vector2.up, width, height)] != (byte)CollisionMap.Wall)
|
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.up, width, height)) != (byte)CollisionMap.Wall)
|
||||||
{
|
{
|
||||||
result |= 0b0001;
|
result |= (byte)Direction.Up;
|
||||||
totalAvailableDirections += 1;
|
totalAvailableDirections += 1;
|
||||||
}
|
}
|
||||||
if (collisionMap[GetTilemapIndex(i, Vector2.down, width, height)] != (byte)CollisionMap.Wall)
|
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.down, width, height)) != (byte)CollisionMap.Wall)
|
||||||
{
|
{
|
||||||
result |= 0b0010;
|
result |= (byte)Direction.Down;
|
||||||
totalAvailableDirections += 1;
|
totalAvailableDirections += 1;
|
||||||
}
|
}
|
||||||
if (collisionMap[GetTilemapIndex(i, Vector2.left, width, height)] != (byte)CollisionMap.Wall)
|
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.left, width, height)) != (byte)CollisionMap.Wall)
|
||||||
{
|
{
|
||||||
result |= 0b0100;
|
result |= (byte)Direction.Left;
|
||||||
totalAvailableDirections += 1;
|
totalAvailableDirections += 1;
|
||||||
}
|
}
|
||||||
if (collisionMap[GetTilemapIndex(i, Vector2.right, width, height)] != (byte)CollisionMap.Wall)
|
if (GetTileAtIndex(collisionMap, GetTilemapIndex(i, Vector2.right, width, height)) != (byte)CollisionMap.Wall)
|
||||||
{
|
{
|
||||||
result |= 0b1000;
|
result |= (byte)Direction.Right;
|
||||||
totalAvailableDirections += 1;
|
totalAvailableDirections += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,39 +132,14 @@ namespace Marro.PacManUdon.Dev
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetTilemapIndex(int index, Vector2 direction, int width, int height)
|
private static int GetTilemapIndex(int index, Vector2 direction, int width, int height)
|
||||||
{
|
{
|
||||||
var position = new Vector2(index % width, index / width) + direction;
|
var position = new Vector2(index % width, index / width) + direction;
|
||||||
position = Clamp(position, 0, width - 1, 0, height - 1);
|
var result = ((int)position.x + width) % width + ((int)position.y + height) % height * width;
|
||||||
var result = (int)position.x + (int)position.y * width;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector2 Clamp(Vector2 vector, float xMin, float xMax, float yMin, float yMax)
|
private static void PrintMap(int[] map, int width)
|
||||||
{
|
|
||||||
if (vector.x < xMin)
|
|
||||||
{
|
|
||||||
vector.x = xMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vector.x > xMax)
|
|
||||||
{
|
|
||||||
vector.x = xMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vector.y < yMin)
|
|
||||||
{
|
|
||||||
vector.y = yMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vector.y > yMax)
|
|
||||||
{
|
|
||||||
vector.y = yMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vector;
|
|
||||||
}
|
|
||||||
private void PrintMap(int[] map, int width)
|
|
||||||
{
|
{
|
||||||
var result = "";
|
var result = "";
|
||||||
for (int i = 0; i < map.Length; i++)
|
for (int i = 0; i < map.Length; i++)
|
||||||
@@ -187,6 +162,10 @@ namespace Marro.PacManUdon.Dev
|
|||||||
Debug.Log(result);
|
Debug.Log(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte GetTileAtIndex(byte[] map, int index) => map[GetUpsideDownIndex(index)];
|
||||||
|
|
||||||
|
private static int GetUpsideDownIndex(int index) => (index % width) + (height - index / width - 1) * width;
|
||||||
|
|
||||||
public static byte[] GetCollisionMap() => new byte[] {
|
public static byte[] GetCollisionMap() => new byte[] {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
|||||||
Reference in New Issue
Block a user