Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void nextPosition () {
- int cx = humans[targetId]->x - x;
- int cy = humans[targetId]->y - y;
- int dist2 = distance2(*humans[targetId]);
- // If the distance is less or equal to zombie speed then nextX takes the value of human X and nextY takes the value of human Y
- if (dist2 < ZOMBIE_SPEED_SQUARED) {
- x = humans[targetId]->x;
- y = humans[targetId]->y;
- }
- else {
- float distanceCoeff = ZOMBIE_SPEED / distance(dist2);
- x += cx * distanceCoeff;
- y += cy * distanceCoeff;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement