How do I merge two cards of the same type that next to each other to make a stronger verson?

Not favoritedFavorited Favorited 0 favourites
  • 9 posts
From the Asset Store
Create your own trading card game with this Fantasy TCG Card Template
  • For context, I'm trying to do a sort of card battler with limited varieties of card abilities that merge with each other to make upgraded versions of that same card. Sort of the system in Reverse: 1999 if you want to look up sort of what I am trying to do.

    I got as far as having the cards spawn and move left and stop when they hit each other and stop spawning when I have a full hand until it's the player's turn again.

    I kind of can't wrap my head around how I would do that. Also, I have all the card faces as individual sprites. Each animation is a character's abilities and has 7 frames. When a card spawn it picks an animation of a character selected at random and then picks a frame between 1-2 at random (1 is the face for the attack ability and 2 for skill at lvl 1.) Frame 3 is attack at lvl 2, Frame 4 is skill at lvl 2, Frame 5 is attack at lvl 3, and frame 6 is skill at lvl 3. Frame 0 is the ultimate ability that only spawns at the start of player turn when they have enough "energy."

  • You should set up some instance variables on those cards so you have more control over what's happening particularly the level of the card. I don't know your upgrade mechanic and how outcomes are created but if for example you want to combine 2 cards you could only allow if a lvl 1 is selected to click on another lvl 1 card, then combine into a lvl 2 so destroy both then create a new lvl 2 card and pick the frame at random 3 or 4.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should set up some instance variables on those cards so you have more control over what's happening particularly the level of the card. I don't know your upgrade mechanic and how outcomes are created but if for example you want to combine 2 cards you could only allow if a lvl 1 is selected to click on another lvl 1 card, then combine into a lvl 2 so destroy both then create a new lvl 2 card and pick the frame at random 3 or 4.

    I did not think about assigning the cards instance variables. I was trying to do it by comparing the animation and frame lol. In hindsight that would make controlling their behaviors cleaner.

    The main problem still is that you don't sepect on cards to merge and upgrade rather my intent is to have a phase of play happen where it checks for cards of the same level and type that are touching to them merge and upgrade them. The combat system I'm trying to replicate uses action points as a resource. Moving a card to a new position costs an action point and so does playing a card. Everytime you play a card or merge two cards from a character's abilities that character gains energy. When energy is full you gain a special card that is their ultimate ability. High level cards also sometimes have additional effects such as preventing the target from using their attacks, specials, or ultimate cards depending. Or inflicting a status effect or granting buffs.

    The reason I like this combat system so much is because you have so many choices each turn to tackle enemies as combat plays out in the form of a very simple puzzle.

    Anyways, I'll try to give them variables and see if I can get them behaving the way I want them to later after work.

  • To compare two separate instances of the same sprite type you could utilize a family with just that type to be able to pick two instances independently. Or you could pick one, save info about it to some variables, then pick the other.

    Personally I like a variety of the latter and pick one instance, save it's iid to a variable, then pick the other instance. As an example you could set up the events like this:

    var i=-1
    
    sprite: pick random instance
    -- set i to sprite.iid
    
    sprite: pick random instance
    compare: sprite.animationFrame = sprite(i).animationFrame
    -- sprite: set animation frame to self.animationFrame+1
    -- pick all sprite
    -- pick sprite instance i
    -- -- sprite: destroy

    Generally I find using one sprite type for all the cards is the cleanest way to go. You'd just differentiate between to cards with different animation frames and instance variables.

    Here's a more complete example that could give you some ideas.

    dropbox.com/scl/fi/3y3ql8yvicyxklrcp0qbj/card_merging.c3p

    Besides that some like to use arrays or json to handle the logic and update sprites from that. I find it becomes rather hard to read as it looks more abstract, but it could allow you to avoid more of the picking system of the event sheet.

  • I still can't get it to work. I thought I could change the direction platform behavior objects fell and that would make lining up/setting the cards easier, but I couldn't find how.

    Using instance variables didn't really make it work. I tried using frame tags too. I am not sure how R0J0hound recommended. The problem right now is that I can't figuere out how to make it so that cards that have the same variable/frametag/are-in-same-animation-and-frame to interact the way I need them to without interacting with every version of that object.

  • I still can't get it to work. I thought I could change the direction platform behavior objects fell and that would make lining up/setting the cards easier, but I couldn't find how.

    Using instance variables didn't really make it work. I tried using frame tags too. I am not sure how R0J0hound recommended. The problem right now is that I can't figuere out how to make it so that cards that have the same variable/frametag/are-in-same-animation-and-frame to interact the way I need them to without interacting with every version of that object.

    In general it is to do with picking, you narrow the picked instances with a condition such as 'on object clicked' or 'variable=n', otherwise it picks all instances. In terms of merging, because it is difficult to pick card vs card that's why the suggestion comes above from Rojo about using card vs family to specify object A against object B.

  • I'm trying to follow along but I'm still not sure how putting the cards in a family helps if I did it that way unless you mean making each card face it's own object under a "card family" rather than one sprite object where every card is a separate frame.

    I don't understand how to make it so it only works with specific variables. When I make an event I pick the compare variables to select the card face. But then when I do something like "destroy" or change animation frame it does it for all of them. Like, when I make a new event I can compare variables so I can pick which card I want the event to effect. But then when I pick the event action I don't see a way to compare those variables to limit it to only that card face.

    So it looks something like event is compare variables, then sub condition when collision/overlap. Then event action. And it's the event action that is giving me problems because I don't know how to make it so when it destroys the card object it only destroys it if it shares the same variable.

  • - for the family you just add 'card' to a family on its own. Because you won't be able to use 'card overlaps with card' or something like this, you can use one card as 'card' in the comparison, and use the other card as 'family' in the comparison, this allows you to distinguish card A and card B separately for whatever you need.

    - if you are having trouble with the picking it would be better to see something visual for how the game works, if something like 'on card clicked' is not enough to pick out the card.

    - for the final part you mentioned, it should be resolved by using the above card vs family - if card.variable=family.variable, where card is card A and family is card B.

  • Ok, I tried putting it in families and using frame tags instead of giving them instance variables and it works perfectly. I was able to get past the part I was stuck at, making the cards destroy themselves and then create an upgraded version. With this method only one of the two cards is destroyed since I'm comparing family to sprite, which then made it super simple to just add an event to change the frame on the one that doesn't get destroyed. So it all ended up being way easier. Thanks so much to all of you that responded to this and helped me.

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