1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2025-09-01 06:20:15 +02:00

FT collision part4: ball to ball collision.

TBall uses multiple inheritance, interesting.
This commit is contained in:
Muzychenko Andrey 2023-03-12 11:12:41 +03:00
parent f521a03322
commit c5acdcd524
15 changed files with 132 additions and 38 deletions

View file

@ -625,7 +625,7 @@ TBall* TPinballTable::AddBall(float x, float y)
{
if (BallList.size() >= 20)
return nullptr;
ball = new TBall(this);
ball = new TBall(this, -1);
BallList.push_back(ball);
}
@ -655,6 +655,16 @@ int TPinballTable::BallCountInRect(const RectF& rect)
return count;
}
int TPinballTable::BallCountInRect(const vector2& pos, float margin)
{
RectF rect{};
rect.XMin = pos.X - margin;
rect.XMax = pos.X + margin;
rect.YMin = pos.Y - margin;
rect.YMax = pos.Y + margin;
return BallCountInRect(rect);
}
void TPinballTable::EndGame_timeout(int timerId, void* caller)
{
auto table = static_cast<TPinballTable*>(caller);