tsaw
New member
I used to program on the Amiga computer, but they went out of business. Then I got a PC with Win 3.1 Sheesh... had to start all over again. I wrote a Amiga program called Deluxe Video Poker that was published in the magazine Amiga World around 1992. I finally decided to get back into programming! I'm taking my code for the Amiga and converting into Liberty Basic for Windows.
Here is what I wrote so far:
Here is what I wrote so far:
Code:
' Deluxe Video Poker 2011
'make window, start game
nomainwin
WindowWidth = 560 ' a window 560 across
WindowHeight = 535 ' 535 tall
'center the new window on the screen
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'load cards into memory so you can display them later
loadbmp "bg", "Cards\b1fv.bmp" ' back of card
' load the Clubs
loadbmp "ac", "Cards\c1.bmp"
loadbmp "2c", "Cards\c2.bmp"
loadbmp "3c", "Cards\c3.bmp"
loadbmp "4c", "Cards\c4.bmp"
loadbmp "5c", "Cards\c5.bmp"
loadbmp "6c", "Cards\c6.bmp"
loadbmp "7c", "Cards\c7.bmp"
loadbmp "8c", "Cards\c8.bmp"
loadbmp "9c", "Cards\c9.bmp"
loadbmp "10c", "Cards\c10.bmp"
loadbmp "jc", "Cards\cj.bmp"
loadbmp "qc", "Cards\cq.bmp"
loadbmp "kc", "Cards\ck.bmp"
'load the Diamonds
loadbmp "ad", "Cards\d1.bmp"
loadbmp "2d", "Cards\d2.bmp"
loadbmp "3d", "Cards\d3.bmp"
loadbmp "4d", "Cards\d4.bmp"
loadbmp "5d", "Cards\d5.bmp"
loadbmp "6d", "Cards\d6.bmp"
loadbmp "7d", "Cards\d7.bmp"
loadbmp "8d", "Cards\d8.bmp"
loadbmp "9d", "Cards\d9.bmp"
loadbmp "10d", "Cards\d10.bmp"
loadbmp "jd", "Cards\dj.bmp"
loadbmp "qd", "Cards\dq.bmp"
loadbmp "kd", "Cards\dk.bmp"
'load the Hearts
loadbmp "ah", "Cards\h1.bmp"
loadbmp "2h", "Cards\h2.bmp"
loadbmp "3h", "Cards\h3.bmp"
loadbmp "4h", "Cards\h4.bmp"
loadbmp "5h", "Cards\h5.bmp"
loadbmp "6h", "Cards\h6.bmp"
loadbmp "7h", "Cards\h7.bmp"
loadbmp "8h", "Cards\h8.bmp"
loadbmp "9h", "Cards\h9.bmp"
loadbmp "10h", "Cards\h10.bmp"
loadbmp "jh", "Cards\hj.bmp"
loadbmp "qh", "Cards\hq.bmp"
loadbmp "kh", "Cards\hk.bmp"
'load the Spades
loadbmp "as", "Cards\s1.bmp"
loadbmp "2s", "Cards\s2.bmp"
loadbmp "3s", "Cards\s3.bmp"
loadbmp "4s", "Cards\s4.bmp"
loadbmp "5s", "Cards\s5.bmp"
loadbmp "6s", "Cards\s6.bmp"
loadbmp "7s", "Cards\s7.bmp"
loadbmp "8s", "Cards\s8.bmp"
loadbmp "9s", "Cards\s9.bmp"
loadbmp "10s", "Cards\s10.bmp"
loadbmp "js", "Cards\sj.bmp"
loadbmp "qs", "Cards\sq.bmp"
loadbmp "ks", "Cards\sk.bmp"
'set variable values used in the game
betamount=1 ' default bet value at start of game
dim deck(52) 'the array that holds the cards
' draw the graphicboxes across the screen
graphicbox #main.card1, 56, 100, 75, 100 'card 1
graphicbox #main.card2, 141, 100, 75, 100 'card 2
graphicbox #main.card3, 226, 100, 75, 100 'card 3
graphicbox #main.card4, 311, 100, 75, 100 'card 4
graphicbox #main.card5, 396, 100, 75, 100 'card 5
'graphicbox #main.graph6, 375, 1, 165, 65 ADD ANOTHER GRAPHICS BOX FOR PAYOUTS???
' draw the buttons
button #main.button1,"Deal",[deal], UL, 225, 257, 80, 35
button #main.button2,"Exit",[quit], UL, 465, 462, 70, 35
button #main.button3,"Bet",[bet], UL, 235, 462, 75, 35
button #main.button4,"Save",[save], UL, 465, 417, 70, 40
' open the graphics window
open "Deluxe Video Poker 2011 Began on 1-13-11" for graphics_nsb_nf as #main
'show 5 cards face down
print #main.card1, "down; drawbmp bg 1 1"
print #main.card2, "down; drawbmp bg 1 1"
print #main.card3, "down; drawbmp bg 1 1"
print #main.card4, "down; drawbmp bg 1 1"
print #main.card5, "down; drawbmp bg 1 1"
print #main, "trapclose [quit]" 'if the x is clicked quit
print #main, "when characterInput [quit]" 'for getting out of an enless loop - quit program when a key is hit
print #main, "when leftButtonMove [displaymouse]"' take out later just for info
print #main.card1, "when leftButtonDown [card1clicked]"
print #main.card2, "when leftButtonDown [card2clicked]"
print #main.card3, "when leftButtonDown [card3clicked]"
print #main.card4, "when leftButtonDown [card4clicked]"
print #main.card5, "when leftButtonDown [card5clicked]"
print #main, "place 260 450;font arial 0 20;color black;\$ ";betamount
print #main, "place 30 16;font arial 0 20;color black;\Value of a = " 'a test routine
print #main, "place 200 25;font arial 0 20;color red;\Deluxe Video Poker "
' done setting up the page----------------------------------
' the main loop
[main]
wait' sit here and wait for a valid mouse click
' ------------------------------------------------------
'---------------------------------------- begin actions based on mouse clicks
[deal]
'for p= 1 to 500 'test used for the fun of seeing high speed dealing
dealclicked=1'the deal button was clicked
gosub [dealcard]' uses the random number generator to pick a card - dealtcard is random
gosub [whatcard] 'every card is assigned a number -
' this sub takes the variable dealtcard and makes card$ the graphic to display
'if deltcard=1 then card$="ac"
gosub [drawcard1]'display card 1
gosub [dealcard]' uses the random number generator to pick a card - dealtcard is random
gosub [whatcard] 'every card is assigned a number -
' this sub takes the variable dealtcard and makes card$ the graphic to display
'if deltcard=1 then card$="ac"
gosub [drawcard2]'display card 2
gosub [dealcard]' uses the random number generator to pick a card - dealtcard is random
gosub [whatcard] 'every card is assigned a number -
' this sub takes the variable dealtcard and makes card$ the graphic to display
'if deltcard=1 then card$="ac"
gosub [drawcard3]'display card 3
gosub [dealcard]' uses the random number generator to pick a card - dealtcard is random
gosub [whatcard] 'every card is assigned a number -
' this sub takes the variable dealtcard and makes card$ the graphic to display
'if deltcard=1 then card$="ac"
gosub [drawcard4]'display card 4
gosub [dealcard]' uses the random number generator to pick a card - dealtcard is random
gosub [whatcard] 'every card is assigned a number -
' this sub takes the variable dealtcard and makes card$ the graphic to display
'if deltcard=1 then card$="ac"
gosub [drawcard5]'display card 5
'all 5 random cards are shown
'test code
print #main, "place 30 16;font arial 0 20;color black;\xxxxxxxxxxxxxxxxxxxxxxx"
print #main, "place 30 16;font arial 0 20;color black;\Value of deltcard = ";deltcard
'end test code
'next p
wait
'--------------------------------------------------------------------------------
[bet]'bet button clicked
betamount=betamount +1
If betamount>5 then betamount=1
Print #main, "place 260 450;font arial 0 20;color black;\$ ";betamount
wait
'-----------------------------------------------------------------------------------
'-----------------------------------------------------------------
[dealcard]'the random number generator at work pick a random card
deltcard=int(rnd(1)*52) + 1
used=deltcard
if deck(deltcard)=used then [dealcard]
deck(deltcard)=used
for a = 1 to 52
deck(a)=0
next
return
'-----------------------------------------------------
'--------------------------------------------------------------------------------
'turn the number picked at random into an image to be displayed in [drawcard1] etc
[whatcard]
if deltcard=1 then card$="ac"
if deltcard=2 then card$="2c"
if deltcard=3 then card$="3c"
if deltcard=4 then card$="4c"
if deltcard=5 then card$="5c"
if deltcard=6 then card$="6c"
if deltcard=7 then card$="7c"
if deltcard=8 then card$="8c"
if deltcard=9 then card$="9c"
if deltcard=10 then card$="10c"
if deltcard=11 then card$="jc"
if deltcard=12 then card$="qc"
if deltcard=13 then card$="kc"
if deltcard=14 then card$="ad"
if deltcard=15 then card$="2d"
if deltcard=16 then card$="3d"
if deltcard=17 then card$="4d"
if deltcard=18 then card$="5d"
if deltcard=19 then card$="6d"
if deltcard=20 then card$="7d"
if deltcard=21 then card$="8d"
if deltcard=22 then card$="9d"
if deltcard=23 then card$="10d"
if deltcard=24 then card$="jd"
if deltcard=25 then card$="qd"
if deltcard=26 then card$="kd"
if deltcard=27 then card$="ah"
if deltcard=28 then card$="2h"
if deltcard=29 then card$="3h"
if deltcard=30 then card$="4h"
if deltcard=31 then card$="5h"
if deltcard=32 then card$="6h"
if deltcard=33 then card$="7h"
if deltcard=34 then card$="8h"
if deltcard=35 then card$="9h"
if deltcard=36 then card$="10h"
if deltcard=37 then card$="jh"
if deltcard=38 then card$="qh"
if deltcard=39 then card$="kh"
if deltcard=40 then card$="as"
if deltcard=41 then card$="2s"
if deltcard=42 then card$="3s"
if deltcard=43 then card$="4s"
if deltcard=44 then card$="5s"
if deltcard=45 then card$="6s"
if deltcard=46 then card$="7s"
if deltcard=47 then card$="8s"
if deltcard=48 then card$="9s"
if deltcard=49 then card$="10s"
if deltcard=50 then card$="js"
if deltcard=51 then card$="qs"
if deltcard=52 then card$="ks"
return
'-----------------------------------------------------------------------
'draw the cards picked from the random number generator-----------------
[drawcard1]'show the image of card 1
if cardclicked1=0 then'the card is unheld if cardclicked1=1 then it is held
print #main.card1, "down; drawbmp ";card$; " 1 1"
return
end if
[drawcard2]'show the image of car2
if cardclicked2=0 then'the card is unheld if cardclicked1=1 then it is held
print #main.card2, "down; drawbmp ";card$; " 1 1"
return
end if
[drawcard3]'show the image of card 3
if cardclicked3=0 then'the card is unheld if cardclicked1=1 then it is held
print #main.card3, "down; drawbmp ";card$; " 1 1"
return
end if
[drawcard4]'show the image of card 4
if cardclicked4=0 then'the card is unheld if cardclicked1=1 then it is held
print #main.card4, "down; drawbmp ";card$; " 1 1"
return
end if
[drawcard5]'show the image of card 5
if cardclicked5=0 then'the card is unheld if cardclicked1=1 then it is held
print #main.card5, "down; drawbmp ";card$; " 1 1"
return
end if
'-------------------------------------------------------------------------------
[displaymouse]
'take this out later just for fun and learning
'print using("######.##", a)
print #main, "place 30 16;font arial 0 20;color black;\Value of a ="; MouseX; " "; MouseY
wait
[card1clicked]
If cardclicked1=0 and dealclicked=1 then
playwave "cards\held.wav", async
print #main, "place 70 216;font arial 0 20;color black;\HELD";
cardclicked1=1
else
if cardclicked1=1 and dealclicked=1 then
playwave "cards\unheld.wav", async
print #main, "place 70 216;font arial 0 20;color black;\ ";" "
cardclicked1=0
end if
end if
wait
[card2clicked]
If cardclicked2=0 and dealclicked=1 then
playwave "cards\held.wav", async
print #main, "place 155 216;font arial 0 20;color black;\HELD";
cardclicked2=1
else
if cardclicked2=1 and dealclicked=1 then
playwave "cards\unheld.wav", async
print #main, "place 155 216;font arial 0 20;color black;\ ";" "
cardclicked2=0
end if
end if
wait
[card3clicked]
If cardclicked3=0 and dealclicked=1 then
playwave "cards\held.wav", async
print #main, "place 240 216;font arial 0 20;color black;\HELD";
cardclicked3=1
else
if cardclicked3=1 and dealclicked=1 then
playwave "cards\unheld.wav", async
print #main, "place 240 216;font arial 0 20;color black;\ ";" "
cardclicked3=0
end if
end if
wait
[card4clicked]
If cardclicked4=0 and dealclicked=1 then
playwave "cards\held.wav", async
print #main, "place 325 216;font arial 0 20;color black;\HELD";
cardclicked4=1
else
if cardclicked4=1 and dealclicked=1 then
playwave "cards\unheld.wav", async
print #main, "place 325 216;font arial 0 20;color black;\ ";" "
cardclicked4=0
end if
end if
wait
[card5clicked]
If cardclicked5=0 and dealclicked=1 then
playwave "cards\held.wav", async
print #main, "place 410 216;font arial 0 20;color black;\HELD";
cardclicked5=1
else
if cardclicked5=1 and dealclicked=1 then
playwave "cards\unheld.wav", async
print #main, "place 410 216;font arial 0 20;color black;\ ";" "
cardclicked5=0
end if
end if
wait
'code snippets for later use ----------------------------------------
'enable disable controls
'nomainwin
' button #win.bttn, "Hello",[hello],UL,10,70
' checkbox #win.cbox, "Goodbye",[quit],[quit],10,160,120,24
' menu #win, "&Main","&Enable",[doEnable],_
' "&Disable",[doDisable],"E&xit",[quit]
' open "Enable and Disable" for window as #win
' wait
' [quit] close #win:end
' [doEnable]
' #win.bttn "!Enable"
' #win.cbox "Enable"
' wait
' [doDisable]
' #win.bttn "!Disable"
' #win.cbox "Disable"
'wait
' [hello] wait
[save] 'Perform action for the button named 'save'
for a = 1 to 10000 'just for fun and learning
print #main, "place 30 16;font arial 0 20;color black;\Value of a =";a
next a
wait
[quit]
' confirm"You really want to quit?";quit$
' if quit$="no" goto [main]
unloadbmp "bg"'unload the back of card
'unload the Clubs
unloadbmp "ac"
unloadbmp "2c"
unloadbmp "3c"
unloadbmp "4c"
unloadbmp "5c"
unloadbmp "6c"
unloadbmp "7c"
unloadbmp "8c"
unloadbmp "9c"
unloadbmp "10c"
unloadbmp "jc"
unloadbmp "qc"
unloadbmp "kc"
'unload the Diamonds
unloadbmp "ad"
unloadbmp "2d"
unloadbmp "3d"
unloadbmp "4d"
unloadbmp "5d"
unloadbmp "6d"
unloadbmp "7d"
unloadbmp "8d"
unloadbmp "9d"
unloadbmp "10d"
unloadbmp "jd"
unloadbmp "qd"
unloadbmp "kd"
'unload the Hearts
unloadbmp "ah"
unloadbmp "2h"
unloadbmp "3h"
unloadbmp "4h"
unloadbmp "5h"
unloadbmp "6h"
unloadbmp "7h"
unloadbmp "8h"
unloadbmp "9h"
unloadbmp "10h"
unloadbmp "jh"
unloadbmp "qh"
unloadbmp "kh"
'unload the Spades
unloadbmp "as"
unloadbmp "2s"
unloadbmp "3s"
unloadbmp "4s"
unloadbmp "5s"
unloadbmp "6s"
unloadbmp "7s"
unloadbmp "8s"
unloadbmp "9s"
unloadbmp "10s"
unloadbmp "js"
unloadbmp "qs"
unloadbmp "ks"
close #main'close window
end
[zerovariables]'a gosub to begin a new hand
dealclicked=0
cardclicked1=0
cardclicked2=0
cardclicked3=0
cardclicked4=0
cardclicked5=0
return