Creating "Card Decks" in Construct

9
  • 4 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.c3p

buildingacarddeckprototype.c3p

Download now 404.17 KB
.capx

buildingacarddeckprototype.capx

Download now 283 KB

Stats

458 visits, 1,095 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY-NC 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Subscribe to Construct videos now

Once shuffled, most card decks are dealt from the top down the array (unless we tell our AI differently! HINT). What this means is we can use an Array's pop() method to deal with those cards. The JavaScript "pop() method" removes the last item added into an Array and will return that item to the caller, which is the exact scenario we have here.

function dealCard(deck){
    return deck.pop();
}

let card = dealCard(deck1);
console.log(card);  // for debugging or possibly PBM or PBeM games?
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!