mikewalton206's Recent Forum Activity

  • It’s not hard, there’s just many ways to go about it.

    I’d go for one array for the deck, and a card sprite for everything else since they are visible. To be able to differentiate between played cards and cards in the hand you could just add a Boolean instance variable inhand that with a default value of true.

    So assuming you have the deck array already populated you can deal your hand with:

    Start of layout

    Repeat 5 times

    — creat card at (0,0)

    — cars: set animation frame to deck.back

    — deck: pop from back

    Then to position the cards in a row it would be

    Global number numcards=0

    Card: is inhand

    — set numcards to card.pickedcount

    For each card ordered by card.x ascending

    — card: set position to (320+(loopindex-(numcards-1)/2)*card.width, 400)

    So then to play a card it’s as easy as setting inhand to false and moving it to where you want it. The gap will close up. Same with dealing new cards, just create it with a low x to slide in from the right. Curved is also possible, you just change how you set the position.

    Card: is inhand

    For each card ordered by card.x ascending

    — card: set position to (320, 400+500)

    — card: set angle to (loopindex-(numcards-1)/2)*5

    — card: move 400 pixels at self.angle-90 degrees

    Thank you! I'm going to combine both of your guys ideas. It should work ouot perfect!

  • I'm not a big fan of arrays in C2. I repeat this almost in every post where arrays are mentioned <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I'm convinced that many things can be done much easier with objects and instance variables instead of arrays.

    Anyway, here is a demo where cards are moved like you want. I used an example from your other post, modified and simplified it (by removing arrays <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> )

    https://www.dropbox.com/s/b7qmdni2wn9ze ... .capx?dl=0

    You will need MoveTo addon to open it. It's a great behavior and I highly recommend installing it.

    If you change "order by" to spCard.cardFace in event 10, then cards in hand will be arranged by their suit and value.

    Nevermind i got it lol thanks a lot. I'm gonna look at this capx and see if this is what i need <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • I'm not a big fan of arrays in C2. I repeat this almost in every post where arrays are mentioned <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I'm convinced that many things can be done much easier with objects and instance variables instead of arrays.

    Anyway, here is a demo where cards are moved like you want. I used an example from your other post, modified and simplified it (by removing arrays <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> )

    https://www.dropbox.com/s/b7qmdni2wn9ze ... .capx?dl=0

    You will need MoveTo addon to open it. It's a great behavior and I highly recommend installing it.

    If you change "order by" to spCard.cardFace in event 10, then cards in hand will be arranged by their suit and value.

    For some reason my computer can't open the file because it's in a 7z file which i can't open. is there a link to that behavior that's not in a file like that?

  • This must be a hard one to figure out because I seen a post from 2014 with no answer lol at the time it might have been hard to figure out but now I hope there might be some answers. i'm trying to figure out how to make a card hand like in this video below when player removes a card from the hand by placing it on the field and then the hand either shrinks like when a card is removed from the middle and leaves no gap. Then the cards slide over as you draw more.

    Also this hearthstone video below does the same. i'm basically looking for a way to play the cards from my hand and then have the cards in hand react like in these to videos. I'm using an array for the deck and one for the players hand if that helps to problem solve this. The cards in my hand are also animation frames from a random deck draw so i'm not sure if it's because i'm trying to place animation frames on the field and not an actually object that's giving me one of the problems but any ideas would be greatly appreciated, thanks guys.

    Subscribe to Construct videos now

    https://youtu.be/GyNq1eSHHDA

  • I have a 100 x 9 x 1 array.

    X axis indicates 'UID' of objects.

    Y axises indicate distance, HP, size, velocity, ETC...

    in X axis, 'sort X axis' event works well. but problem is Y axises.

    I want to sort X axis by values of Y axises.

    So if I click HP button list should sort by order of HP....

    Is it possible?

    or should I try something else?

    I checked and it might be able to work so look into this... go into the array options and go to compare at xy

    you get to compare the two values and then in the add actions part, you can set the x. looks like you can set at X and In the value part set at whatever your array is called .CurY not sure if that will work or not lol but might get you close. Good luck!

  • Hi mikewalton206!

    The example I sent you on the other thread has a shuffling function already working. Check it!

    Cheers!

    yeah I seen that but I wasn't sure if it had no duplicates or not lol I was also messing around with trying to place cards down like i'm playing them on the field and then draw more cards when my next turn comes up. I tried and The cards either got placed at an angle and or all on top of each other haha and when I tried to draw more cards it wouldn't work because of the max hands so I did something to add 1 to max hand but it just became a mess lol is it because i'm trying to place frames on the playing field and not an actual object? That's one of the main things i'm working/stuck on, The card hand mechanic like hearthstone or really any card game. For example you draw 5 cards, you can play one card or two if an effect kicks in, your card hand shrinks down like how it grows when you add a card, on your next turn you draw another card(s) you get the idea lol I just wanna be able to play cards from the hand and add more whenever that chance come up. If you check out a video of hearthstone ccg you'll get a better idea of what I;m talking about. The player can do a lot with the cards in hand so that's what I pretty much need. Any ideas you have would be greatly appreciated

  • If you have each card as a separate instance, you could do this

    For each sprite ordered by random(1) ascending

    —- sprite: set animation frame to loopindex

    If you want to just get a number one at a time you can either make an array with all the numbers and randomly taking one out. Blackhornet also made a nice plugin to do that.

    ok cool, thanks a lot!

  • ok so I seen the answer to this on here before but that capx wouldn't load so i'll have to ask here again and maybe someone knows a new capx that will actually open for me. Anyways I wanna shuffle a deck of cards from an animation and draw random frames without any duplicates. I tried so many things and have yet to figure it out so any help would be great! thanks everyone.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Het mikewalton206!

    Here's an example with some functions that might be useful for your card game, including the updateHand, which sets position and angle to each card on the player's hand according to the amount of cards and the player hand area.

    https://www.dropbox.com/s/anbtxlrdk2n1l ... .capx?dl=1

    Every function has a help text so you can figure out how it works.

    Hope this helps. Cheers!

    OMG!!! Yes! you are the best LOL this will for sure get me started in the right direction. I really appreciate it!!!

  • Might try this as a cheat.

    That looks good but like some of the people said... the plug-in won't load. This is like one of the hardest but i'm sure really simple things i'm trying to add lol I bet i'll just laugh whenever I figure this out if it ends up being something stupid to make this card hand thing work. Thanks for all the efforts to help

  • With some trig you could set it up like an arc in Hearthstone.

    In a loop, I would set the angle to ((360/number of possible cards)*loopindex)+offset

    With the formula: x = centerX + cos(angle) * distance, y = centerY + sin(angle) * distance

    The z should take care of itself.

    Yeah that didn't work for me. it just placed the cards all in one spot and then they just got set at different angels as they got dealt out so I gotta look for other options or find out if I made a mistake on your idea.

  • yeah I agree with them above... without any or very little details on like how the screen is set up, is the level scrolling, is the button on the same layer as everything else(might have to be put on it's own layer) and so on. More details on how you got it set up would help us help you

mikewalton206's avatar

mikewalton206

Member since 24 Mar, 2015

Twitter
mikewalton206 has 2 followers

Connect with mikewalton206

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies