// Project: Cards
// Created: 2017-10-22
// show all errors
SetErrorMode(2)
screenwidth=1024
screenheight=768
// set window properties
SetWindowTitle( "Cards" )
SetWindowSize( screenwidth, screenheight, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
type _cards
id as integer
value as integer[2] // right side up and upside down
suit as integer //1 - diamonds, 2=spades, 3=hearts, 4=clubs
x# as float
y# as float
endtype
global cards as _cards[52]
global suitname as integer [4]
cardnumber=1
for suit=1 to 4
for a=1 to 13
/// Chane the width and hieght if you like xx xx, or change colors, colours of the corners of the box
cards[cardnumber].id = createsprite(createcard(50,100,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255)))
cards[cardnumber].x#=(a*GetSpriteWidth(cards[cardnumber].id))*1.3
cards[cardnumber].y#=(suit*GetSpriteHeight(cards[cardnumber].id))*1.3
value$=str(a)
if value$="1" then value$="A"
if value$="11" then value$="J"
if value$="12" then value$="Q"
if value$="13" then value$="K"
cards[cardnumber].value[1] =createtext(value$)
cards[cardnumber].value[2] =createtext(value$)
SetTextSize(cards[cardnumber].value[1],30)
SetTextSize(cards[cardnumber].value[2],30)
if suit=1 then cards[cardnumber].suit = createtext("♦") //
if suit=2 then cards[cardnumber].suit = createtext("♠") //
if suit=3 then cards[cardnumber].suit = CreateText("♥") //
if suit=4 then cards[cardnumber].suit = CreateText("♣") //
SetTextSize(cards[cardnumber].suit,40)
inc cardnumber
next
next
do
cardnumber=1
for suit=1 to 4
for a=1 to 13
SetSpritePosition(cards[cardnumber].id,cards[cardnumber].x#,cards[cardnumber].y#)
SetTextPosition(cards[cardnumber].value[1], cards[cardnumber].x#, cards[cardnumber].y#)
SetTextPosition(cards[cardnumber].value[2], cards[cardnumber].x#+GetSpriteWidth(cards[cardnumber].id), cards[cardnumber].y#+GetSpriteHeight(cards[cardnumber].id))
SetTextAngle(cards[cardnumber].value[2],180)
select suit
case 1,3:
SetTextColor(cards[cardnumber].value[1],255,0,0,255)
SetTextColor(cards[cardnumber].value[2],255,0,0,255)
SetTextColor(cards[cardnumber].suit,255,0,0,255)
endcase
case 2,4:
SetTextColor(cards[cardnumber].value[1],0,0,0,255)
SetTextColor(cards[cardnumber].value[2],0,0,0,255)
SetTextColor(cards[cardnumber].suit,0,0,0,255)
endcase
endselect
SetTextPosition(cards[cardnumber].suit, cards[cardnumber].x#+GetSpriteWidth(cards[cardnumber].id)/2-GetTextTotalWidth(cards[cardnumber].suit)/2,cards[cardnumber].y#+GetSpriteHeight(cards[cardnumber].id)/2-GetTextTotalHeight(cards[cardnumber].suit)/2)
inc cardnumber
next
next
Render2DBack()
Print( ScreenFPS() )
Sync()
loop
function createcard(w,h,col1,col2,col3,col4)
render()
DrawBox(0,0,w,h,col1,col2,col3,col4,1)
swap()
img = getimage(0,0,w,h)
endfunction img
Enjoy.
I certainly enjoyed creating it