Author Topic: Blackjack  (Read 48338 times)

0 Members and 1 Guest are viewing this topic.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #45 on: June 14, 2020, 09:13:49 pm »
I thought you might have noticed those patterns.... already downloaded some images and attempted to 'tile' the images. I think they are actually images of real cloth. The angle of the image causes slight lighting and tiling irregularities. I may be able to do something with them but not sure...

No, I didn't notice the neon sign, but sounds neat, especially if it was flashing.... ;)

Here is the link to a version of ScratchJack.... https://scratch.mit.edu/projects/472525/

It's web based. Click on the little green flag (next to the red dot). Use the slider to place a bet. You know the rest... lol

Here is a 'minimal' cloth that isn't too distracting. Buttons can also be 'printed'. Easy enough to change the cloth colour. This is just a style concept.

green-minimal.png
* green-minimal.png (Filesize: 737.63 KB, Dimensions: 1024x768, Views: 297)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #46 on: June 14, 2020, 09:29:24 pm »
@johnno56 nice!

OK I will move buttons to right side in mockup of game for that logo on tablecloth, that might give more w x h size for buttons as well. I was worried buttons across middle would mess up anything nice in middle of table cloth.

Here is an update on the game code. Delete the old B+ Banking and Loan.txt file if you have one started, everybody is starting at 0 instead of in the hole for 1000 stake to start. Just remember every bet while in the hole is a loan with interest paid the next time you play and positive balances earn interest. ;-))

Same asset files as in last zip:
Code: QB64: [Select]
  1. DEFINT A-Z
  2. _TITLE "Blackjack B+ Johnno v 2020-06" ' started 2019-06-11 B+ as: BJ 1on1 DD w Images.bas
  3. ' Thanks to [banned user] for Card Image file.
  4. ' Fixes since BJ 1on1 wImages.bas 2019-06-09:
  5. ' + Fix label: Dealer must hit if es Total is < 17, not 16.
  6. ' + I added Double Down (DD) option, not just for Pete's sake.
  7. ' So for DD, I read BJ rules according to Hoyle, more fixes to those rules:
  8. ' + The 2nd card to Dealer is face down not first.
  9. ' + Blackjack pays 3:2 or 1.5 times bet, IF Dealer does not match = "push".
  10. ' + If player busts e loses immediately, no push if Dealer also busts.
  11. ' + After everyone gets 2 cards, Dealer looks to see if e has BJ, if so, shows it.
  12. ' + Splash Screen and introduction.
  13.  
  14. 'BJ restart 2020-06-12 wow 1 year later w Johnno collaboration
  15. ' Punch List: from easy to hard
  16. ' + change chips type to _integer64 ;-)) done
  17. ' + larger stakes to start 1000 instead of 100 done
  18. ' + If player busts Dealer wins as everyone is familiar to this rule: this was done already!
  19. ' + Buttons controls like in Gin Rummy, OK done
  20. ' + Banking system charge interest on negative balances and pay interest on positive ones, sound fun? Done very basic
  21. ' + get done quickly so Johnno can work in assets, eh not so quick
  22. ' + fixed up new betting system that involves the bank file.
  23. ' 2020-06-13 post
  24.  
  25. 'BJ v2020-06-13
  26. ' + add Johnno's image for splash screen (or table background?)
  27. ' + charge/pay player interest as soon as sign in again, along with Founder update
  28.  
  29. 'BJ v2020-06-14
  30. ' + update acct at every change of chips count, so user cant cut all loses during session by X-out
  31. ' + start tracking dealer wins and losses too = wins and losses of house without Interest
  32. ' + Oh, oh, oh everybody starts at 0! so it's an automatic P&L statement
  33.  
  34.  
  35. CONST xmax = 900, ymax = 640, white = &HFFFFFFFF ' 40 lines
  36. CONST player = 1 ' at the table
  37. CONST dealer = 2
  38.  
  39. TYPE CardType
  40.     ID AS INTEGER
  41.     cname AS STRING
  42.     value AS INTEGER '1 to 13
  43.     suit AS INTEGER
  44.     points AS INTEGER '1 to 10
  45.  
  46. TYPE PlayerType
  47.     ID AS STRING '         for game player numbers
  48.     name AS STRING '       for tracking accts
  49.     chips AS _INTEGER64 '  current status of player's account
  50.     setbet AS _INTEGER64 ' what's this again? a preset bet for all bets so not constantly queried about a bet amount now has limit of 1000
  51.     bet AS _INTEGER64 '    cuurent round stakes
  52.     hand AS STRING '       the cards?
  53.     cardY AS INTEGER '     graphic Y position for cards
  54.     Ace AS INTEGER '       ace 1 or 11?
  55.     Total AS INTEGER '     cards total
  56.  
  57. DIM SHARED cardDeck AS LONG '                     image file handle
  58. DIM SHARED deck(1 TO 52) AS CardType, deckIndex ' deck and last card dealt
  59. DIM SHARED players(1 TO 2) AS PlayerType '        players
  60. DIM SHARED blockDealerCard '
  61.  
  62. SCREEN _NEWIMAGE(xmax, ymax, 32)
  63. _DELAY .25
  64.  
  65. players(player).ID = "Player": players(player).cardY = 420
  66. players(dealer).ID = "Dealer": players(dealer).cardY = 100
  67. players(dealer).name = "Dealer"
  68.  
  69. DIM i, choice, pick2$(0 TO 2), pick3$(0 TO 3) ' declare main variables
  70. pick2$(1) = "Hit": pick2$(2) = "Stand": pick2$(0) = "Quit"
  71. pick3$(1) = "Hit": pick3$(2) = "Stand": pick3$(3) = "Double Down": pick3$(0) = "Quit"
  72.  
  73. GetStarted 'sets bColor to Johnno splash screen backcolor
  74.     IF players(player).setbet = 0 THEN '                                     Get Bet (if not preset)
  75.         CLS
  76.         ShowAndTell 10, "You have " + _TRIM$(STR$(players(player).chips)) + " chips."
  77.         LOCATE 11, 25: INPUT "(0 quits) Enter your bet > ", players(player).bet
  78.         IF players(player).bet = 0 THEN 'quits
  79.             'updateBankAcct players(player).name, players(player).chips    should now be constantly updated
  80.             SYSTEM
  81.         ELSEIF players(player).bet > 1000 THEN 'you can bet up to half your chips
  82.             IF players(player).chips < 2000 THEN
  83.                 players(player).bet = 1000
  84.             ELSEIF players(player).bet > .5 * players(player).chips THEN 'half because player can Double Down
  85.                 players(player).bet = .5 * players(player).chips
  86.             END IF
  87.         END IF
  88.     ELSE 'using preset betting set at beginning of the game see GetStarted
  89.         players(player).bet = players(player).setbet
  90.     END IF
  91.  
  92.     ClearPlayers 'and screen
  93.     blockDealerCard = -1
  94.     FOR i = 1 TO 2 '                                                         2 Cards for Each Player
  95.         PlayerAddCard player
  96.         PlayerAddCard dealer
  97.     NEXT
  98.     blockDealerCard = 0
  99.     IF players(player).Total = 21 THEN '                                   Handle all the Blackjacks
  100.         ShowAndTell 36, "Blackjack!"
  101.     END IF
  102.     IF players(dealer).Total = 21 THEN '  Dealer BJ
  103.         PlayerShow (dealer)
  104.         ShowAndTell 16, "Dealer has Blackjack!"
  105.         IF players(player).Total <> 21 THEN
  106.             players(player).chips = players(player).chips - players(player).bet
  107.             players(dealer).chips = players(dealer).chips + players(player).bet
  108.             roundUpdate
  109.             ShowAndTell 38, "You lose" + STR$(players(player).bet)
  110.         ELSE
  111.             ShowAndTell 38, "Push, Dealer and Player have Blackjack."
  112.         END IF
  113.         _DELAY .5
  114.         GOTO skip
  115.     END IF
  116.     IF players(player).Total = 21 THEN ' Player BJ! pays 1.5 times bet
  117.         players(player).chips = players(player).chips + 1.5 * players(player).bet
  118.         players(dealer).chips = players(dealer).chips - 1.5 * players(player).bet
  119.         roundUpdate
  120.         ShowAndTell 38, "You win" + STR$(1.5 * players(player).bet)
  121.         GOTO skip
  122.     END IF
  123.     WHILE players(player).Total < 21 '                                                 Player's turn
  124.         IF LEN(players(player).hand) = 4 THEN
  125.             choice = getButtonNumberChoice%(pick3$())
  126.         ELSE
  127.             choice = getButtonNumberChoice%(pick2$())
  128.         END IF
  129.         IF choice = 1 THEN '                                                          Hit  Option
  130.             PlayerAddCard player
  131.             ShowAndTell 36, SPACE$(50)
  132.         ELSEIF choice = 3 AND LEN(players(player).hand) = 4 THEN '             Double Down Option
  133.             players(player).bet = 2 * players(player).bet
  134.             PlayerAddCard player
  135.             ShowAndTell 36, SPACE$(50)
  136.             EXIT WHILE
  137.         ELSEIF choice = 0 THEN '                                                              quit
  138.             'updateBankAcct players(player).name, players(player).chips  should be updated after each round
  139.             SYSTEM
  140.         ELSE 'stand                                                                           Stand
  141.             ShowAndTell 36, SPACE$(50)
  142.             EXIT WHILE
  143.         END IF
  144.     WEND
  145.     IF players(player).Total > 21 THEN '                                                Oops! busted
  146.         ShowAndTell 36, "Busted!"
  147.         ShowAndTell 38, "You lost" + STR$(players(player).bet)
  148.         players(player).chips = players(player).chips - players(player).bet
  149.         players(dealer).chips = players(dealer).chips + players(player).bet
  150.         roundUpdate
  151.         _DELAY 2
  152.         GOTO skip
  153.     END IF
  154.     PlayerShow dealer '                                                                Dealer's Turn
  155.     WHILE players(dealer).Total < 17
  156.         ShowAndTell 16, "Dealer takes a card."
  157.         _DELAY .5
  158.         PlayerAddCard dealer
  159.     WEND
  160.     IF players(dealer).Total > 21 THEN 'busted                                    Results Accounting
  161.         ShowAndTell 38, "You won" + STR$(players(player).bet)
  162.         players(player).chips = players(player).chips + players(player).bet
  163.         players(dealer).chips = players(dealer).chips - players(player).bet
  164.         roundUpdate
  165.     ELSEIF players(player).Total > players(dealer).Total THEN
  166.         ShowAndTell 38, "You won!"
  167.         players(player).chips = players(player).chips + players(player).bet
  168.         players(dealer).chips = players(dealer).chips - players(player).bet
  169.         roundUpdate
  170.     ELSEIF players(player).Total < players(dealer).Total THEN
  171.         ShowAndTell 38, "You lost" + STR$(players(player).bet)
  172.         players(player).chips = players(player).chips - players(player).bet
  173.         players(dealer).chips = players(dealer).chips + players(player).bet
  174.         roundUpdate
  175.     ELSEIF players(player).Total = players(dealer).Total THEN
  176.         ShowAndTell 38, "Push"
  177.     END IF
  178.     skip:
  179.     'IF players(player).chips = 0 THEN ShowAndTell 40, "Out of chips!"
  180.     _DELAY 4
  181. 'that's all folks the game ends when Player quits inside the main loop
  182.  
  183. SUB GetStarted
  184.     DIM splash&, name$, fline$, fname$, amount AS _INTEGER64, nFound, bankerFee AS _INTEGER64, Founder AS _INTEGER64
  185.     IF LoadCardImages = 0 THEN PRINT "PlayingCards.png failed to load, bye!": END
  186.     splash& = _LOADIMAGE("BJ Splash.png")
  187.     _PUTIMAGE , splash&, 0, (100, 100)-(_WIDTH(splash&) - 100, _HEIGHT(splash&) - 100)
  188.     bColor = POINT(40 * 8, 7 / 8 * _HEIGHT)
  189.     COLOR white, bColor
  190.     _DELAY 3
  191.  
  192.     'quick log in to get started with Bank  to be developed more later
  193.     IF _FILEEXISTS("B+ Banking and Loan.txt") = 0 THEN ' get a file started to track player acounts
  194.         OPEN "B+ Banking and Loan.txt" FOR APPEND AS #1
  195.         PRINT #1, "Founder$" + STR$(0)
  196.         PRINT #1, "Dealer$" + STR$(0)
  197.         CLOSE #1
  198.     END IF
  199.     LOCATE 7 / 8 * _HEIGHT \ 16, 40: INPUT "Please enter Player name "; name$
  200.     OPEN "B+ Banking and Loan.txt" FOR INPUT AS #1
  201.     WHILE EOF(1) = 0
  202.         LINE INPUT #1, fline$
  203.         PRINT fline$
  204.         fname$ = MID$(fline$, 1, INSTR(fline$, "$") - 1)
  205.         IF _TRIM$(fname$) <> "" THEN
  206.             IF fname$ = name$ THEN
  207.                 nFound = 1
  208.                 amount = VAL(MID$(fline$, INSTR(fline$, "$") + 1))
  209.                 IF amount < 0 THEN bankerFee = .1 * ABS(amount) ELSE bankerFee = .05 * amount 'interest made by banker
  210.                 IF amount < 0 THEN amount = 1.1 * amount ELSE amount = 1.05 * amount
  211.                 players(player).name = name$
  212.                 players(player).chips = amount
  213.             ELSEIF fname$ = "Founder" THEN
  214.                 Founder = VAL(MID$(fline$, INSTR(fline$, "$") + 1))
  215.             ELSEIF fname$ = "Dealer" THEN
  216.                 amount = VAL(MID$(fline$, INSTR(fline$, "$") + 1))
  217.                 players(dealer).chips = amount
  218.             END IF
  219.         END IF
  220.     WEND
  221.     CLOSE #1
  222.     IF nFound = 0 THEN
  223.         OPEN "B+ Banking and Loan.txt" FOR APPEND AS #1
  224.         PRINT #1, name$ + "$" + STR$(0) ' zero balance to start
  225.         players(player).name = name$
  226.         players(player).chips = 0
  227.         bankerFee = 0
  228.         CLOSE #1
  229.     END IF
  230.     updateBankAcct "Founder", Founder + bankerFee '              update banker's acct
  231.     updateBankAcct players(player).name, players(player).chips ' update player acct
  232.     CLS
  233.     InitDeck
  234.     IF nFound THEN
  235.         ShowAndTell 6, "Welcome back to B+J Blackjack, " + name$
  236.         ShowAndTell 8, "The banker informs us you have a balance of " + _TRIM$(STR$(players(player).chips))
  237.     ELSE
  238.         ShowAndTell 3, "Welcome to B+ and Johnno's Game of Blackjack, " + name$
  239.         ShowAndTell 5, "An account has been setup for you at B+ Banking and Loan."
  240.         ShowAndTell 6, "Terms are 10% interest payments for negative balance and"
  241.         ShowAndTell 7, "5% interest paid to you for positive balance."
  242.         ShowAndTell 8, "Thankyou for banking with B+."
  243.     END IF
  244.  
  245.     ShowAndTell 10, "The object of the game is to get to 21 or as close as possible without going over."
  246.     ShowAndTell 11, "You will need to get closer than dealer to win your bet (placed before cards are dealt)."
  247.     ShowAndTell 12, "An Ace counts as 1 or 11, points for 2-10 cards are 2-10, Jack, Queen, King are 10."
  248.  
  249.     ShowAndTell 14, "Some Blackjack Terms:"
  250.  
  251.     ShowAndTell 16, "Blackjack is getting a total of 21 with first 2 cards (an Ace and a 10 point card)."
  252.     ShowAndTell 17, "Blackjack pays 1.5 times the bet if the Dealer does not also have Blackjack."
  253.     ShowAndTell 18, "Hit is asking for another card."
  254.     ShowAndTell 19, "Stand is saying, no more cards."
  255.     ShowAndTell 20, "Double Down option occurs after 2nd card."
  256.     ShowAndTell 21, "Double Down is doubling your bet and getting just one more card."
  257.     ShowAndTell 22, "If 2 X Bet > Player's Chips, Bet will be Player's Chips."
  258.     ShowAndTell 23, "A Push is the same as a tie or a draw, no one loses."
  259.  
  260.     ShowAndTell 25, "For this Blackjack Game, you start by owing bank -1000 chips."
  261.     ShowAndTell 26, "If you owe you can bet up to 1000. If have more than 2000, you can bet half of"
  262.     ShowAndTell 27, " any positive amount you have."
  263.     ShowAndTell 29, "If you'd like to set your bet for each round now, enter that Amount (<=1000),"
  264.     ShowAndTell 30, "otherwise, to place your bet before each round, enter 0 now."
  265.  
  266.     ShowAndTell 32, ""
  267.     INPUT ""; players(player).setbet
  268.     IF players(player).setbet > 1000 THEN players(player).setbet = 1000
  269.  
  270. SUB roundUpdate
  271.     updateBankAcct players(dealer).name, players(dealer).chips
  272.     updateBankAcct players(player).name, players(player).chips
  273.  
  274.  
  275. SUB updateBankAcct (name$, amount AS _INTEGER64) ' store players chips back into bank
  276.     DIM accts(0) AS STRING, fline$, fname$, i
  277.     OPEN "B+ Banking and Loan.txt" FOR INPUT AS #1
  278.     WHILE NOT EOF(1)
  279.         LINE INPUT #1, fline$
  280.         fname$ = MID$(fline$, 1, INSTR(fline$, "$") - 1)
  281.         IF _TRIM$(fname$) = name$ THEN
  282.             loadSort name$ + "$" + STR$(amount), accts()
  283.         ELSE
  284.             loadSort fline$, accts()
  285.         END IF
  286.     WEND
  287.     CLOSE #1
  288.     OPEN "B+ Banking and Loan.txt" FOR OUTPUT AS #1
  289.     FOR i = 1 TO UBOUND(accts)
  290.         PRINT #1, accts(i)
  291.     NEXT
  292.     CLOSE #1
  293.  
  294. SUB ClearPlayers
  295.     DIM i
  296.     CLS
  297.     Shuffle
  298.     deckIndex = 0
  299.     FOR i = 1 TO 2
  300.         players(i).hand = ""
  301.         players(i).Ace = 0
  302.         players(i).Total = 0
  303.     NEXT
  304.  
  305. SUB PlayerAddCard (receiver)
  306.     DIM i, di
  307.     deckIndex = deckIndex + 1
  308.     players(receiver).hand = players(receiver).hand + D2$(deckIndex)
  309.     IF deck(deckIndex).value = 1 THEN players(receiver).Ace = -1
  310.     players(receiver).Total = 0
  311.     FOR i = 1 TO LEN(players(receiver).hand) STEP 2
  312.         di = VAL(MID$(players(receiver).hand, i, 2))
  313.         players(receiver).Total = players(receiver).Total + deck(di).points
  314.     NEXT
  315.     IF players(receiver).Total < 12 AND players(receiver).Ace THEN players(receiver).Total = players(receiver).Total + 10
  316.     PlayerShow receiver
  317.  
  318. FUNCTION D2$ (num) 'we have to store 1 or 2 digit numbers in a string to represent hand that is buch of card indexes
  319.     D2$ = LEFT$(_TRIM$(STR$(num)) + "  ", 2)
  320.  
  321. SUB PlayerShow (shower)
  322.     DIM i, xoff, di
  323.  
  324.     IF shower = dealer THEN
  325.         LINE (0, 0)-STEP(xmax, 319), bColor, BF
  326.         ShowAndTell 1, STR$(players(dealer).chips)
  327.         ShowAndTell 2, "BLACKJACK: Dealer must Hit if House Total < 17, Blackjack pays 3:2 unless Push"
  328.         ShowAndTell 5, players(shower).ID
  329.         ShowAndTell 15, "Total =" + STR$(players(shower).Total)
  330.         IF players(shower).Total > 21 THEN ShowAndTell 16, "Busted!"
  331.     ELSE
  332.         LINE (0, 320)-STEP(xmax, 320), bColor, BF
  333.         ShowAndTell 25, "Chips:" + STR$(players(player).chips) + "   Betting:" + STR$(players(player).bet) + " chips."
  334.         ShowAndTell 23, players(shower).ID
  335.         ShowAndTell 35, "Total =" + STR$(players(shower).Total)
  336.         IF players(shower).Total > 21 THEN ShowAndTell 36, "Busted!"
  337.     END IF
  338.     xoff = (xmax - 43 * LEN(players(shower).hand)) / 2
  339.     FOR i = 1 TO LEN(players(shower).hand) STEP 2
  340.         di = VAL(MID$(players(shower).hand, i, 2))
  341.         ShowCardDI xoff, players(shower).cardY, di
  342.         xoff = xoff + 86
  343.     NEXT
  344.     IF shower = dealer AND blockDealerCard AND LEN(players(dealer).hand) = 4 THEN 'hide first card
  345.         xoff = xoff - 86
  346.         ShowCard 2, xoff, players(dealer).cardY, 0, 4
  347.         ShowAndTell 15, " Total = ?? "
  348.     END IF
  349.     _DELAY 1.5
  350.  
  351. SUB ShowAndTell (row, s AS STRING)
  352.     LOCATE row, (xmax / 8 - LEN(s)) / 2: PRINT s;
  353.  
  354. SUB InitDeck
  355.     DIM i, s, v
  356.     DIM suit$(3)
  357.     suit$(0) = "Hearts": suit$(1) = "Clubs": suit$(2) = "Diamonds": suit$(3) = "Spades"
  358.     DIM v$(1 TO 13)
  359.     v$(1) = "Ace": v$(11) = "Jack": v$(12) = "Queen": v$(13) = "King"
  360.     FOR i = 2 TO 10
  361.         v$(i) = _TRIM$(STR$(i))
  362.     NEXT
  363.     i = 0
  364.     FOR s = 0 TO 3
  365.         FOR v = 1 TO 13
  366.             i = i + 1
  367.             deck(i).ID = i
  368.             deck(i).cname = v$(v) + " of " + suit$(s)
  369.             deck(i).value = v
  370.             deck(i).suit = s
  371.             IF v < 11 THEN deck(i).points = v ELSE deck(i).points = 10
  372.         NEXT
  373.     NEXT
  374.  
  375. SUB Shuffle
  376.     DIM i, r
  377.     FOR i = 52 TO 2 STEP -1
  378.         r = INT(i * RND) + 1
  379.         SWAP deck(i), deck(r)
  380.     NEXT
  381.  
  382. SUB ShowCardDI (x AS INTEGER, y AS INTEGER, deckI AS INTEGER)
  383.     ShowCard 2, x, y, deck(deckI).value - 1, deck(deckI).suit
  384.  
  385. 'at scale = 2 need screen space of 76 x 100 for one card
  386. SUB ShowCard (scale, ScrnX, ScrnY, imageCol, imageRow) 'screen x, y  h= horizontal  , v =vertical  image h, v
  387.     DIM ch, cv
  388.     ch = 38 * imageCol + 1: cv = 51 * imageRow + 1
  389.     _PUTIMAGE (ScrnX, ScrnY)-STEP(38 * scale, 50 * scale), cardDeck, 0, (ch, cv)-(ch + 37, cv + 50)
  390.  
  391. FUNCTION LoadCardImages%
  392.     cardDeck = _LOADIMAGE("PlayingCards.png")
  393.     IF cardDeck = -1 THEN EXIT FUNCTION
  394.     _SOURCE cardDeck
  395.     _CLEARCOLOR POINT(0, 0), cardDeck
  396.     _SOURCE 0
  397.     LoadCardImages% = -1
  398.  
  399.  
  400. 'this sub uses drwBtn  Const bColor for background
  401. FUNCTION getButtonNumberChoice% (choice$()) 'developed for this app but likely can use as is elsewhere
  402.     DIM ub, s1, b, oldmouse, mx, my, mb
  403.  
  404.     ub = UBOUND(choice$)
  405.     s1 = (_WIDTH - (ub + 1) * 200 - ub * 20) / 2
  406.     FOR b = 0 TO ub
  407.         drwBtn b * 220 + s1, 270, choice$(b)
  408.     NEXT
  409.     oldmouse = -1
  410.     DO
  411.         WHILE _MOUSEINPUT: WEND
  412.         mx = _MOUSEX: my = _MOUSEY: mb = _MOUSEBUTTON(1)
  413.         IF mb AND oldmouse = 0 THEN
  414.             IF my >= 270 AND my <= 270 + 50 THEN
  415.                 FOR b = 0 TO ub
  416.                     IF mx > b * 220 + s1 AND mx <= b * 250 + s1 + 200 THEN
  417.                         LINE (0, 265)-(_WIDTH, 330), bColor, BF 'erase buttons
  418.                         getButtonNumberChoice% = b: EXIT FUNCTION
  419.                     END IF
  420.                 NEXT
  421.                 BEEP
  422.             ELSE
  423.                 BEEP
  424.             END IF
  425.         END IF
  426.         oldmouse = _MOUSEBUTTON(1)
  427.         _LIMIT 200
  428.     LOOP
  429.  
  430. SUB drwBtn (x, y, s$) '200 x 50   const white = &hffffffff and bColor
  431.     DIM th, tw, gray~&
  432.     th = 16: tw = 8 * LEN(s$): gray~& = _RGB32(190, 190, 190)
  433.     LINE (x, y)-STEP(204, 54), _RGB32(0, 0, 0), BF
  434.     LINE (x - 2, y - 2)-STEP(201, 51), _RGB32(255, 255, 255), BF
  435.     LINE (x, y)-STEP(200, 50), gray~&, BF
  436.     COLOR _RGB32(0, 0, 0), gray~&
  437.     _PRINTSTRING (x + 100 - 4 * LEN(s$), y + 17), s$
  438.     COLOR white, bColor
  439.  
  440. SUB loadSort (insertN AS STRING, dynArr() AS STRING) ' note this leaves dynArr(0) empty! so ubound of array is also number of items in list
  441.     DIM ub, j, k
  442.     ub = UBOUND(dynArr) + 1
  443.     REDIM _PRESERVE dynArr(LBOUND(dynArr) TO ub) AS STRING
  444.     FOR j = 1 TO ub - 1
  445.         IF insertN > dynArr(j) THEN '  GT to LT according to descending or ascending sort
  446.             FOR k = ub TO j + 1 STEP -1
  447.                 dynArr(k) = dynArr(k - 1)
  448.             NEXT
  449.             EXIT FOR
  450.         END IF
  451.     NEXT
  452.     dynArr(j) = insertN
  453.  
  454.  


Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #47 on: June 14, 2020, 11:55:19 pm »
The size of the cloth logo was made larger to demonstrate the style. It can be made the same size as the original logo (or any other size) to accommodate the layout of the cloth.... I will try to throw together a complete table... I hope... lol
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #48 on: June 15, 2020, 02:08:34 am »
Here is the minimal cloth only.

I have made buttons for all three states. On, Off and Hover.

Is this ok? I can add / subtract whatever you need...

In regards to sound: Ogg/Vorbis compresses a little more than MP3, but not sure about using on Windows. WAV files play on most but are usually larger in size than MP3's or OGG's. Midi - for a game like this - maybe not.... lol

The next step would be the sprites for chips (activated using 'BET' button).  The card "shu" in the Scratch game looked interesting. I ca try to simulate a minimal verion of that... Not sure how it will go... Might need some coding wizardry to make the cards slide and flip.... or just have them 'appear' on screen...

ps: I managed to tweak and tile the suit patterns into the cloth... ;)
mockup6.png
* mockup6.png (Filesize: 354.31 KB, Dimensions: 1024x768, Views: 197)
« Last Edit: June 15, 2020, 08:11:08 am by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #49 on: June 15, 2020, 07:14:11 am »
@johnno56  Looking good!

Ogg files are fine with Windows and QB64.

With buttons built into table, don't have to worry about drawing them. But how to make Double Down option disappear when not available? A second table maybe without that button?
No lets draw them as needed (like Scratch Jack) as have been doing that way, we can stack them in as needed or across then bottom, will just show an image instead of drawing the button, can detect mouseover as well.

BTW a slide bar is fine for setting bet, I could draw it in as needed. We could also use an Input box for special (really high) bets. And I have a Message box for Text portion of instructions to player that Scratch's does with bubble.

Along with "BJ Pays 3 to 2"  also need "Dealer must stand on 17, draw on 16" (can be all on same line across).
« Last Edit: June 15, 2020, 07:54:59 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #50 on: June 15, 2020, 08:02:40 am »
All button images have three states. All buttons 'off' initially. When it come to DD being available, use the hover state, then 'on' when clicked. then 'off' when done... Oh, that sounds like a lot of code... Maybe your way will be better... lol

I couldn't remember the "Dealer" notice at the time of making the table.... Consider id done.

I used a "shutterstock" image as inspiration for a sample splash. I will make another that looks more traditional....

splash1.png
* splash1.png (Filesize: 1.23 MB, Dimensions: 1024x576, Views: 224)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #51 on: June 15, 2020, 09:14:02 am »
Hi @johnno56

Yeah, I tried to work in green-minimal.png for background table for game and had to rework all messages and labels to try and fit cards and such off the center logo, didn't work too well and code is a mess BUT I will have to fix it to work with any table cloth you come up with for the background, so I will practice with mockup6.

Buttons and slider bars, I think will work better on top of the background table.

Do you have new set of cards in works or plans?


Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #52 on: June 15, 2020, 10:06:11 am »
I can make the table cloth colour as dark or as light as you need. What are you basic colours for the buttons? Are they like the grey buttons you used in an earlier version? If your buttons are images, send them, and I will try to match. If you are using primitives, may I suggest using black and white for contrast and aligning the buttons, then select a colour(s) when the beastie is working?

So, rather than the 'printed' buttons, you are leaning towards 'normal' buttons, for the table?

I will attach a 'button-less' copy of the table cloth (mockup6b).

mockup6b.png
* mockup6b.png (Filesize: 331.97 KB, Dimensions: 1024x768, Views: 191)
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #53 on: June 15, 2020, 10:11:21 am »
By the way... I have setup the table cloth in layers. The cloth pattern has had a 50% transparency applied to it. So to either lighten or darken it, all I have to do, is place a solid colour layer 'under' the cloth. Easy as. So, if you need it changed, just ask... ;)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #54 on: June 15, 2020, 10:56:57 am »
@johnno56

Mockup6 is working fine!, don't change as I am recoding program layout for it. We might not need x in top right, the window already has it and looks redundant. We can allow esc key as alternative. And I am drawing buttons over the place you have them on table cloth for when you have button graphic ready the mouse will find the same places.

Also if you have new cards, higher definition?, than current, OK to make them a little bigger too

code layout with mockup6.PNG
* code layout with mockup6.PNG (Filesize: 386.25 KB, Dimensions: 1024x768, Views: 229)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #55 on: June 15, 2020, 11:58:36 am »
I was going to ask you what size cards did you need. I have 2 sizes of the same deck: 500x726 and 209x303.

They are all individual. I can put them is a grid the same as your current deck. I can also resize the cards to whatever dimensions you need.

 
KH209x303.png
* KH209x303.png (Filesize: 74.01 KB, Dimensions: 209x303, Views: 202)
10S500x726.png
* 10S500x726.png (Filesize: 46 KB, Dimensions: 500x726, Views: 218)
Logic is the beginning of wisdom.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Blackjack
« Reply #56 on: June 15, 2020, 12:06:49 pm »
THese may be lower quality than you want, but I'd thought id offer it if you would like it.  I used this card set for an iPad game I made in smartbasic.

www.qbasicnews.com/dav/files/cards.png

- Dav

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #57 on: June 15, 2020, 12:09:54 pm »
Thanks, Dav. Much appreciated.
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #58 on: June 15, 2020, 12:43:58 pm »
Ah Dav's cards look better than what I am using now, thanks @Dav

Yes they worked without allot of difficulty. Using them scaled up to 1.35 X's
« Last Edit: June 15, 2020, 01:42:29 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Blackjack
« Reply #59 on: June 15, 2020, 01:29:51 pm »
This is a really great game bplus and Johnno! I'm impressed at the graphics and the game play. Last year I posted my old 1990's game of 21 here on the forum but nobody replied to it. With the game 21 you don't bet so it's just whoever gets to 21 or closest wins. The graphics are simple ASCII stuff. I first made it in QBasic and then made it in ASIC 5.0 (which was like GW-Basic but had a tiny compiler). So last year I made it work with QB64 if any of you want to try it? I'm not trying to compete with yours though of course. Just wanted you all to see what I did too. You can see the post here:


https://www.qb64.org/forum/index.php?topic=1500.msg106998#msg106998