none
Variable Graphics

    Question

  • Before we get started yes I am a student working on an Assignment.

    Our class assignment is to create a card game. simple I know. But I have gone for the hard task and tried to recreate a similar version to the 90's Pokemon Trading Card game, you know slightly more difficult than your typical 52 Deck card game.

    I have created, the card classes, deck classes  and am currently working on the GUI. I have managed to get the graphic working for the game but only as a static image. eg the graphics Image in the Card only relates to 1 place on the GUI and I want it to be a variable based on where I place the card, so if I were to put it into the Deck that is my main Fighting card, it will know to update the Image in that GUI related to that Deck.

    ps i did add as much of the relevant code as possible without just dumping loads of useless crap here.

    namespace Pokemon
    {  
        public partial class Form1 : Form
        {
            Card OpponentCard;// OPPONENT FIGHTING CARD 
            Card myCard;//MY FIGHTING CARD

     

    Graphics PokemonCard;//MY FIGHTING CARD GRAPHICS
            Graphics PokemonCard2;// OPPONENT FIGHTING CARD GRAPHICS

            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {

        PokemonCard = ptrFighterCard.CreateGraphics();
                PokemonCard2 = ptrOpponentFighterCard.CreateGraphics();

        Deck AllCards = new Deck(200);
                Deck myDeck = new Deck(60);
                Deck computerDeck = new Deck(60);
                Deck myHand = new Deck(60);
                Deck computerHand = new Deck(60);
                Deck playerBench = new Deck(5);
                Deck computerBcnch= new Deck(5);
                Deck playerFighter = new Deck(1);
                Deck computerFighter = new Deck(1);
                Deck playerElementDeck = new Deck(60);
                Deck computerElementDeck = new Deck(60);
                Deck playerGraveyard = new Deck(60);
                Deck computerGraveyard = new Deck(60);            

        myCard = new Card("Bulbasaur", 40, 20,"Grass','Grass", 0,"","","Basic","Grass", PokemonCard);
                OpponentCard = new Card("Charmander", 50, 10, "Normal", 30, "Fire,Normal", "", "Basic", "Fire", PokemonCard2);

    //So right here is where my question lies...... I can get these images to just turn up when I click the button so the Images do work but I want the Image to pop up based on the Deck that it is in.

    private void ShowButton_Click(object sender, EventArgs e)
            {
                myCard.display();
                OpponentCard.display();
            }

    }

    class Deck
        {
            public Card[] deck;
            private int indexCard;
            private int lengthofDeck;
            private Random shuffle;

            public Deck(int deckSize)
            {
                deck = new Card[deckSize];
                indexCard = 0;
                lengthofDeck = deckSize;
                shuffle = new Random();
            }

    public void Add(Card cardToAdd)
            {            
                this.deck[FirstSlot()] = cardToAdd;
            }
            public Card DealCard()
            {
                if (indexCard < deck.Length)
                {
                    return deck[indexCard++];
                }
                else
                    return null;
            }
        }

    class Card
        {
            public string name;
            private int health;
            private int attack1;
            private string elementRequiremnt1;
            private int attack2;
            private string elementRequiremnt2;
            private Graphics picture;

    private string evolution;
            private string level;

    public Card( string cName,int cHealth,int cAttack1,string cElementRequired1, int cAttack2, string cElementRequired2,string cEvolution, string cLevel,string cElement, Graphics CPicture)
            {
                name = cName;
                health = cHealth;
                attack1 = cAttack1;
                elementRequiremnt1 = cElementRequired1;
                attack2 = cAttack2;
                elementRequiremnt2 = cElementRequired2;
                evolution = cEvolution;
                level = cLevel;
                picture = CPicture;

    }
            public Card( string cName, int cHealth, int cAttack1,int cAttack2, Graphics CPicture) :this(cName,cHealth,cAttack1,"Water','Water",cAttack2,"Normal','Normal","","Basic","Normal", CPicture)
            {
                name = cName;
                health = cHealth;
                attack1 = cAttack1;
                attack2 = cAttack2;
                picture = CPicture;
            }
            public Card(Graphics CPicture): this("empty",1,0,0, CPicture)
            {
                picture = CPicture;
            }

    public void display()
            {

          Image PokemonCard = (Image)Properties.Resources.ResourceManager.GetObject(this.Name);
                picture.DrawImage(PokemonCard, 10, 10, 50, 80);

    }

    }}

    THANK YOU IN ADVANCED

    I know this seams probably silly to you pro's out there but my lecturer is Dutch and I find him hard to understand and I think a little gets lost in translation.

    Tuesday, October 11, 2016 1:09 AM

Answers