One of the most basic AI processes involves moving an AI actor around in a physical environment. To do this, we will create a queue of waypoints. Each waypoint represents the next position we want our actor to move to.
Execute the following code:
#import "GameWaypoint.h" @interface GameActor : GameObject { NSMutableArray *waypoints; float runSpeed; } @end @implementation GameActor -(void) processWaypoints { bool removeFirstWaypoint = NO; //The actor's position onscreen CGPoint worldPosition = CGPointMake(self.body->GetPosition().x * PTM_RATIO, self.body->GetPosition().y * PTM_RATIO); //Process waypoints for(GameWaypoint *wp in waypoints){ float distanceToNextPoint = [GameHelper distanceP1:worldPosition toP2:CGPointMake(wp.position.x, wp.position.y)]; //If we didn't make progress to the next point, increment timesBlocked...