MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / intersectionArea

Method intersectionArea

engine/src/entity.cpp:373–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373float Entity::intersectionArea(StaticObject* pobj)
374{
375 float x11 = position.x + leftPadding;
376 float y11 = position.y + bottomPadding;
377 float x12 = position.x + size.x - rightPadding;
378 float y12 = position.y + size.y - topPadding;
379 float x21 = pobj->position.x;
380 float y21 = pobj->position.y;
381 float x22 = pobj->position.x + pobj->size.x;
382 float y22 = pobj->position.y + pobj->size.y;
383
384 float x_overlap = std::max(0.0f, std::min(x12, x22) - std::max(x11, x21));
385 float y_overlap = std::max(0.0f, std::min(y12, y22) - std::max(y11, y21));
386
387 return x_overlap * y_overlap;
388}
389
390Player::Player()
391{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected