Okay, its not a complete blackjack game as you can see here, if it was a complete game, i probably wouldnt send it here but that doesnt mean that i can not complete it, its so simple to complete this game just changing the place of the same codes would do the thing and adding an other button.
Anyhow, make a folder called "Cards" in your and put the attached images in that folder, then use the following code to have an idea.
Press "T" key to take a card.
Rem Project: 21
Rem Created: 08.03.2005 16:56:42
Rem ***** Main Source File *****
pathRoot$ = GET DIR$()
pathCards$ = "Cards"
mouseSpeed = 5
txtFont$ = "Georgia"
txtSize = 12
scrWidth = Screen Width()
scrHeight = Screen Height()
scrDepth = Screen Depth()
scrWidth2 = Screen Width() / 2.0
scrHeight2 = Screen Height() / 2.0
scrFov = 62
gameFps = 60
SYNC RATE gameFps : SYNC ON
AUTOCAM OFF : BACKDROP ON : HIDE MOUSE
SET IMAGE COLORKEY 0, 0, 0
RANDOMIZE TIMER()
SET TEXT FONT txtFont$
SET TEXT SIZE txtSize
GOSUB Load_Strips
DO
text 0,0, "Your Score: "+str$(valTOTAL)
text 0,10, "Ai Score: "+str$(valTOTALE)
`-----------MAKE BUTTON (T)------------
if keystate(20) > 0 and T_BUT = 0 then T_BUT = 1
if T_BUT = 1
T_BUT = 2
REM PLAYER
rows = rnd(13)
card = rnd(4) * 100
if rows = 0 or card = 0
if rows < 1 then rows = 1
if card < 100 then card = 100
endif
REM ENEMY
rowsE = rnd(13)
cardE = rnd(4) * 100
if rowsE = 0 or cardE = 0
if rowsE < 1 then rowsE = 1
if cardE < 100 then cardE = 100
endif
inc BUT_T, 1
if BUT_T > 5 then BUT_T = 0
endif
if keystate(20) = 0 then T_BUT = 0
if BUT_T = 1
if sprite exist(card+rows) > 0
sprOne = card+rows
if rows => 10
valOne = 10
else
valOne = rows
endif
if sprite exist(cardE+rowsE) > 0
sprOneE = cardE+rowsE
if rowsE => 10
valOneE = 10
else
valOneE = rowsE
endif
endif
endif
endif
if BUT_T = 2
if sprite exist(card+rows) > 0
sprTwo = card+rows
if rows => 10
valTwo = 10
else
valTwo = rows
endif
if sprite exist(cardE+rowsE) > 0
sprTwoE = cardE+rowsE
if rowsE => 10
valTwoE = 10
else
valTwoE = rowsE
endif
endif
endif
endif
if BUT_T = 3
if sprite exist(card+rows) > 0
sprThree = card+rows
if rows => 10
valThree = 10
else
valThree = rows
endif
if sprite exist(cardE+rowsE) > 0
sprThreeE = cardE+rowsE
if rowsE => 10
valThreeE = 10
else
valThreeE = rowsE
endif
endif
endif
endif
if BUT_T = 4
if sprite exist(card+rows) > 0
sprFour = card+rows
if rows => 10
valFour = 10
else
valFour = rows
endif
if sprite exist(cardE+rowsE) > 0
sprFourE = cardE+rowsE
if rowsE => 10
valFourE = 10
else
valFourE = rowsE
endif
endif
endif
endif
if BUT_T = 5
T_BUT = 0
BUT_T = 0
sprOne = 0
sprTwo = 0
sprThree = 0
sprFour = 0
valOne = 0
valTwo = 0
valThree = 0
valFour = 0
valTOTAL = 0
sprOneE = 0
sprTwoE = 0
sprThreeE = 0
sprFourE = 0
valOneE = 0
valTwoE = 0
valThreeE = 0
valFourE = 0
valTOTALE = 0
endif
valTOTAL = valOne + valTwo + valThree + valFour
valTOTALE = valOneE + valTwoE + valThreeE + valFourE
if valTOTAL =< 21 and valTOTAL =< 21
if valTOTAL =< 21
if sprOne > 0 then PASTE SPRITE sprOne, 100, 300
if sprTwo > 0 then PASTE SPRITE sprTwo, 200, 300
if sprThree > 0 then PASTE SPRITE sprThree, 300, 300
if sprFour > 0 then PASTE SPRITE sprFour, 400, 300
endif
if valTOTALE =< 21
if sprOneE > 0 then PASTE SPRITE sprOneE, 100, 100
if sprTwoE > 0 then PASTE SPRITE sprTwoE, 200, 100
if sprThreeE > 0 then PASTE SPRITE sprThreeE, 300, 100
if sprFourE > 0 then PASTE SPRITE sprFourE, 400, 100
endif
else
T_BUT = 0
BUT_T = 0
valOne = 0
valTwo = 0
valThree = 0
valFour = 0
valTOTAL = 0
sprOne = 0 : sprTwo = 0 : sprThree = 0 : sprFour = 0
T_BUT = 0
BUT_T = 0
valOneE = 0
valTwoE = 0
valThreeE = 0
valFourE = 0
valTOTALE = 0
sprOneE = 0 : sprTwoE = 0 : sprThreeE = 0 : sprFourE = 0
endif
SYNC
LOOP
Load_Strips:
`-----------LOAD IMAGES-----------
SET DIR pathCards$
clubs = 100
diamonds = 200
hearts = 300
spades = 400
imgWidth = 71
imgHeight = 96
imgSeperate = 1
LOAD BITMAP "cards_clubs.png", clubs
for s = 1 to 13
GET IMAGE clubs+s, imgSeperate+(s-1)*imgWidth, imgSeperate, imgWidth+(s-1)*imgWidth, imgHeight
SPRITE clubs+s, 0, 0, clubs+s : HIDE SPRITE clubs+s
next s
DELETE BITMAP clubs
LOAD BITMAP "cards_diamonds.png", diamonds
for s = 1 to 13
GET IMAGE diamonds+s, imgSeperate+(s-1)*imgWidth, imgSeperate, imgWidth+(s-1)*imgWidth, imgHeight
SPRITE diamonds+s, 0, 0, diamonds+s : HIDE SPRITE diamonds+s
next s
DELETE BITMAP diamonds
LOAD BITMAP "cards_hearts.png", hearts
for s = 1 to 13
GET IMAGE hearts+s, imgSeperate+(s-1)*imgWidth, imgSeperate, imgWidth+(s-1)*imgWidth, imgHeight
SPRITE hearts+s, 0, 0, hearts+s : HIDE SPRITE hearts+s
next s
DELETE BITMAP hearts
LOAD BITMAP "cards_spades.png", spades
for s = 1 to 13
GET IMAGE spades+s, imgSeperate+(s-1)*imgWidth, imgSeperate, imgWidth+(s-1)*imgWidth, imgHeight
SPRITE spades+s, 0, 0, spades+s : HIDE SPRITE spades+s
next s
DELETE BITMAP spades
`---------SET SPRITE PROPERTIES-----------
for spr = clubs to spades+13
if sprite exist (spr)
SET SPRITE spr, 1, 0
endif
next spr
SET DIR pathRoot$
RETURN