Card* Discard::RemoveTopCard(wxDC& dc, int m_xOffset, int m_yOffset) { Card* card; if (m_topCard <= 31) { card = Pile::RemoveTopCard(dc, m_xOffset, m_yOffset); } else { int topX, topY, x, y; GetTopCardPos(topX, topY); card = Pile::RemoveTopCard(); card->Erase(dc, topX - m_xOffset, topY - m_yOffset); GetTopCardPos(x, y); dc.SetClippingRegion(topX - m_xOffset, topY - m_yOffset, CardWidth, CardHeight); for (int i = m_topCard - 31; i <= m_topCard - 31 + CardWidth / m_dx; i++) { m_cards[i]->Draw(dc, m_x - m_xOffset + i * m_dx, m_y - m_yOffset); } if (m_topCard > 31) { m_cards[m_topCard]->Draw(dc, topX - m_xOffset - m_dx, topY - m_yOffset); } dc.DestroyClippingRegion(); } return card; }
void Pile::AddCard(wxDC& dc, Card* card) { AddCard(card); int x, y; GetTopCardPos(x, y); card->Draw(dc, x, y); }
Card* Discard::RemoveTopCard(wxDC& dc, int m_xOffset, int m_yOffset) { Card* card; if (m_topCard <= 31) { card = Pile::RemoveTopCard(dc, m_xOffset, m_yOffset); } else { int topX, topY, x, y; GetTopCardPos(topX, topY); card = Pile::RemoveTopCard(); card->Erase(dc, topX - m_xOffset, topY - m_yOffset); GetTopCardPos(x, y); dc.SetClippingRegion(topX - m_xOffset, topY - m_yOffset, CardWidth, CardHeight); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (int i = m_topCard - 31; i <= m_topCard - 31 + CardWidth / m_dx; i++) { m_cards[i]->Draw(dc, m_x - m_xOffset + i * m_dx, m_y - m_yOffset); } if (m_topCard > 31) { m_cards[m_topCard]->Draw(dc, topX - m_xOffset - m_dx, topY - m_yOffset); } dc.DestroyClippingRegion(); } return card; }
bool Pile::Overlap(int x, int y) { int cardX; int cardY; GetTopCardPos(cardX, cardY); if (x >= cardX - Card::GetWidth() && x <= cardX + Card::GetWidth() && y >= cardY - Card::GetHeight() && y <= cardY + Card::GetHeight()) { return true; } return false; }
//+-------------------------------------------------------------+ //| Pile::RemoveTopCard() | //+-------------------------------------------------------------+ //| Description: | //| As RemoveTopCard() but also redraw the top of the pile | //| after the card has been removed. | //| NB: the offset allows for the redrawn area to be in a | //| bitmap ready for 'dragging' cards acrosss the screen. | //+-------------------------------------------------------------+ Card* Pile::RemoveTopCard(wxDC& dc, int xOffset, int yOffset) { int topX, topY, x, y; GetTopCardPos(topX, topY); Card* card = RemoveTopCard(); if (card) { card->Erase(dc, topX - xOffset, topY - yOffset); GetTopCardPos(x, y); if (m_topCard < 0) { Card::DrawNullCard(dc, x - xOffset, y - yOffset); } else { m_cards[m_topCard]->Draw(dc, x - xOffset, y - yOffset); } } return card; }
// Return the card at x, y. Check the top card first, then // work down the pile. If a card is found then return a pointer // to the card, otherwise return NULL Card* Pile::GetCard(int x, int y) { int cardX; int cardY; GetTopCardPos(cardX, cardY); for (int i = m_topCard; i >= 0; i--) { if (x >= cardX && x <= cardX + Card::GetWidth() && y >= cardY && y <= cardY + Card::GetHeight()) { return m_cards[i]; } cardX -= (int)Card::GetScale()*m_dx; cardY -= (int)Card::GetScale()*m_dy; } return 0; }
// Calculate how far x, y is from top card in the pile // Returns the square of the distance int Pile::CalcDistance(int x, int y) { int cx, cy; GetTopCardPos(cx, cy); return ((cx - x) * (cx - x) + (cy - y) * (cy - y)); }