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

469 visits, 1,106 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.

"Card Deck" design explained.

A complete card deck has 5 suits of 14 sequential cards numbered "Ace", 2, 3, 4, 5, 6, 7, 8, 9, 10, "Knight" (aka cavaliers or ober), "Jack", "Queen", and "King". The fifth suit is the "Trump" suit used in Tarot. Each card in its set belongs to a particular symbol: Hearts, Spades, Clubs, and Diamonds. In total that consists of 56 different cards. For our deployment, I plan to eliminate the "Knight" card and the "Trump suit" (a future Tarot Game release). The "Knight" is typically used in Skat - the national card game of Germany, and one of the best card games for 3 players (HINT! HINT!).

The deck, we're building in this tutorial, will be an "Array of sprite card objects" that we create and shuffle dynamically. We could use Unicode to lighten our game's download (See the free resource file attached).

Separating Components

To modularize my code, I split the game into 3 parts. One component deals with logic, rules, and data manipulation (aka "Game Mechanics"), while the other performs just the User Interface (UI) Display functions. Keeping these components separate allows me to quickly transpile my games into any gaming framework or exchange any artwork graphics. This is covered in detail in the workbook.

Declaring Global Variables

Let's start with some data structures**. Here is the JavaScript ...

let suits = ["Spades", "Hearts", "Diamonds", "Clubs"];
let cards = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"];	
let deck = new Array();

The variable suit is an array of card sets that we will use as a lookup table. The order of the suits is unnecessary for now. But you might consider using this card deck in other card games where suits do have a priority. For example, "Poker"! The second array holds all the possible card values. Here's how it would look inside the Construct editor ...

Arrays are "zero-based". I've added a "card backing" into the zero index. Doing this keeps the array index matching any card's face value. The suit array has the "Trump suit" and all other suits are in their ordinal index for card games that need a "suit priority".

  • 0 Comments

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