Recent

Author Topic: Video of the playing cards I use in my games and some background info  (Read 204 times)

TBMan

  • Sr. Member
  • ****
  • Posts: 284
Here's a video of all the playing cards I currently use in the games I code. I'm always on the look out for new images.

What I do is find an image that has all the cards in it, in sequence, and by suit. Then I resize the image to a manageable size so I can grab the individual card sprites that can range from 70x100 to 84x120.  I've found that shrinking a sprite too much can cause blurry images so that's why my card images vary in size.

Up until recently I also had to allow for the different ptcgraph palettes used by each jpg. Recently I got code from ChatGpt that "fits" a jpg's palette to an existing palette when displaying it. The last three decks in the video all use the same color palette as the first deck shown.   This has made things a lot simpler.

I convert the sprites I "grab" to my own simple bitmap format and I also "export" these bitmaps to code that is included (i.e. {$include clubs1.asc} ) in units that I make. At runtime for all of my games the only external files are the palette files. I can also export the palettes to code as well, so I might at some point just create a unit with all the palettes in it.

The only thing I don't like in my big plan here is that each deck has to be determined at runtime using defines for what units are being used.

{ [** edit**] After I wrote this "blog" I decided to build decks and units that have the card sprites all the same size and all use the same color palette. Now I will just have a large block of units in the uses section and the "paintcard" procedure just copies the proper cardicon to a working cardicon based on the current "decknumber."  The card backs are now in one unit as well instead of separate units for each deck. Things will be a lot simpler now to code. I can now have a game setup hot key that will allow the player to select the deck and cardback to use. I now have only 7 decks which include a couple not in the video below. I dropped some of the simpler looking decks in leiu of a couple of old fashion looking decks.}

The card sprites are typed to be a "CardIconType" which is an array of bytes maxrows-1 by Maxcolumns-1. Each deck has different definitions of MaxRows and MaxColumns. Also, each deck is in it's own folder with it's own deck units. These units have slightly different names, but generally the cards are named as clubs1, clubs2, clubs3, etc. (Ace, Two, Three) Doing it this way prevented me from allowing the user of the game to select what deck to use, but I only have 52 cards, and a handful of card backs, (which can be about 11,000 bytes each) in memory for any given game. 

I also made a customized sprite editor for most of the decks so I can tweak things a bit. The editor also exports the sprite as code.

https://www.youtube.com/watch?v=IXSxXaE0E28

« Last Edit: September 10, 2025, 06:43:10 pm by TBMan »
I love programming.

Some things I've done using PTCgraph:

NFL Retro Football (almost finished):
https://www.youtube.com/watch?v=78mTtsd7ppk


Solitaire games:
https://www.youtube.com/watch?v=zmtxI7FdWuQ&list=PLa4BPpFl34iVhFwX1JZwVm3vE5ay_i3R2

 

TinyPortal © 2005-2018