1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GML Confusing variables, I need help!

Discussion in 'Programming' started by JopRillos2001, Sep 18, 2018.

  1. JopRillos2001

    JopRillos2001 Member

    Joined:
    Sep 18, 2018
    Posts:
    19
    I made a game where you can click on a pack, and you will recieve a card. When you click on this card, the variable changes and in the next room, I want to display this card again, but it keeps on giving me the wrong sprite. I think it is because my variables are not saved correctly. When opening a pack, You'll get multiple cards, but you can only see the front card. There is 1 card with a 100% change of getting, but its always at the bottom of the card pile, so when a card with 25% change gets created, it goes overtop. Im using drag and drop for this. I use the test chance function for each card here. Is there a way to make it so the top card gets selected, or even better, when randomizing a card, not multiple cards are being created.
     
  2. dannyjenn

    dannyjenn Member

    Joined:
    Jul 29, 2017
    Posts:
    569
    Are data structures available in Drag and Drop? If so, look into using a stack. (Though this sort of project looks like it would be extremely difficult to do using Drag and Drop, even if data structures are available...)

    The basic idea of a stack is that you "push" the 100% card onto the stack first. Then 1 in 4 times you push the 25% card on top of the 100% card. "Popping" occurs in reverse order ("last in first out") so the player will select cards from top to bottom (i.e. the 25% card first (if it exists), and then the 100% card).
     

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