-2

I want to make a game a card game and I was thinking to make the cards as a int so I can make the game rules with if ifelse and else condition's but I don't know how to take an int and put texture and rectangle all together. So I make a research and people make the card deck from array. I'm asking what is the best way to do it and if you could give me a code example I'm a beginner in xna?

I start thinking if a way to make cards by number like int but I don't know if it gonna work like this.

int Card0 =1;
int Card1 =2;
int Card3 =3;
int Card4 =4;
int Card5 =5;
int Card6 =6;
int Card7 =7;
int Card8 =8;
int Card9 =9;
int Card10 =10;
int Card11 =11;
int Card12 =12;

///class
Passplayerturn passTurn;
UnloadCard unloadcard;

if I can do it like this I can put the rule like this.

if(Card4 >= 4)
   passTurn;
else
   unloadcard;

but I don't know how to put texture to something I made in in variable. I seen some people in Java language use Array to make deck but I don't really know how array works. I searched tutorials of array but I cant understand it.

Mat
  • 202,337
  • 40
  • 393
  • 406
  • You should first show some effort first when asking on this site. Show us YOUR code. What have you tried so far and what didnt quite work? As for your idea - its a bad idea. You are using an OOP language - use it to your advatage. You need a card? Define a `Card` class. You need a deck? Create a `Deck` class. Etc. – Nikita B May 14 '13 at 06:21
  • Here is some sample code that shows you how to create a blackjack game using proper object oriented techniques: http://visualstudiogallery.msdn.microsoft.com/049d2fe9-f845-48ae-a34d-acbded9f7e5a – jgallant May 14 '13 at 10:53
  • thx Nik for what you say it help me get a answered to my question xD Jon thx for sending me that link I will study it xD and Sam I am thx for answare my question I will try my best xD; – Amaterasu Hiro May 15 '13 at 23:14

1 Answers1

0

If I were you I'd make a Card class

public class Card
{
    int number;
    int suit;  // or better yet, an enum of some sort
    Texture2d sprite;
    ...
}

and then a Deck would essentially be a collection of cards

public class Deck
{
    List<Card> cards;
    ...
}