summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/Main.cs')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/Main.cs28
1 files changed, 19 insertions, 9 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/Main.cs b/Pathfinding Visualizer/Assets/Scripts/Main.cs
index 018ce33..a146859 100644
--- a/Pathfinding Visualizer/Assets/Scripts/Main.cs
+++ b/Pathfinding Visualizer/Assets/Scripts/Main.cs
@@ -16,7 +16,12 @@ public class Main : MonoBehaviour
void Start()
{
// Create world
- world = new LogicGrid(100, 100, 5f, new Vector3(-110, -110));
+ int width = 100;
+ int height = 100;
+ float cellSize = 5f;
+ Vector3 origin = new Vector3(-110, -110);
+
+ world = new LogicGrid(width, height, cellSize, origin);
// Set default placement to Obstacle
placementValue = 1;
@@ -28,11 +33,16 @@ public class Main : MonoBehaviour
}
- // Update is called once per frame
- void Update()
+ public void StartAStar()
{
- // Change Placement Modes:
+ AStar astar = new AStar(world, 0);
+ }
+ // Update contains keyboard shortcut options
+ void Update()
+ {
+ // Change Placement Mode Keyboard Shortcuts:
+ ////////////////////////////////
// Place Obstacle in grid
if (Input.GetKeyDown("o"))
{
@@ -59,15 +69,16 @@ public class Main : MonoBehaviour
{
ResetGrid();
}
-
+ //////////////////////////
+
// Update Cell:
- // Change cell to obstacle
+ // Place value in cell based on selected placementValue with left click
if (Input.GetMouseButton(0))
{
world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), placementValue);
}
- // Clear cell
+ // Clear cell with right click
if (Input.GetMouseButton(1))
{
world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), 0);
@@ -79,7 +90,6 @@ public class Main : MonoBehaviour
}
-
public void SetModeObstacle()
{
placementValue = 1;
@@ -96,5 +106,5 @@ public class Main : MonoBehaviour
{
world.reset();
}
-
+
}