1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

I need help with a basic card game - BEGINNER

Discussion in 'Programming' started by TidusXCloud000, May 12, 2019.

  1. TidusXCloud000

    TidusXCloud000 Member

    Joined:
    May 12, 2019
    Posts:
    6
    Hello everyone,

    I am a beginner to Game Maker Studio 2, I have made some basic games such as platformers and top down tank shooters in previous Game Makers to give you an idea of where I am up to in my experience.

    I am trying to make a game right now which is a card game which involves one player or two players. I'll give you the rules:
    The game is based off of Topps Match Attax and their soccer section. Essentially one player gets to choose either 'attack' or 'defence'. Each card has an attack stat and a defence stat. Two players place a card down and whoever has the highest stat wins both cards, and rests them next to the player, showing the amount of cards he has won. The game will go on until one player has lost all of their cards. So what I am struggling with is the fact that I have many cards with different statistics. How would I give a player a random deck of cards, and then let them choose a stat on which to play on. Basically, how would I code this game? I understand the basics, which is setting up the room, the sprites, and I have made an object for each of the cards to go off of. If anything is unclear, please do not hesitate to ask. I will leave an example of one of the cards in the link below. Also, I can just make the card change from its back to the front through just an animation where the player clicks and both cards flip, right? Thank you so much! IMG_4633.JPG
     
  2. SnortySnoopy

    SnortySnoopy Member

    Joined:
    Apr 25, 2018
    Posts:
    116
    You might find this tutorial series useful : .
     
  3. TidusXCloud000

    TidusXCloud000 Member

    Joined:
    May 12, 2019
    Posts:
    6
    Thanks mate, I will check it out!
     
  4. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    Don't go with one object per card. Use at most one object for the whole deck of cards.
    Check out arrays and how to use them, they would be perfect to hold your cards data. And ds_list would be perfect for shuffling decks, draing cards, adding cards to the hands, etc. Just don't go with that many different objects, you'll hate yourself later on
     
  5. TidusXCloud000

    TidusXCloud000 Member

    Joined:
    May 12, 2019
    Posts:
    6
    Oh, I guess that makes sense. I haven’t come across that command, but I have seen videos based around the “ds” function when it comes to stacks. Thank you!
     
  6. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    Basically, they are very much like arrays (which I would abuse of in your case, too!)
    The whole deck data could be just a simple 2D array, like (taking the card above as example)
    Code:
    deck[0,0] = "Robin Van Persie";  //PLAYER NAME
    deck[0,1] = 20;        //DEFENSE
    deck[0,2] = 84;       //OFFENSE
    deck[0,3] = "Arsenal FC";       // TEAM
    ds_list, I would use for more volatile data, like player's hand and such, but for the data that you need to access on a regular basis, just a good ol' 2D array would do all you need, and it's easy to access. Need to draw the player name?
    Code:
    draw_string(x,y,deck[current_card, 0]);
    Need to use the def value to calculate some stuff?
    Code:
    var _def = deck[current_card, 1];
    And boom!

    Really useful and user-friendly, plus it's clean, readable code
     
    Last edited: May 13, 2019
  7. TidusXCloud000

    TidusXCloud000 Member

    Joined:
    May 12, 2019
    Posts:
    6
    OMG! You are such a great help, was busy with school, sorry for the late reply. Thank you sooo much, I really deeply appreciate it.
     
    Taddio likes this.
  8. TidusXCloud000

    TidusXCloud000 Member

    Joined:
    May 12, 2019
    Posts:
    6
    Hey there, sorry to bother you again. I would like to know how to give a player a random set of cards. I have approximately 50 saved up, and would like to utilise all of them. I'm planning to give the player 10 cards for his deck. Thanks!
     
  9. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    You will need some kind of list that holds the cards the player has. I would suggest either a 1D array or a ds_list.
    You could then use a loop (length of which is the number of cards you have to draw) combined with irandom(deck_size) and add the random card from the deck in the player hand. You would obviously need to add a conditional in there to avoid duplicate cards.

    Another way to go would be to simply shuffle the whole deck and pick the cards from the top to bottom. This would be how cards work in real life, but that's the beauty of game dev: illusion! It doesnt have to be realistic under the hood if the end result appears to he the same.

    Just go step by step with it. If you don't master them yet, you will need to check arrays, data structures, loops, and the various random functions. They will be useful for a ton of other stuff, so it's worth learning them sooner than later
     
  10. TidusXCloud000

    TidusXCloud000 Member

    Joined:
    May 12, 2019
    Posts:
    6
    Oh, I see. That makes sense. Thanks for that.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice