%Generate A Card
%Created by Adrian Todorov
%Created on May 11,2004
%Modified on
%A program that generates a suit and then a value of a card
%Question #6
setscreen ("graphics:400;400")
var any:string(1) %String variable for user input which will generate cards
var suit:string:="" %Variable to give an empty string suit before being assigned one in the procedure
var value:string:="" %Variable to give an empty string value before being assigned one in the procedure
var picID: int %Variable to store the card image generated
var font:int %Variable for font numbers will appear in
var col:int %Variable to store the colour of the numbers
font := Font.New ("Garamond:18:bold")
procedure Card_Generate(var suit:string,var value:string) %Procedure to generate a suit and value of a card
var intsuit:int %Local variable for the integer suit generation
var intvalue:int %Local variable for the integer value generation
randint(intsuit,1,4)
randint(intvalue,1,13)
value:=intstr(intvalue)
suit:= intstr (intsuit)
if suit="1" then %If statements to determine the suit in a string form
suit:="Hearts"
elsif suit="2" then
suit:="Spaids"
elsif suit="3" then
suit:="Clubs"
elsif suit= "4" then
suit:="Diamonds"
end if
if value="1" then %If statements to determine the value (if) there is a string form
value:="A"
elsif value="11" then
value:="J"
elsif value="12" then
value:="Q"
elsif value="13" then
value:="K"
end if
%%%%%If statements to assign JPG image and text colours
if suit="Hearts" then
picID := Pic.FileNew ("Hearts.jpg")
col:=red
end if
if suit="Spaids" then
picID := Pic.FileNew ("Spaids.jpg")
col:=black
end if
if suit="Diamonds" then
picID := Pic.FileNew ("Diamonds.jpg")
col:=red
end if
if suit="Clubs" then
picID := Pic.FileNew ("Clubs.jpg")
col:=black
end if
%%%%%%%%%%%%
end Card_Generate
put"Press any key to generate a card"
delay(1000)
cls
loop %Loop to keep generating a card after every user inputted key
locate(1,1)
getch(any)
Font.Draw(value,105,70,font,white)
Font.Draw(value,250,270,font,white)
Card_Generate(suit,value)
Pic.Draw (picID,115,100, picCopy)
Font.Draw(value,105,70,font,col)
Font.Draw(value,250,270,font,col)
drawbox(86,40,290,310,black)
drawbox(96,50,280,300,black)
drawfill(88,44,col,black)
View.Update
end loop |