The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 5 of 5

Thread: Random Card Deck Draw

  1. #1

    Random Card Deck Draw

    I am VERY, VERY new to flash so I'm hoping somebody could help me out. I made a very simple flash program in CS5 for a board game 'Firefly: The Game' to replace using the NAV Deck cards for your movement in the game. So far I have it setup to randomly choose one 'card' in the time frame every time one of the buttons is pressed and display it. The one thing that I have no idea how to do is, that I would really love some help on, is have the flash program know and keep track of which 'cards' have already been chosen till it reaches the end of the specific deck. Then it auto reshuffles and starts all over again. If anybody is willing to take a look at my file I created I am more than welcome send it to whoever is interested. Thanks

    Brian Blake
    aka: Deadmaxx

  2. #2
    TheCanadian's Avatar
    10,305
    posts
    Noo doot aboot it, eh?
    Hey Brian, I don't have time to write any code examples but basically I think the best strategy would be to have an array which contains all of the cards. You then have two options: you can (1) shuffle the array so that the cards are ordered randomly and then pop cards off the end, or (2) pick a care randomly from the array and splice it out. The drawn cards can then be put in a new array. When the old array is empty, you repeat the process with the new array.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  3. #3

    random card drawing

    Oh okay thanks for the tips. No problemabout not having time to show examples or anything, I know how that is. Unfortunately since I barley know how to use flash, I have no idea howto do the things you suggested. LOL but I can ask a guy in the office thatmight have an idea. Thanks.

    bsb


  4. #4

    Cards in Flash

    Quote Originally Posted by TheCanadian View Post
    Hey Brian, I don't have time to write any code examples but basically I think the best strategy would be to have an array which contains all of the cards. You then have two options: you can (1) shuffle the array so that the cards are ordered randomly and then pop cards off the end, or (2) pick a care randomly from the array and splice it out. The drawn cards can then be put in a new array. When the old array is empty, you repeat the process with the new array.
    Okay...sadly all the Flash stuff is WAY over my head...hehe... Can you maybe suggest a site where I could maybe find somebody I can possibly pay to do flash work? Thanks

  5. #5
    tpann's Avatar
    275
    posts
    Instructional Designer
    Here are suggestions:
    Your card deck could be an array containing all the cards. Then you could have another array containing the cards that have been pulled out for whatever reason. I'm not familiar with how 'Firefly' actually works so I may be oversimplifying.

    var deck:Array = new Array();
    var pulledCards:Array = new Array();

    Let's say each card is a movieclip in your library and you bring them in naming them card_1, card_2, card_3, ... card_n. As you bring them in you populate them in your deck array by whatever means:

    deck.push(card_1);
    deck.push(card_2);
    //...etc.


    Or if you can load each card dynamically then you can do a for loop. Whatever. So then the deck array actually represents your full deck.

    So let's say for simplicity you have a deck with 8 cards:

    trace(deck); // card_1,card_2,card_3,card_4,card_5,card_6,card_7,c ard_8


    To pull a card out of the deck, you splice it from the deck array and simultaneously push it into the pulledCards array. Mind you, here you must have a way of identifying each card within a for loop, thus:
    PHP Code:
    for (var a:int 0deck.lengtha++) {
               if (
    deck[a].someProperty == thePropertyIWant) {
                         
    pulledCards.push(deck.splice(a1));
                         
    // splice removes the card at position a in deck; 1 means just one card.
               
    }

    Then, for example, you end up with...

    trace(deck); // card_1,card_2,card_3,card_5,card_6,card_7,card_8

    trace(pulledCards); // card_4
    t i m

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012