437 |
V2 f; |
V2 f; |
438 |
GridPos p((int)x[0], (int)x[1]); |
GridPos p((int)x[0], (int)x[1]); |
439 |
|
|
440 |
if (a->is_on_floor()) |
if (a->is_on_floor()) { |
441 |
{ |
if (Floor *floor = GetFloor(p)) { |
442 |
if (Floor *floor = GetFloor(p)) |
double friction; |
443 |
{ |
|
444 |
// Mouse force |
// Mouse force |
445 |
f += floor->process_mouseforce(a, level->mouseforce.get_force(a)); |
if (a->has_spikes()) { |
446 |
|
f += level->mouseforce.get_force(a) * 1.0; |
447 |
|
friction = 1.0; |
448 |
|
} |
449 |
|
else { |
450 |
|
f += floor->process_mouseforce(a, level->mouseforce.get_force(a)); |
451 |
|
friction = floor->friction(); |
452 |
|
} |
453 |
|
|
454 |
// Friction |
// Friction |
455 |
double vv=length(v); |
double vv=length(v); |
456 |
if (vv > 0) { |
if (vv > 0) { |
457 |
V2 frictionf = v * enigma::FrictionFactor*floor->friction(); |
V2 frictionf = v * enigma::FrictionFactor*friction; |
458 |
frictionf /= vv; |
frictionf /= vv; |
459 |
frictionf *= pow(vv, 0.8); |
frictionf *= pow(vv, 0.8); |
460 |
f -= frictionf; |
f -= frictionf; |
461 |
} |
} |
462 |
|
|
463 |
f += floor->get_force(a); |
f += floor->get_force(a); |
464 |
} |
} |
465 |
|
|
466 |
if (Item *item = GetItem(p)) |
if (Item *item = GetItem(p)) { |
|
{ |
|
467 |
f += item->get_force(a); |
f += item->get_force(a); |
468 |
} |
} |
469 |
} |
} |