Drawing Cards?

Blitz3D Forums/Blitz3D Beginners Area/Drawing Cards?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Don't you just hate demonstrating you have too much free time on your hands?

Graphics 1024,768,32,2

Global fntSymbol = LoadFont ("symbol.ttf",20)
Global fntSymbolBig = LoadFont ("symbol.ttf",40)
Global fntArialBig = LoadFont ("Arial.ttf",70)
Global fntArial = LoadFont ("Arial.ttf",15)

Function DrawCard(x,y,Value,Suit)

SuitSymbol$ = Mid("§¨©ª",Suit+1,1)

Color 255,255,255
Rect x+1,y+1,98,148,True
Color 0,0,0
Rect x+2,y,96,1,False
Rect x,y+2,1,146,False
Rect x+99,y+2,1,146,False
Rect x+2,y+149,96,1,False
Plot x+1,y+1
Plot x+98,y+1
Plot x+1,y+148
Plot x+98,y+148

If suit=1 Or suit = 2 Then Color 200,0,0

SetFont fntArial

Text x+8,y+10,Convert(Value),True,True
Text x+92,y+140,Convert(Value),True,True

SetFont fntSymbol
Text x+8,y+25,SuitSymbol,True,True
Text x+92,y+125,SuitSymbol,True,True

If Value > 10 Then
	SetFont fntArialBig
	Text x+50,y+75,Convert(Value),True,True
Else
	SetFont fntSymbolBig
	If Value = 1 Or Value = 3 Or Value = 5 Or Value = 9 Then
		Text x+50,y+75,SuitSymbol,1,1
	EndIf
	
	If Value = 2 Or Value = 3 Then
		Text x+50,y+25,SuitSymbol,1,1
		Text x+50,y+125,SuitSymbol,1,1
	EndIf
		
	If Value > 3 Then
		Text x+30,y+25,SuitSymbol,1,1
		Text x+70,y+25,SuitSymbol,1,1
		Text x+30,y+125,SuitSymbol,1,1
		Text x+70,y+125,SuitSymbol,1,1
	EndIf
	
	If Value > 5 And Value < 9 Then
		Text x+30,y+75,SuitSymbol,1,1
		Text x+70,y+75,SuitSymbol,1,1
	EndIf
	
	If Value = 7 Or Value = 8 Then
		Text x+50,y+50,SuitSymbol,1,1
	EndIf

	If Value = 8 Then
		Text x+50,y+100,SuitSymbol,1,1
	EndIf
	
	If Value = 9 Or Value = 10 Then
		Text x+30,y+57,SuitSymbol,1,1
		Text x+70,y+57,SuitSymbol,1,1
		Text x+30,y+93,SuitSymbol,1,1
		Text x+70,y+93,SuitSymbol,1,1
	EndIf
	
	If Value = 10 Then
		Text x+50,y+40,SuitSymbol,1,1
		Text x+50,y+110,SuitSymbol,1,1
	EndIf
EndIf


End Function

Function Convert$(Value)
	If Value = 1 Then Return "A"
	If Value = 11 Then Return "J"
	If Value = 12 Then Return "Q"
	If Value = 13 Then Return "K"
	Return Value
End Function

; demo!


ClsColor 100,150,100
Cls

For n=1 To 100
	drawcard(Rand(0,924),Rand(0,618),Rand(1,13),Rand(0,3))
Next

WaitKey