This commit is contained in:
Joel 2020-05-10 21:07:03 +02:00
parent c17adf52cd
commit e4d2086bf9
3 changed files with 9 additions and 7 deletions

View File

@ -5,7 +5,7 @@ class HandleRotation
{
int rotationSpeed = 5, Rotation = 180;
private float oldSpeed, movementSpeed;
private Vector2 oldTile;
private Vector2 oldTile, oldPosition;
public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position, Crops crops)
{
@ -14,7 +14,7 @@ class HandleRotation
{
Position = new Vector2((int)Math.Round(Position.X), (int)Math.Round(Position.Y));
}
if (Destination == 0)
if (Destination == 0) // down
{
if (Rotation == 0)
{
@ -37,7 +37,7 @@ class HandleRotation
}
}
}
else if (Destination == 1)
else if (Destination == 1) // up
{
if (Rotation == 180)
{
@ -57,7 +57,7 @@ class HandleRotation
}
}
else if (Destination == 2)
else if (Destination == 2) // right
{
if (Rotation == 270)
{
@ -80,7 +80,7 @@ class HandleRotation
}
}
}
else if (Destination == 3)
else if (Destination == 3) // left
{
if (Rotation == 90)
{
@ -105,6 +105,7 @@ class HandleRotation
}
oldSpeed = crops.getSpeedFactor(tractorSpeed);
oldPosition = Position;
return Position;
}

View File

@ -32,7 +32,7 @@ class Tractor
Spacing = input.getSpacing();
Position = housePos;
TargetPosition = new Vector2(house.X, house.Y);
smartTractor.init();
smartTractor.init(new Vector2(house.X, house.Y));
}
// Runs when the tractor reaches a tile

View File

@ -46,9 +46,10 @@ class SmartTractor
}
public void init()
public void init(Vector2 nHousePos)
{
ai.init();
housePos = nHousePos;
farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize), housePos / (tileSize + Spacing));
}