How do I ..TCG?

0 favourites
  • 13 posts
  • Okay, so I am doing a personal project that I'd like to really expand on.

    Basically, I'm dealing with trading cards and it's not a game so much as it is just collecting cards.

    However, there will be some aspects as far as a game.. anyways..

    I have always been really bad about dealing with arrays, and I feel like that is something I need, because here is all I'm trying to figure out:

    -User logs in through Google Play (to save progress etc.)

    -User gets initial booster pack that contains 3 cards!

    -Store cards on profile?

    -Purchase booster pack

    -Pick random cards for selection (including rares?)

    -Trading with other players online

    Now I know this is a lot and there is a lot I want to do with it and I'm working really hard to try to figure this out, but I am really struggling and I'd appreciate some help. I have been looking at all sorts of tutorials and manuals and I'm just trying to figure out the best way to approach this.

    Help is appreciated. Thanks!

  • You can allocate each card to an array slot and then fill it with 1 if they achieve a certain card, so it just looks like a table of 0s and 1s where 1 means they have the card. You can then save this in local storage. That is how I would do this kind of thing but there are plenty of ways. You could also just add any cards they have to the array once achieved so it's just a list of cards. I was concerned with arrays too but once I decided to make my own inventory and understood how you can manipulate them some more then they became very useful.

    This is useful : ... -beginners

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much, I will be sure to check it out.

    So if they get multiple of the same cards, would the 0s and 1s become like 0s and 1s and 2s?

    Or would I want to make it so that they can't achieve the same card?

    I'd just rather not do that.

    I'll get to work though and see what I come up with on that. Thank you.

  • Again lots of ways to do it but if you want to achieve multiple versions of the same card you could have them in an array as such [Wizard, Paladin, Dragon, Wizard, Dwarf] which is just a store of all of the cards they own. You can then run checks for how many of each they have if you need to know that. I don't really know how you're going to be displaying the cards so the method you use is probably determined by that.

  • I'd like to display them in Alphabetical order ..ha.. across the layout.. so I'd have the one being looked at right in the center and bigger and then there would be two more cards being displayed, one to the left and one to the right, a little smaller.

    <- i I i ->

    ^^ Like that, sort of.. but then in Alphabetical order and at the end of the list it would go back to A to the right or Z to the left, you know what I'm getting at? Displaying the cards I feel won't be a problem if I can figure out how the array works but I think if I just keep looking I'll get it figured out.

  • Yeah you could make a CurrentCard variable which is co-ord in the array and then +/- 1 as you navigate between them to show each card. Then you need a check that grabs what card it is so if at (0,1) is 'Dragon' it knows to show the 'Dragon' card, then you go to the next item in the array etc. Have a go at adding strings and numbers to an array and retrieving their values and you'll soon figure it out.

  • I think I am beginning to understand the array. My brain just farted though with trying to link the card to the Array value. Like should I have each card as its own object or should I keep the cards in one sprite? Maybe that's what is throwing me off.

  • Well I guess the card is a Sprite and you just change the animation or frame of an animation to change card? If (0,1) is a particular card then you have to decide if that's a Sprite, a SpriteAnim or a frame of an Anim. You can even go as far as when you add a card to the array, it creates a new Sprite, with animation and texture and a load of variable stats and things, depends how detailed you want to go.

  • The way I have it right now is that it would have it as a frame of an Anim.. so each frame of the sprite is actually a different card. This is how I was going to organize my booster packs. This way I could try to keep the sprites low but I can have a higher card count.

    So is there a way to set the frame based on a string?

    Also, when I'm trying to draw the card, it has to check to see what card is owned. So I have my array and 3 of the cards are owned, is there a way to skip over the 0 value? I'm sorry I'm trying to make sense of this and I found a couple helpful links. It's a struggle.

    EDIT: I looked back at the arrays and figured out how to find the 0 through the loop.

  • Okay, here is what I have.

    What I am trying to do is figure out how to draw the sprite that only has the (1) so how do I check that?

    Would that mean I'd have to find out how to jump number in CurrentCard?

    I'm so dumbfounded.

  • You could run a check, there is a 'Does array contain value' and check for 1. Then you'd have to start from the current co-ord and run a check for the next 1.

  • So under the moue left and mouse right I would want to check, correct?

    That's where I have it right now.

    Then if it contains 1, I would want to set CurrentCard to CurX?

    But then how do I check the next 1?

    I feel as if I'm overthinking this.

  • It is going down a complex route, to stop this going on forever I would just look at making an array and manipulating it so that you are comfortable with what each action does, if you are going to be relying on them for the cards. The best way to use them might be to have the card stored at 0,0 displayed, then the card stored at 1,0 displayed so you can easily run through the co-ords of the array and display each card in order.

    Every time you collect a card just push it to the back of the array, you can worry about things like arranging in alphabetical order later on. Push the card values onto the X 0,0 1,0 2,0 3,0 etc and practice switching between each value in the array to display the card associated with that stored value. If 'Dragon' was the first card, stored at 0,0 then you display 'Dragon', then a right key press will display 1,0. Start with the basics then branch out from there when you are comfortable with using arrays. I found that when you are using arrays, using the Debug view is helpful. You can see what is appearing in the array in the debug layout at the bottom.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)