/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); if (!gameStarted) { ShowSplashScreen(); } else { // players points if (showP2Score) { spriteBatch.DrawString(fontScoreP2, P2_PNTS_MSG + scoreP2, new Vector2(50, 20), Color.Red); } spriteBatch.DrawString(fontScoreP1, P1_PNTS_MSG + scoreP1, new Vector2(50, 430), Color.Blue); for (int i = 0; i < p1Hand.GetNumCardsInHand(); i++) { // display player 1 hand Card c = p1Hand.GetCard(i); //c.setTurned(true); c.CardRectangle = new Rectangle(50 + CARD_CAP * i, 310, Card.CARD_WIDTH, Card.CARD_HEIGHT); c.Draw(spriteBatch); } for (int j = 0; j < p2Hand.GetNumCardsInHand(); j++) { // display opponent hand Card co = p2Hand.GetCard(j); //if (j == 0) // co.setTurned(true); co.CardRectangle = new Rectangle(50 + CARD_CAP * j, 60, Card.CARD_WIDTH, Card.CARD_HEIGHT); co.Draw(spriteBatch); } if (winner != "") { // we have a winner spriteBatch.DrawString(fontScoreP1, winner, new Vector2(screenWidth / 2 - fontScoreP1.Texture.Width / 2, screenHeight / 2), Color.Purple); } else { // ask the player 1 to draw a card spriteBatch.DrawString(fontScoreP1, DRAWCARD_MSG, new Vector2(screenWidth / 2 - fontScoreP1.Texture.Width / 2, screenHeight / 2), Color.Purple); } // display the card under the pile m_deck.GetCard(0).Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Draw deck background and all cards of this deck /// </summary> /// <param name="theSpriteBatch"></param> public virtual void Draw(SpriteBatch theSpriteBatch) { // Draw empty deck background Rectangle r = new Rectangle(m_pos.X, m_pos.Y, Card.CARD_WIDTH, Card.CARD_HEIGHT); if (m_background != null) { theSpriteBatch.Draw(m_background, r, Color.White); } // Draw cards for (int i = 0; i < m_cards.Count; i++) { Card c = m_cards[i]; c.Draw(theSpriteBatch); } }
/// <summary> /// Draws all the cards in the hand, if dealer the first card is hidden /// </summary> public void Draw(SpriteBatch spriteBatch, bool magEye, Card topCard) { foreach (Card card in cards) { int locY; if (isDealer) { locY = Constants.DEALER_Y; } else { locY = Constants.PLAYER_Y; } location = new Point( Constants.OFFSET + (Constants.CARD_SIZE.X + Constants.SPAN) * cards.IndexOf(card), locY); card.Draw(spriteBatch, location, false); } if (magEye) { int locY; if (isDealer) { Card cardD = cards[0]; locY = Constants.DEALER_Y + Constants.SMALL_OFFSET.Y; location = new Point(Constants.OFFSET + Constants.SMALL_OFFSET.X, locY); cardD.Draw(spriteBatch, location, true); } else { locY = Constants.PLAYER_Y + Constants.SMALL_OFFSET.Y; location = new Point(Constants.OFFSET + Constants.SMALL_OFFSET.X + (Constants.CARD_SIZE.X + Constants.SPAN) * cards.Count, locY); topCard.Draw(spriteBatch, location, true); } } }