Creating "Card Decks" in Construct

11

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

1,417 visits, 2,842 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.

Published on 31 Aug, 2024. Last updated 2 Sep, 2024
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

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