Advertisement
Egor_Vakar

Cards.cpp (coursework)

Dec 26th, 2022 (edited)
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include "Cards.hpp"
  2.  
  3. Cards::Cards(sf::Texture& p_texture, int cardsPosition, int currentPlayer){
  4.  
  5.     this->screenPosition = cardsPosition + 1;
  6.     this->card_id = ( rand() % 13 );
  7.  
  8.     if( card_id > 8 ){
  9.         this->card_value = 10;
  10.     }else{
  11.         this->card_value = card_id + 1;
  12.     }
  13.  
  14.     spr.setTexture(p_texture);
  15.  
  16.     if( currentPlayer == 1 ){
  17.  
  18.         spr.setPosition( (this->CARDS_WIDTH * this->screenPosition) + 370, this->CARDS_HEIGHT + 400);
  19.     }else{
  20.  
  21.         spr.setPosition( (this->CARDS_WIDTH * this->screenPosition) + 370, this->CARDS_HEIGHT + this->CARDS_HEIGHT - 50);
  22.     }
  23.     // # @Param 1: Position x on sprite, based in width of drawing
  24.     // # @Param 2: Position y on sprite, based in height of drawing
  25.     // # @Param 3: width of drawing
  26.     // # @Param 4: height of drawing
  27.     spr.setTextureRect(sf::IntRect(this->CARDS_WIDTH * this->card_id, ( rand() % 4)  * this->CARDS_HEIGHT, this->CARDS_WIDTH, this->CARDS_HEIGHT));
  28. }
  29.  
  30. Cards::~Cards(){}
  31.  
  32. sf::Sprite Cards::Draw(){
  33.     return this->spr;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement