Author Topic: Blackjack  (Read 56358 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #60 on: June 15, 2020, 01:58:45 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


Thanks Ken,

Very odd! The forum search engine is not locating any old Blackjack games, yours Ken and mine, well no, I guess mine is listed first from yesterday. Oh! you call yours 21 OK :)

The first post in this thread was about a month before yours, Ken, in 2019.

qbguy had one a year before ours: https://www.qb64.org/forum/index.php?topic=678.msg5477#msg5477
no reply to that one either, pretty short game.

And in Discussion someone had brought in old spaghetti code.

I almost have an update with the new png's and new layout for Johnno's Table mockup6.png. One little snag to go.
« Last Edit: June 15, 2020, 02:15:36 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #61 on: June 15, 2020, 02:12:51 pm »
OK the snag wasn't a snag, just rounding to 0 which is OK for Founder ;-))

Here is all new working code with all new .png's:

I might play around with the chip images for setting bets, right now that screen is very rudimentary.

Update: attachment removed see latest version later in this thread
« Last Edit: June 17, 2020, 12:44:39 am by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Blackjack
« Reply #62 on: June 15, 2020, 03:43:09 pm »
Ohh wow OK thanks bplus, I had no idea. Oh well.
« Last Edit: June 15, 2020, 03:53:24 pm by SierraKen »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #63 on: June 15, 2020, 06:38:54 pm »
Bplus,

As long as you have not made physical changes to the tablecloth, just replace the cloth with the 'button-less' cloth I posted yesterday, then the 'cloth buttons' will not be seen.

It's not even 9am and I came up with a solution, minor though it be, but a solution none the less... 'without' coffee!!  What could have happened if I 'did' have coffee... I can feel an experiment coming on...

ps: I see you have added a slash screen... It looks familiar... lol  Started working on a more 'traditional' splash. Not sure how 'that' one will turn out or how long it will take. I am experimenting with a couple of my many  little used methods, creativity and imagination.... Yeah. Surprised 'me' as well... By the way... Stop laughing... lol

* clip.png (Filesize: 12.37 KB, Dimensions: 132x98, Views: 374)
« Last Edit: June 15, 2020, 06:51:48 pm by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #64 on: June 15, 2020, 06:50:18 pm »
Bplus,

As long as you have not made physical changes to the tablecloth, just replace the cloth with the 'button-less' cloth I posted yesterday, then the 'cloth buttons' will not be seen.

@johnno56  Oh those are just hand-draw placeholders until we have the button images I think you said you were working on 3 types: plain, mouse over, and activated (pressed) was it? I was using the hand-drawn buttons to get mouse alignments and to test the rest of game and alignments. Maybe the plain was the table cloth button itself?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #65 on: June 15, 2020, 06:53:37 pm »
Ah you posted whilst I was typing... I will bundle the buttons and post them...

Done...

* buttons.zip (Filesize: 19.64 KB, Downloads: 218)
« Last Edit: June 15, 2020, 06:56:11 pm by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #66 on: June 15, 2020, 07:00:46 pm »
Most excellent, I was wondering what I would do tonight :-))

Hey, I just noticed, the instructions in the open screens have not been updated. Nobody starts in the hole -1000, just that every bet is a loan when your balance is less than 0 and it is only official when end the session in the hole.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #67 on: June 15, 2020, 08:13:25 pm »
I hope that they work out for you.

Have you decided on the dimensions of the playing cards? No rush. I figured that, that task, might give 'me' something to do tonight... lol

New splash: No. It's not ready yet... lol  I'm thinking of 'old school black mirror'.
I made a small stack of chips, using opengamart's free sprites, then added a reflection... The size is for the demo... It looks a lot better in my head... lol

chips.png
* chips.png (Filesize: 95.61 KB, Dimensions: 500x1000, Views: 251)
« Last Edit: June 15, 2020, 08:14:42 pm by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #68 on: June 15, 2020, 09:43:30 pm »
Hi @johnno56

Sorry those buttons are not going to work. I need opaque ones to cover the ones on the cloth, just 3 for Hit, Stay and Double Down, oh and a blank for the bet slot to write numbers on and to use when Double Down is not available.

I tried to align the buttons over the cloth ones but they are blurry and smeared because the cloth is fit over different screen dimensions than it's png image, such that if perfectly aligned on left then way off by the time you reach the right side, same with top to bottom.

I don't want to use the plain cloth because that logo is too big and 2nd cloth pattern is cool!

So I can stay with hand drawn ones unless you have better idea. I am thinking doing screen updates while showing and clearing mouse over of buttons wont be fun either. It's pretty clear to me when a mouse is over a button so don't really need that. I could try different colored hand drawn buttons with better font.

If you want to try a cloth without the buttons just logo and tile pattern that would be great because it would get rid of the redundant X box at the top right otherwise we could find some other image to cover it.

The bet slot is going to hold the amount of the bet so it is more a label that will need numbers than a button.

« Last Edit: June 15, 2020, 09:46:23 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #69 on: June 15, 2020, 11:25:58 pm »
@johnno56

Listening to Episode 2 Podcast, they discussed idea of layering screens over main screen, this might work with mouse over or button press image altering... so don't have to redraw main screen with cards and messages already current, cool! So a new cloth without buttons can be worked with mouse over and button press, I think.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #70 on: June 16, 2020, 01:42:15 am »
Here are your opaque buttons....

* buttons.zip (Filesize: 292.22 KB, Downloads: 163)
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Blackjack
« Reply #71 on: June 16, 2020, 02:21:13 am »
@johnno56

Listening to Episode 2 Podcast, they discussed idea of layering screens over main screen, this might work with mouse over or button press image altering... so don't have to redraw main screen with cards and messages already current, cool! So a new cloth without buttons can be worked with mouse over and button press, I think.

Sounds like you guys need a little help in saving and restoring backgrounds.  See if this very simple demo will highlight a *very* easy way to handle things for you:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2.  
  3. 'Draw some background
  4. FOR i = 1 TO 2000
  5.     out$ = out$ + "Hello World "
  6. FOR i = 0 TO 480 STEP 16
  7.     _PRINTSTRING (0, i), MID$(out$, i)
  8. SLEEP 'A sleep statement so we can see our undisturbed background
  9.  
  10. SBG = SaveBackground(100, 100, 300, 200) 'Saved BackGround from (100,100)-(300,200), which is where I'm going to put my "button"
  11.  
  12.     k = _KEYHIT
  13.     SELECT CASE k
  14.         CASE 32 'space
  15.             toggle = NOT toggle
  16.             IF toggle THEN
  17.                 LINE (100, 100)-(300, 200), DarkGray, BF
  18.                 _PRINTSTRING (170, 140), "BUTTON!"
  19.             ELSE
  20.                 RestoreBackground SBG, 100, 100
  21.             END IF
  22.         CASE 27 'esc
  23.             SYSTEM
  24.     END SELECT
  25.     _LIMIT 30
  26.  
  27. FUNCTION SaveBackground (x1, y1, x2, y2)
  28.     SaveBackground = _NEWIMAGE(x2 - x1 + 1, y2 - y1 + 1, 32)
  29.     _PUTIMAGE , 0, SaveBackground, (x1, y1)-(x2, y2)
  30.  
  31. SUB RestoreBackground (Background, x1, y1)
  32.     _PUTIMAGE (x1, y1), Background
  33.  
  34.  

Use the spacebar to toggle the button.  :)

For your needs, just save the background where the buttons will appear, and then you can restore/overwrite them as needed easily enough. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #72 on: June 16, 2020, 12:11:16 pm »
Thanks Steve, looks like we don't have to save a whole screen sized image with button in just the right place and just lay it over current screen. I will check out.

Update: Looks good for my tool box too! Thanks again!
« Last Edit: June 16, 2020, 12:32:53 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #73 on: June 16, 2020, 12:36:33 pm »
@johnno56

Wow! buttons with cloth background that will be interesting to see!

Well with Steve's help and new buttons I have some homework.

Can't wait to see how the buttons work out :) Thanks for quick reply.

@SMcNeill

Update: Oh wait, I think I can just _putimage the button image at x, y location on screen. The problem was that the buttons were transparent and the cloth already had different sized button images embedded in it's image.

If the material did not have a pattern, I could patch over the button areas with clear section but likely to be a chore to patch over and match a pattern cloth perfectly.

So either needed new cloth without embedded buttons or over sized opaque buttons to paste over embedded buttons.
« Last Edit: June 16, 2020, 02:40:14 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Blackjack
« Reply #74 on: June 16, 2020, 03:18:26 pm »
Thanks Steve, looks like we don't have to save a whole screen sized image with button in just the right place and just lay it over current screen. I will check out.

Update: Looks good for my tool box too! Thanks again!

And here's another option you may not have considered -- make the button a hardware image.  Then, you're guaranteed that your button won't affect the main image, because it'll be rendered on a separate layer completely.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2.  
  3. 'Draw some background
  4. FOR i = 1 TO 2000
  5.     OUT$ = OUT$ + "Hello World "
  6. FOR i = 0 TO 480 STEP 16
  7.     _PRINTSTRING (0, i), MID$(OUT$, i)
  8. SLEEP 'A sleep statement so we can see our undisturbed background
  9.  
  10. temp = _NEWIMAGE(200, 100, 32)
  11. _DEST temp 'sw
  12. CLS , DarkGray 'color the button
  13. _PRINTSTRING (70, 40), "BUTTON!" 'Add a highlight to the button
  14. SBGHW = _COPYIMAGE(temp, 33) 'Make that saved button a hardware image
  15. _FREEIMAGE temp 'Free the original software image
  16.  
  17.  
  18.     k = _KEYHIT
  19.     SELECT CASE k
  20.         CASE 32 'space
  21.             toggle = NOT toggle
  22.         CASE 27 'esc
  23.             SYSTEM
  24.     END SELECT
  25.     IF toggle THEN _PUTIMAGE (100, 100), SBGHW 'Now overlay the button over the original image on the screen, using the hardware image
  26.     _DISPLAY 'Display is needed so that the hardware image will render
  27.     _LIMIT 30
  28.  
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!