Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!ground && !onladder) {
- double dis = vel.speed()*double(delta)/1000;
- //Iterate through all footholds
- for (auto i = footholds.begin(); i != footholds.end(); i++) {
- auto other = *i;
- if (!other->walk && group!=other->group) {continue;}
- double a1 = angdif(vel.direction(), other->dir);
- if (a1 <= 0) {continue;}
- double a2 = angdif(vel.direction(), pdir(x, y, other->x1, other->y1));
- if (a2 >= 0) {continue;}
- double a3 = angdif(vel.direction(), pdir(x, y, other->x2, other->y2));
- if (a3 <= 0) {continue;}
- double d1 = pdis(xprev, yprev, other->x1, other->y1);
- double a4 = angdif(other->dir+90, pdir(xprev, yprev, other->x1, other->y1));
- double d2 = ldx(d1, a4);
- if (d2<0) {continue;}
- if (d2 <= dis) {
- if (downjump && downjump->group == other->group) {
- downjump = 0;
- continue;
- }
- ground = other;
- dis = d2;
- }
- }
- //Deal with the foothold of interest
- if (ground) {
- //double a5 = angdif(ground->dir+90, vel.direction());
- //double d3 = dis/ldx(1, a5);
- x = xprev+ldx(dis, vel.direction());
- y = yprev+ldy(dis, vel.direction());
- vel.limit(ground->dir);
- if (ground->walk) {
- x = max(min(x, ground->x2-0.1), ground->x1+0.1);
- }
- group = ground->group;
- if (z[1] != ground->layer) {
- z[1] = ground->layer;
- resort = true;
- }
- }
- }
Add Comment
Please, Sign In to add comment