Compare commits
2 Commits
101dedca7f
...
f040ccfb01
Author | SHA1 | Date | |
---|---|---|---|
f040ccfb01 | |||
5e7c8ee240 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.vscode/launch.json
|
@ -1,2 +1,108 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
Console.WriteLine("Hello, World!");
|
||||
using System;
|
||||
|
||||
namespace meise
|
||||
{
|
||||
public class Game
|
||||
{
|
||||
|
||||
static void Main()
|
||||
{
|
||||
Map mapInstance = new Map();
|
||||
Armeise armeise = new Armeise();
|
||||
mapInstance.DrawMap(armeise.posX, armeise.posY);
|
||||
|
||||
armeise.Move(2);
|
||||
mapInstance.DrawMap(armeise.posX, armeise.posY);
|
||||
armeise.TurnRight();
|
||||
armeise.Move(2);
|
||||
mapInstance.DrawMap(armeise.posX, armeise.posY);
|
||||
}
|
||||
}
|
||||
|
||||
public class Map
|
||||
{
|
||||
public int sizeY = 10;
|
||||
public int sizeX = 10;
|
||||
|
||||
// Draws map line by line, replacing the V wit A if ant there
|
||||
public void DrawMap(int armeiseX, int armeiseY)
|
||||
{
|
||||
for (int i = 0; i <= sizeY; i++)
|
||||
{
|
||||
for (int j = 0; j <= sizeX; j++)
|
||||
{
|
||||
if (i == armeiseY && j == armeiseX)
|
||||
{
|
||||
Console.Write('A');
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write('V');
|
||||
}
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
public class Armeise
|
||||
{
|
||||
public int posY { get; set; }
|
||||
public int posX { get; set; }
|
||||
public Directions directionFacing { get; set; }
|
||||
// Enum to have it obviousè what way turning
|
||||
public enum Directions
|
||||
{
|
||||
North,
|
||||
East,
|
||||
South,
|
||||
West
|
||||
}
|
||||
|
||||
public Armeise(int x = 0, int y = 0)
|
||||
{
|
||||
posX = x;
|
||||
posY = y;
|
||||
directionFacing = Directions.East;
|
||||
}
|
||||
|
||||
public void MoveRandom(int borderX, int borderY)
|
||||
{
|
||||
int minMove = 2;
|
||||
int maxMove = 6;
|
||||
int test = 3;
|
||||
}
|
||||
|
||||
public void Move(int steps)
|
||||
{
|
||||
switch (directionFacing)
|
||||
{
|
||||
case Directions.North:
|
||||
posY -= steps;
|
||||
break;
|
||||
case Directions.East:
|
||||
posX += steps;
|
||||
break;
|
||||
case Directions.South:
|
||||
posY += steps;
|
||||
break;
|
||||
case Directions.West:
|
||||
posX -= steps;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Using enums to make turning easier like this
|
||||
// Prevents ant from doing a U turn in one move
|
||||
public void TurnRight()
|
||||
{
|
||||
directionFacing++;
|
||||
}
|
||||
public void TurnLeft()
|
||||
{
|
||||
directionFacing--;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("armeisen")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+101dedca7f0000a6490be72536deb2859167f446")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("armeisen")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("armeisen")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
51e59712bef259c72b49cb0b8857cb2a433b277e97cec2a297c5379ed31f59a7
|
||||
aac56502c0079c943a87f6e8bae7d11cd21b0cc50bca17a7839d69eedffc7240
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user