|
Post by Rod on Feb 16, 2023 15:20:51 GMT
Back to basic games. This is a link to some card sprites and some code to load them up. It is a very basic demo. I will post more soon and show how to move the cards with the mouse. 'version8 9/3/23 'increased verticle gapping 'fixed refusal to move, reserve pile flipping 'fixed logic error allowing face down column moves 'added back in placeholder and reserve circle marker 'fixed reserve pile flipping for less than three cards remaining 'fixed column move issue that Anatoly debugged 'fixed zero cards remaining flip issue. 'I have left in debugging code just in case, enable the mainwin if you find an issue and let me see the audit trail. gamebin.webs.com/CardSprites.zipThere are now three bas files, animate.bas which is a simpler demo of card animation and mouse drag and drop. Also solitaire.bas which is more complex because it resizes to full screen. Click the card to move, click it again if it isn't in the location you want. Finally a rudimentary Blackjack.bas that shows sprite based numerals. It plays a very basic game to itself, I don't understand Blackjack well enough to code a complete game its just first steps in gameplay and scoring.
|
|
|
Post by plus on Feb 17, 2023 17:11:56 GMT
I have some Gin hand analyzer code for best hand score or something I've been meaning to add card images. But that wasn't holdup, making an AI smart enough to play against was the holdup. Hmm... might check that code out and do a JB version. I have Grim Rummy and Grin Rummy versions that are variations on Gin Rummy that did take an easier AI to make and play against. I look forward to your demo's Rod
|
|
|
Post by Rod on Feb 17, 2023 18:05:49 GMT
Cool. This demo is getting the mouse involved. The card loading is simplified and I introduce the deck() array so we can shuffle and play cards. The card info remains in card()
This code lets the mouse pick drag and drop or turn the card.
Later I will try and show some animation techniques to liven up the card play.
code removed, correct code in first post.
|
|
|
Post by plus on Feb 18, 2023 19:43:12 GMT
Hi Rod,
I had to do this to get your code to run, otherwise it says point.bmp not found.
'loadbmp "point", "point.bmp" '#w.g "addsprite point point" '#w.g "spritexy point -10 -10"
|
|
|
Post by Rod on Feb 18, 2023 20:08:04 GMT
I need to update the graphics, will post a new link soon. I am busy pushing the code into subs as close to the original cards.dll as I can get. We never saw that on this forum but Liberty always had a card game .dll example.
Point.bmp is simply a 1x2 pixel black bmp. It serves as an unseen sprite that follows the mouse and collides with whatever is beneath it.
|
|
|
Post by Rod on Feb 21, 2023 11:49:42 GMT
I have updated the link in the first post. Animate.bas will show off some of the card functions. Lots more still to do. Any ideas about card functions are very welcome. Not quite as cool as Anatoly's Forth but coding for cards is proving to be an interesting challenge.
This is an extract of the code to show what I am about with functions and subs.
'load card images call loadcardimages
call scaledeck 100 'scales entire deck call sortdeck 2 'orders all undealt cards in deck 1=ordered 2=random call showdeck 10,100,up 'undealt cards in a line starting at x,y,face up or down(for testing) call pause 2000 call movedeck 446,273,down 'undealt cards placed at x,y,face up or down call dealcard 1,5,up 'deal player n,x cards face up or down call dealcard 2,5,up 'dealcard also sorts the hand on value and displays the hand with drawhand call dealcard 3,5,up call dealcard 4,5,up call pause 2000 call dealcard 1,2,down call dealcard 4,2,down call pause 2000 call fliphand 1,up 'flip player n's hand face up or down call fliphand 4,up call sorthand 1,card 'sort player n's hand by value or card call drawhand 1 'redraws the players hand call pause 2000 call movecard 1,400,200 'move card cc to x,y call flipcard 1,up 'flip card cc face up or down call setblock 1,1 'block or unblock card cc 1=blocked 0=clear print getsuit(1) 'query suit print getvalue(1) 'query value print getcolor(1) 'query color print getface(1) 'query face up or down print isblock(1) 'query blocked or unblocked
|
|
|
Post by plus on Feb 21, 2023 23:23:35 GMT
Looks like it's ready for my Rummy code
|
|
|
Post by Rod on Mar 2, 2023 15:18:34 GMT
Well a game at long last. Debugging was a pain. So Solitaire, not sure it is completely bug free but it seems to play ok. It actually did not use many of the core functions, mostly flip and move. Next step is to make the deck resizable in a predictable way. Cards probably too big for some screens. So the download link is updated in the first post. but this is it.This is the code, it is click and play right now I have yet to implement the drag and drop part but the components are there. So just click on the card you think should be played and it will fly off to a valid position, click again if it hit the wrong spot. code removed, corrected code in first post
|
|
|
Post by cundo on Mar 2, 2023 22:25:17 GMT
My screen is 1920x1080, and lately I can't run JB games without mod them
|
|
|
Post by Rod on Mar 3, 2023 7:58:59 GMT
Cundo, can you expand on that? What size would you prefer? Full screen or a specific size. I am just about to make the card game resizeable, but what strategy to use?
|
|
|
Post by cundo on Mar 3, 2023 22:28:05 GMT
I usually adjust the game screen to the DisplayWidth and DisplayHeight Variables. But I'm not sure what would be the best solution I'm on my notebook now, but I have a very small netbook as well. With a smaller screen. Both Windows 10. I remember my old times programming on my desktop Pentium II for years, that was 800x600 haha. Good times.
|
|
|
Post by Rod on Mar 4, 2023 14:55:13 GMT
Ok, this is a version that will grab your whole screen. I have tried it from 800x600 to 1920x1080. The cards resize and reposition automatically. You can set it to play at whatever resolution you prefer. Set ww and wh. The one thing that I have stumbled on is an old bug. If you resize a sprite the collision detection does not work as well as for the sprites natural size. I find you have to click in the top left quadrant of the card image to have the collision recognised.
Done for now unless someone expresses some interest or exposes a bug.
code removed corrected code in first post
|
|
|
Post by cundo on Mar 4, 2023 20:33:07 GMT
It plays so smooth!
|
|
|
Post by Rod on Mar 5, 2023 18:46:18 GMT
Still bug hunting, sigh. Flipping the deck is not dealing with deck position 52 well. It is duplicating an already played card and sucking it back into the deck even if it has been played. Need to leave it for a while, been staring at the problem for a couple of days and not seeing it!
Edit:
Sleep helps, I have been thinking about the pack inverted. I need to pop the last few cards to the top of the pack and not keep burying them at the bottom,
|
|
|
Post by Rod on Mar 6, 2023 14:15:08 GMT
Bug free version 5 code now in first post.
|
|