A small deck of cards sprite sheet for making card games

Post Reply
User avatar
Dav
Posts: 279
Joined: Tue Dec 30, 2014 5:12 pm
My devices: iPad Mini, iPod Touch.
Location: North Carolina, USA
Contact:

A small deck of cards sprite sheet for making card games

Post by Dav »

Here's a demo of using a small playing cards sprite sheet. With this card sprite sheet it will easy to make nice looking card games in smart basic, which is what I plan to do next. I added a red & blue back of playing cards to the original 52 card deck, and also added 2 joker cards, so this sprite sheet is a complete deck with 56 total images.

This program will download the needed sprite sheet from my website and then run. It's a small file, only about 40k.

- Dav

Code: Select all

'cards.txt v1.0 (iphone/ipad)
'Demos a nice deck of cards using a sprite sheet.
'Downloads 'cards.png' sprite sheet from internet.
'You can use this sprite sheet to make card games.
'The sprite sheet is small, only 40k in size.
'Coded by Dav, OCT/2017

'NOTE: This programs saves 'cards.png' in current dir.
'      On first run it will download it off internet.

option base 1

if not file_exists("cards.png") then
   gosub download
end if

graphics
graphics clear 0,.5,.2
get screen size sw,sh

sprite "cards" load "cards.png", 14,4
sprite "cards" show

'Now show all frames of sprite...
'(52 number cards, 2 backs, 2 jokers)

do
  for f =1 to 56
    refresh off
    sprite "cards" frame int(rnd(55))+1
    sprite "cards" at rnd(sw),rnd(sh) scale rnd(2)+1 angle rnd(255)/255
    sprite "cards" stamp
    refresh on
    pause .01
  next f
until forever

end


'=======
download:
'=======

url$="www.qbasicnews.com/dav/files/cards.png"
print
print
print
print "DOWNLOAD CARDS.PNG SPRITE SHEET?"
print
print "This program requires the file cards.png.";
print "It is only about 40k in file size and will ";
print "download from: http://"&url$
print
print "It will be saved in the current folder. ";
print "You will only have to download it once ";
print "unless you delete the cards.png file."
print

button "download" text "Proceed" at 25,10
button "no" text "Not now, maybe later" at 150,10

do 
  if button_pressed("no") then end
until button_pressed("download")

button "download" delete
button "no" delete

if system_ext_ip$() ="" then
   print "Error!"
   print
   print "You do not appear to be online. ";
   print "Please connect to the internet first and ";
   print "try running program again."
   print
   print "STOPPED..."
   end
end if

print "Downloading..."

http url$ getdim m
file "cards.png" writedim m

return
Attachments
carddemo.jpg
carddemo.jpg (301.9 KiB) Viewed 10378 times

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: A small deck of cards sprite sheet for making card games

Post by Dutchman »

I made a lib for card-games with multi-lingual interface.
See viewtopic.php?f=20&t=937&p=5346 :D
Last edited by Dutchman on Thu Jan 19, 2023 3:18 pm, edited 1 time in total.

User avatar
Dav
Posts: 279
Joined: Tue Dec 30, 2014 5:12 pm
My devices: iPad Mini, iPod Touch.
Location: North Carolina, USA
Contact:

Re: A small deck of cards sprite sheet for making card games

Post by Dav »

Nice lib, Dutchman. I somehow didn't see that post when you posted it.

- Dav

Post Reply