CallumKeene's Forum Posts

  • 4 posts
  • For those of us who haven't played, can you explain what this button does?

  • Obvious question, but I assume you're using AJAX to load the JSON file on start of layout, and then JSON to parse it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • A couple things I didn't include:

    The 3 0's at the bottom of the debug text are a quick and dirty append of what the CurValue in the array is.

    When I have no condition and just tell it to loop through and spawn Cards, it of course spawn a random card from that family and does this 17 times for the full deck size.

  • Hello all,

    I'm making a single-player card game in the vein of Slay the Spire and I want to assign each character a base deck that will include multiple copies of some of the cards. When it was only one copy of each and all cards behaved the same I was able to set the animation frame to a different card sprite based on the array value.

    Now I've built an array containing the IDs of the cards I need to reference, one at each X value. It looks like this:

    0,0,0 are the first 3 because the ID of the first card is 0 and I want it to spawn 3 copies of it in the deck. I thought I could do that like this:

    I have a for loop that runs through the entire array. Then on each step along the way I want the game to compare the current value to the Cards family and see if it matches an ID. When it does, create the card with that ID.

    Other things you'll see in this block aren't relevant. Toggling them off doesn't change the outcome. It's basically set up with a debug text output so I can see the CurValue returned (always 0), it tells the cards to start in the Back animation so they can be flipped over by another event. And setting the value at loopindex to loopindex is a holdover from a tutorial I was following. Removing it doesn't seem to change anything.

    Here's the result:

    It only generates a deck of 3 cards. Then it distributes those cards as normal. In the debug text, the neatly appended column is what the array contains after a shuffle function. It has 3 0's, 3 1's, and other numbers I set when I built the array, as it's supposed to.

    The three cards it pulls are random every time, and it doesn't bother to take their IDs into account.

    What seems to happen is it starts the loop at 0, finds Cards.id does have a match of 0, runs through the 0s in the array (there are 3), and spawns random Cards from the Cards family. I've tried for a week to work this out myself, but I just can't crack it. Do I need to nest another for loop where it checks every card in the Cards family?

    Here's a link to the project file if that helps. Let me know if it's needed in a different format.

    https://drive.google.com/file/d/19-3wLQ5waKaKGH0k1qZ4mvNxNJb-DAOg/view?usp=share_link

  • 4 posts