• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Confusing variables, I need help!

J

JopRillos2001

Guest
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.
 
D

dannyjenn

Guest
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).
 
Top