hi, sorry ive not been around for such a long time, but here i am again, with a crappy blackjack game... its ok though...
`-Blackjack-
`sync
sync on
set window on
set window title "Blackjack"
cls rgb(0,255,255)
ink rgb(0,0,0),0
``play or rules
do
if makebutton(275,240,"Play")>0 then buttonselected=1
if makebutton(365,240,"Rules")>0 then buttonselected=2
if buttonselected=1 then goto welcome
if buttonselected=2
ink rgb(0,0,0),0
center text 320,300,"RULES"
center text 320,350,"When the game starts select 'hit' or 'stand'"
center text 320,370,"If you click 'hit' you take another random card"
center text 320,390,"If you click 'stand' your opponent takes another random card"
center text 320,410,"The aim of the game is to get your cards to add up to 21"
center text 320,430,"But if you have more that 21 and your opponent has less, you lose, vise versa"
center text 320,460,"[click on the play button to start]"
endif
sync
cls rgb(0,255,255)
loop
`welcome
welcome:
cls rgb(0,255,255)
set cursor 30,30
print "Welcome to Blackjack..."
sleep 2000
cls rgb(0,255,255)
set cursor 30,30
input "Please enter your name: ",name$
sleep 1000
cls rgb(0,255,255)
set cursor 30,30
print "Thank you and enjoy the game..."
sleep 2000
cls rgb(0,255,255)
`start game
start:
`variables
ppoints=0
opoints=0
tmm=0
draw=0
win=0
h=0
s=0
timer=0
ctimer=0
ootimer=0
cards=1
ocards=1
oturn=rnd(13)
lturn=0
endgame=0
dim card(1,13)
card(1,1)=1
card(1,2)=2
card(1,3)=3
card(1,4)=4
card(1,5)=5
card(1,6)=6
card(1,7)=7
card(1,8)=8
card(1,9)=9
card(1,10)=10
card(1,11)=11
card(1,12)=12
card(1,13)=13
rcard1=rnd(13)
rcard2=rnd(13)
rcard3=rnd(13)
rcard4=rnd(13)
rcard5=rnd(13)
dim ocard(1,13)
ocard(1,1)=1
ocard(1,2)=2
ocard(1,3)=3
ocard(1,4)=4
ocard(1,5)=5
ocard(1,6)=6
ocard(1,7)=7
ocard(1,8)=8
ocard(1,9)=9
ocard(1,10)=10
ocard(1,11)=11
ocard(1,12)=12
ocard(1,13)=13
orcard1=rnd(12)
orcard2=rnd(12)
orcard3=rnd(12)
orcard4=rnd(12)
orcard5=rnd(12)
`show stuff
load image "template.bmp",1
`main loop
do
`show things
ink rgb(0,0,0),0
sprite 1,195,160,1
scale sprite 1,50
`hit or stand
ink rgb(255,255,255),0
if rcard1<1 then rcard1=1
if rcard2<1 then rcard2=1
if rcard3<1 then rcard3=1
if rcard4<1 then rcard4=1
if orcard1<1 then orcard1=1
if orcard2<1 then orcard2=1
if orcard3<1 then orcard3=1
if orcard4<1 then orcard4=1
if makebutton(42,185,"Hit")>0 then h=1 : s=0
if makebutton(42,215,"Stand")>0 then h=0 : s=1
ink rgb(0,0,0),0
if h=0 and s=0
center text 320,30,"Your turn"
endif
if h=1
inc timer
endif
if timer>20
cards=cards+1
timer=0
h=0
endif
if cards=4 then s=1
if s=1
inc ootimer
center text 320,30,"Opponent's turn"
endif
if ootimer>20
ocards=ocards+1
ootimer=0
s=0
h=0
endif
`card stuff
if cards=1
card1=card(1,rcard1)
card2=0
card3=0
card4=0
endif
if cards=2
card1=card(1,rcard1)
card2=card(1,rcard2)
card3=0
card4=0
endif
if cards=3
card1=card(1,rcard1)
card2=card(1,rcard2)
card3=card(1,rcard3)
card4=0
endif
if cards=4
card1=card(1,rcard1)
card2=card(1,rcard2)
card3=card(1,rcard3)
card4=card(1,rcard4)
endif
if ocards=1
ocard1=ocard(1,orcard1)
ocard2=0
ocard3=0
ocard4=0
endif
if ocards=2
ocard1=ocard(1,orcard1)
ocard2=ocard(1,orcard2)
ocard3=0
ocard4=0
endif
if ocards=3
ocard1=ocard(1,rcard1)
ocard2=ocard(1,rcard2)
ocard3=ocard(1,rcard3)
ocard4=0
endif
if ocards=4
ocard1=ocard(1,rcard1)
ocard2=ocard(1,rcard2)
ocard3=ocard(1,rcard3)
ocard4=ocard(1,rcard4)
endif
`show cards
if card1=0 then scard1$=" "
if card2=0 then scard2$=" "
if card3=0 then scard3$=" "
if card4=0 then scard4$=" "
if card1=1 then scard1$="Ace"
if card2=1 then scard2$="Ace"
if card3=1 then scard3$="Ace"
if card4=1 then scard4$="Ace"
if card1=2 then scard1$="Two"
if card2=2 then scard2$="Two"
if card3=2 then scard3$="Two"
if card4=2 then scard4$="Two"
if card1=3 then scard1$="Three"
if card2=3 then scard2$="Three"
if card3=3 then scard3$="Three"
if card4=3 then scard4$="Three"
if card1=4 then scard1$="Four"
if card2=4 then scard2$="Four"
if card3=4 then scard3$="Four"
if card4=4 then scard4$="Four"
if card1=5 then scard1$="Five"
if card2=5 then scard2$="Five"
if card3=5 then scard3$="Five"
if card4=5 then scard4$="Five"
if card1=6 then scard1$="Six"
if card2=6 then scard2$="Six"
if card3=6 then scard3$="Six"
if card4=6 then scard4$="Six"
if card1=7 then scard1$="Seven"
if card2=7 then scard2$="Seven"
if card3=7 then scard3$="Seven"
if card4=7 then scard4$="Seven"
if card1=8 then scard1$="Eight"
if card2=8 then scard2$="Eight"
if card3=8 then scard3$="Eight"
if card4=8 then scard4$="Eight"
if card1=9 then scard1$="Nine"
if card2=9 then scard2$="Nine"
if card3=9 then scard3$="Nine"
if card4=9 then scard4$="Nine"
if card1=10 then scard1$="Ten"
if card2=10 then scard2$="Ten"
if card3=10 then scard3$="Ten"
if card4=10 then scard4$="Ten"
if card1=11 then scard1$="Jack"
if card2=11 then scard2$="Jack"
if card3=11 then scard3$="Jack"
if card4=11 then scard4$="Jack"
if card1=12 then scard1$="Queen"
if card2=12 then scard2$="Queen"
if card3=12 then scard3$="Queen"
if card4=12 then scard4$="Queen"
if card1=13 then scard1$="King"
if card2=13 then scard2$="King"
if card3=13 then scard3$="King"
if card4=13 then scard4$="King"
tcards=card1+card2+card3+card4
opnum=ocard1+ocard2+ocard3+ocard4
ink rgb(0,0,0),0
set cursor 0,10
print "",name$," :"
print " "
print "First card: ",scard1$
print "Second card: ",scard2$
print "Third card: ",scard3$
print "Fourth card: ",scard4$
print "----------------------"
print "Total: ",tcards
print "----------------------"
set cursor 560,10
print "Opponent: "
set cursor 560,40
print "----------------------"
set cursor 560,55
print "Total: ",opnum
set cursor 560,70
print "----------------------"
center text 320,460,"©Alastair Zotos 2005"
`win or lose
if cards=4 or ocards=4 or tcards>21 or opnum>21 or tcards=21 or opnum=21 then endgame=1
if endgame=1
if tcards=opnum then draw=1
if tcards>21 and opnum<21 then win=2
if tcards>21 and opnum=21 then win=2
if opnum>21 and tcards<21 then win=1
if opnum>21 and tcards=21 then win=1
if draw=1
center text 320,90,"DRAW!"
center text 320,110,"Click anywhere to restart"
endif
if win=1
center text 320,90,"YOU WIN!"
center text 320,110,"Click anywhere to restart"
endif
if win=2
center text 320,90,"YOU LOSE!"
center text 320,110,"Click anywhere to restart"
endif
endif
if tcards=21 and opnum<21 then win=1
if opnum=21 and tcards<21 then win=2
if win=1
if mouseclick()=1 then goto start
endif
if win=2
if mouseclick()=1 then goto start
endif
if draw=1
if mouseclick()=1 then goto start
endif
`end loop
sync
cls rgb(0,255,255)
loop
`buttons
function makebutton(x,y,desc$)
buttonpressed=0
ink rgb(0,128,0),0 : box x-42,y-14,x+42,y+14
ink rgb(0,255,0),0 : box x-40,y-12,x+40,y+12
ink rgb(0,0,0),0
myx=mousex() : myy=mousey()
if myx>x-40 and myx<x+40
if myy>y-12 and myy<y+12
buttonpressed=1
endif
endif
if buttonpressed=1 then ink rgb(255,255,0),0
set text size 18 : center text x,y-8,desc$
if mouseclick()=0 then buttonpressed=0
endfunction buttonpressed
Your signature has been erased by a mod because it's larger than 600x120...