Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
Billy now spawns
  • Loading branch information
AlecUrbany committed Dec 6, 2022
1 parent 0eedf12 commit c86d182
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions lab3.pde
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,69 @@ void setup() {

}

void mousePressed()
{
if (show_help) return;
PVector target = new PVector(mouseX, mouseY);
if (!map.isReachable(target)) return;
if (mouseButton == LEFT)
{

if (waypoints.size() == 0)
{
billy.seek(target);
}
else
{
//ArrayList<PVector> pathfinding = nm.findPath(waypoints.get(waypoints.size()-1), target);
//for(int i = 0; i < pathfinding.size(); i++)
//{
// waypoints.add(pathfinding.get(i));
//}
waypoints.add(target);
entering_path = false;
billy.follow(waypoints);
}
}
else if (mouseButton == RIGHT)
{
if (!entering_path){
waypoints = new ArrayList<PVector>();
//ArrayList<PVector> pathfinding = nm.findPath(billy.kinematic.position, target);
//waypoints = pathfinding;
}
else
{
print("Adding additional path");
//ArrayList<PVector> pathfinding = nm.findPath(waypoints.get(waypoints.size()-1), target);
//for(int i = 0; i < pathfinding.size(); i++)
//{
// waypoints.add(pathfinding.get(i));
//}
}
waypoints.add(target);
entering_path = true;
}
}

void keyPressed()
{
if (key == 'g')
{
map.generate(-2);
}
else if (key == 'w')
{
show_waypoints = !show_waypoints;
}
}


void draw() {
background(0);

float dt = (millis() - lastt)/1000.0;
billy.update(dt);
lastt = millis();

map.update(dt);
Expand Down

0 comments on commit c86d182

Please sign in to comment.