272 |
} |
} |
273 |
|
|
274 |
BasicBall::BasicBall(const char *kind, double radius, double mass) |
BasicBall::BasicBall(const char *kind, double radius, double mass) |
275 |
: Actor(kind, V2()), state(NO_STATE) |
: Actor(kind, V2()), state(NO_STATE), |
276 |
|
sinkDepth (0) |
277 |
{ |
{ |
278 |
world::ActorInfo *ai = get_actorinfo(); |
world::ActorInfo *ai = get_actorinfo(); |
279 |
ai->radius = radius; |
ai->radius = radius; |
311 |
ActorInfo *ai = get_actorinfo(); |
ActorInfo *ai = get_actorinfo(); |
312 |
|
|
313 |
const double defaultSinkSpeed = 10.0; // 10.0 means : sink in 1 second (if absVelocity == 0) |
const double defaultSinkSpeed = 10.0; // 10.0 means : sink in 1 second (if absVelocity == 0) |
314 |
const double nonSinkVelocity = 8.0; // at this velocity don't sink; above: raise |
const double nonSinkVelocity = 6.0; // at this velocity don't sink; above: raise |
315 |
|
|
316 |
double absVelocity = sqrt(ai->vel[0]*ai->vel[0] + ai->vel[1]*ai->vel[1]); |
double absVelocity = length(ai->vel); |
317 |
double sinkSpeed = absVelocity * -(defaultSinkSpeed/nonSinkVelocity) + defaultSinkSpeed; |
double sinkSpeed = absVelocity * -(defaultSinkSpeed/nonSinkVelocity) + defaultSinkSpeed; |
318 |
|
|
319 |
sinkDepth += sinkSpeed*dtime; |
sinkDepth += sinkSpeed*dtime; |