Liberty BASIC Community Forum
« Card Game Contest! »

Welcome Guest. Please Login or Register.
Aug 16th, 2017, 10:45pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2 3  ...  6 Notify Send Topic Print
 veryhotthread  Author  Topic: Card Game Contest!  (Read 6960 times)
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
smiley Card Game Contest!
« Thread started on: Jul 11th, 2011, 1:05pm »

We have a new contest that begins today and ends on September 1. The details can be found here:

http://basic.wikispaces.com/CardGameContest

Please read the explanation on the wiki page. The contest asks you to create a card game in Liberty BASIC using card image DLLS,

If you don't know how to use any card image DLLs you'll find the DLLs and many tutorials and examples here:

Playing Card Tutorials

There will be a community poll at the end of the contest and the winner will be listed at the Hall of Fame on the contest page:
http://basic.wikispaces.com/Contests

Feel free to post questions and comments here on this thread. If you need help adding your entry to the wiki please post here and we'll be happy to assist you.

Let the (card) games begin!
« Last Edit: Jul 13th, 2011, 12:17pm by Admin » User IP Logged

Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
smiley Re: Card Game Contest!
« Reply #1 on: Jul 13th, 2011, 12:17pm »

Some of you may be thinking that card image DLLs would be difficult to use. Not necessarily!

The cards.dll that is part of Windows requires only a simple init call at the start, a simple termination call at the end and ONE api call to draw a card! It's all explained here, along with a simple demo. There's a more involved demo by Stefan as well.

http://lbpe.wikispaces.com/cardsDLL

User Image

The add-on QCard32.dll is almost as easy to use and it has more features. There is a series of tutorials here:

http://lbpe.wikispaces.com/QCard01

User Image

So, is anybody interested?
grin
User IP Logged

tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
smiley Re: Card Game Contest!
« Reply #2 on: Jul 13th, 2011, 4:07pm »

Quote:
So, is anybody interested?

wink
Looks interesting, though I am not in cards much.

as on DLLS,
notice that cards.dll miss a joker.
QCard32.dll has two.
You can use some resource editor to see/extract all bitmaps from a DLL, then use bitmaps as you wish (though programming using functions provided by DLL probably MUCH easier.)
User IP Logged

damned Dog in the Manger
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
xx Re: Card Game Contest!
« Reply #3 on: Jul 13th, 2011, 4:18pm »

on Jul 13th, 2011, 4:07pm, tsh73 wrote:
You can use some resource editor to see/extract all bitmaps from a DLL, then use bitmaps as you wish (though programming using functions provided by DLL probably MUCH easier.)


I advise against extracting images from DLLs or EXEs unless the license allows you to do so.

This contest requires you to use a DLL for card images, so extracting bmps would not conform to the contest rules.

It's kind of amusing that you suggest extracting individual images. People tend to complain about the distribution files and ask for fewer files or for a single exe from Liberty BASIC. wink
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5471
smiley Re: Card Game Contest!
« Reply #4 on: Jul 14th, 2011, 02:26am »

Hmmm.... I had in mind UNO which is a fast fun family game but it uses it's own card image set. The family I envisaged was Bart on one side, Homer on the other, Marge in the background and you as the fourth player.

I wonder if you can shoehorn your own images into the .dll? Never pulled a .dll appart before but I assume the images are just bytes in the file so in theory I should be able to create a copy .dll with my own card images?

I will be trying to write something for the contest.
User IP Logged

tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
smiley Re: Card Game Contest!
« Reply #5 on: Jul 14th, 2011, 02:59am »

Never heard of UNO so I went Wikipedia.
Look:
Quote:
Uno ( /ˈunoʊ/; from Italian and Spanish for 'one') is a card game played with a specially printed deck (see Mau Mau for an almost identical game played with normal playing cards).

So you can use both card set - dll one and your own - and you'll get two games for price of one!
smiley
User IP Logged

damned Dog in the Manger
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
smiley Re: Card Game Contest!
« Reply #6 on: Jul 14th, 2011, 08:32am »

Hi all, Here's my solitaire game. QCARD32.DLL is required in the LB folder

The object of this game is to place cards in pairs over existing cards such that the value of each pair of covered cards adds up to eleven.
(e.g. 6 & 5, 7 & 4, Jack & Ace, etc)

Suits are irrelevant. Ace counts as one, picture cards count as ten.

A Jack-Queen-King sequence is also permitted.

Code:
    nomainwin
    dim saved(3,4), deck(52,2), pos(9,4)
    for a=0 to 3
        for b= 1 to 13
            deck(a*13+b,1)=a*13+b:deck(a*13+b,2)=b
        next b
    next a
    restore[posn]
    for a=1 to 9
        read b,c:pos(a,1)=b:pos(a,2)=c
    next a

[posn]
    data 10,2,110,2,210,2,10,102,110,102,210,102,10,202,110,202,210,202
    WindowWidth=310:WindowHeight=380:UpperLeftX=1:UpperLeftY=25
    menu #1,"&Options","&Deal",[deal],"E&xit",[quit]
    graphicbox #1.g,0,0,300,330
    open "Patience" for window_nf as #1
    #1 "trapclose [quit]"
    #1.g "setfocus; when leftButtonUp [checkIndex]"
    hBox=hwnd(#1.g)
    open "qcard32.dll" for dll as #qc
    calldll #qc,"InitializeDeck",hBox as long,r as long

[deal]
    dealt=0:clicks=0:card=0:score=0:pic=0:reclaim=0:dim jqk(3):nomore=0
    calldll #qc,"SetDefaultValues",r as void
    gosub[shuffle]
    #1.g "down; fill 10 190 225"
    #1.g "backcolor 10 190 225"
    for i=1 to 9
        Call DealCard hBox,deck(i,1),pos(i,1),pos(i,2)
        pos(i,3)=deck(i,1):pos(i,4)=deck(i,2)
        dealt=dealt+1
    next i
    gosub[moretest]

[wait]
    #1.g "place 10 320"
    #1.g "\Cards Left:";52-dealt;"  "
    if nomore=1 then
        confirm "Play Again?";q$: if q$="yes" then[deal] else[quit]
    end if
    wait

[checkIndex]
    x=MouseX:y=MouseY
    for a= 1 to 9
        if (x>pos(a,1)) and (x<pos(a,1)+70) and (y>pos(a,2)) and (y<pos(a,2)+95) then exit for
    next a
    card=a:if a=10 then card=0:goto[wait]
    dealt=dealt+1
    #1.g "place 80 320":#1.g "\";52-dealt;"  "
    clicks=clicks+1
    if pos(card,4)>10 then
        score=score+10
    else
        score=score+pos(card,4)
    end if
    saved(clicks,1)=card:saved(clicks,2)=pos(card,3):saved(clicks,3)=pos(card,4)
    Call DealCard hBox,deck(dealt,1),pos(card,1),pos(card,2)
    if pos(card,4)<11 then[2pictest]
    pic=pic+1
    if jqk(pos(card,4)-10)=pos(card,4) then[gotpic]
    jqk(pos(card,4)-10)=pos(card,4)
    pos(card,3)=deck(dealt,1):pos(card,4)=deck(dealt,2)
    if pic=3 then[zeroscore]
    goto[2clicktest]

[gotpic]
    select case pos(card,4)
        case 11
            name$="J"
        case 12
            name$="Q"
        case 13
            name$="K"
    end select
    notice "Already Have a ";name$;"!":dim jqk(3)

[redeal]
    reclaim=clicks:gosub[redealold]

[zeroscore]
    score=0:pic=0:clicks=0:reclaim=0:dim jqk(3):gosub[moretest]:goto[dealtall]

[2pictest]
    if pic=2 then notice "Can't Have ";pos(card,4);" in J-Q-K Run!":dim jqk(3):goto[redeal]

[2clicktest]
    pos(card,3)=deck(dealt,1):pos(card,4)=deck(dealt,2)
    if pic>1 then[dealtall]
    if clicks=2 then
        reclaim=clicks:clicks=0
        if score <> 11 then
            dim name$(2)
            for a= 1 to 2
                name$(a)=str$(saved(a,3))
                select case name$(a)
                    case "1"
                        name$(a)="A"
                    case "11"
                        name$(a)="J"
                    case "12"
                        name$(a)="Q"
                    case "13"
                        name$(a)="K"
                end select
            next a
            notice name$(1)+" and "+name$(2)+" is not 11!":gosub[redealold]
        else
            score=0:reclaim=0:pic=0:dim jqk(3):gosub[moretest]
        end if
    end if

[dealtall]
    if dealt=52 then
        confirm "You Did it! Play Again?";q$
        if q$="yes" then [deal] else [quit]
    end if
    goto[wait]

[shuffle]
    for a=1 to 500
        b=int(rnd(0)*52)+1:c=int(rnd(0)*52)+1
        d=deck(b,1):dd=deck(b,2)
        deck(b,1)=deck(c,1):deck(b,2)=deck(c,2)
        deck(c,1)=d:deck(c,2)=dd
    next a
    return

[redealold]
    for a=1 to reclaim
        Call DealCard hBox,saved(a,2),pos(saved(a,1),1),pos(saved(a,1),2)
        pos(saved(a,1),3)=saved(a,2):pos(saved(a,1),4)=saved(a,3)
    next a
    dealt=dealt-reclaim:score=0:reclaim=0:pic=0:dim jqk(3):return

[quit]
    close #qc:close #1:end

[moretest]
    more=0:nomore=0
    for a= 1 to 8
        for b=a+1 to 9
            if pos(a,4)+pos(b,4)=11 then more=1
        next b
    next a

    jqk=0
    for a=1 to 9
        if pos(a,4)>10 then jqk=1
    next a
    for a= 1 to 9
        if pos(a,4)=1 and jqk=1 then more=1
    next a

    dim jqktest(3)
    for a=1 to 9
        if pos(a,4)>10 then jqktest(pos(a,4)-10)=1
    next a
    if jqktest(1)=1 and jqktest(2)=1 and jqktest(3)=1 then more=1
    if more=0 then nomore=1: notice "No More Moves"
    return

Sub DealCard hndle,nC,x,y
    calldll #qc,"DealCard",hndle as long,nC as long,x as long,y as long,r as void
    End Sub
 


I had to flowchart this little sucker, it was a bit of a headache!

Have fun.

JohnnyD


User IP Logged

Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
smiley Re: Card Game Contest!
« Reply #7 on: Jul 14th, 2011, 08:47am »

JohnnyD, that's great! I've put it on the wiki and listed it on the contest page.

I have one suggestion. Add a "help" item to the menu and either give a notice with the rules or open a text window to display the rules. I had to refer back to your message to discover the correct way to play (after the game scolded me a few times!)

User IP Logged

JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
smiley Re: Card Game Contest!
« Reply #8 on: Jul 16th, 2011, 6:49pm »

Hi Alyce,

Thanks for the comments! It is a good five years or so since I did this and it was for personal use, so never thought of adding a helpfile. When I saw the contest, I just jumped right in with the entry with no thought of help.

Here's a slightly tidied & tweaked version with help added:

Code:
    nomainwin
    dim saved(3,4):dim deck(52,2):dim pos(9,4)
    for a=0 to 3
        for b= 1 to 13
            deck(a*13+b,1)=a*13+b:deck(a*13+b,2)=b
        next b
    next a
    restore[posn]
    for a= 1 to 9
        read b,c:pos(a,1)=b:pos(a,2)=c
    next a

[posn]
    data 10,2,110,2,210,2,10,102,110,102,210,102,10,202,110,202,210,202
    WindowWidth=306:WindowHeight=382
    UpperLeftX=(DisplayWidth-WindowWidth)/2
    UpperLeftY=(DisplayHeight-WindowHeight)/2
    menu #1,"&Options","&Deal",[deal],"&Help",[help],"E&xit",[quit]
    graphicbox #1.g,0,0,300,330
    open "Patience" for window_nf as #1
    #1 "trapclose [quit]"
    #1.g "setfocus; when leftButtonUp [checkIndex]"
    hBox=hwnd(#1.g)
    open "qcard32.dll" for dll as #qc
    calldll #qc,"InitializeDeck",hBox as long,r as long

[deal]
    dealt=0:clicks=0:card=0:score=0:pic=0
    reclaim=0:dim jqk(3):nomore=0
    calldll #qc,"SetDefaultValues",r as void
    gosub[shuffle]
    #1.g "down; fill 10 190 225"
    #1.g "backcolor 10 190 225"
    for i=1 to 9
        Call DealCard hBox,deck(i,1),pos(i,1),pos(i,2)
        pos(i,3)=deck(i,1):pos(i,4)=deck(i,2)
        dealt=dealt+1
    next i
    gosub[moretest]

[wait]
    #1.g "place 10 320"
    #1.g "\Cards Left:";52-dealt;"  "
    if nomore=1 then
        confirm "Play Again?";q$
        if q$="yes" then
            goto[deal]
        else
            goto[quit]
        end if
    end if
    wait

[checkIndex]
    x=MouseX:y=MouseY
    for a= 1 to 9
        if (x>pos(a,1)) and (x<pos(a,1)+70) and (y>pos(a,2)) and (y<pos(a,2)+95) then exit for
    next a
    card=a
    if a=10 then
        card=0:goto[wait]
    end if
    dealt=dealt+1
    #1.g "place 80 320":#1.g "\";52-dealt;"  "
    clicks=clicks+1
    if pos(card,4)>10 then
        score=score+10
    else
        score=score+pos(card,4)
    end if
    saved(clicks,1)=card:saved(clicks,2)=pos(card,3):saved(clicks,3)=pos(card,4)
    Call DealCard hBox,deck(dealt,1),pos(card,1),pos(card,2)
    if pos(card,4)<11 then[2pictest]
    pic=pic+1
    if jqk(pos(card,4)-10)=pos(card,4) then[gotpic]
    jqk(pos(card,4)-10)=pos(card,4)
    pos(card,3)=deck(dealt,1):pos(card,4)=deck(dealt,2)
    if pic=3 then[zeroscore]
    goto[2clicktest]

[gotpic]
    select case pos(card,4)
        case 11
            name$="J"
        case 12
            name$="Q"
        case 13
            name$="K"
    end select
    notice "Already Have a ";name$;"!":dim jqk(3)

[redeal]
    reclaim=clicks:gosub[redealold]

[zeroscore]
    score=0:pic=0:clicks=0:reclaim=0:dim jqk(3)
    gosub[moretest]
    goto[dealtall]

[2pictest]
    if pic=2 then
        notice "Can't Have ";pos(card,4);" in J-Q-K Run!"
        dim jqk(3)
        goto[redeal]
    end if

[2clicktest]
    pos(card,3)=deck(dealt,1):pos(card,4)=deck(dealt,2)
    if pic>1 then[dealtall]
    if clicks=2 then
        reclaim=clicks:clicks=0
        if score <> 11 then
            dim name$(2)
            for a= 1 to 2
                name$(a)=str$(saved(a,3))
                select case name$(a)
                    case "1"
                        name$(a)="A"
                    case "11"
                        name$(a)="J"
                    case "12"
                        name$(a)="Q"
                    case "13"
                        name$(a)="K"
                end select
            next a
            notice name$(1)+" and "+name$(2)+" is not 11!"
            gosub[redealold]
        else
            score=0:reclaim=0:pic=0:dim jqk(3)
            gosub[moretest]
        end if
    end if

[dealtall]
    if dealt=52 then
        confirm "You Did it! Play Again?";q$
        if q$="yes" then [deal] else [quit]
    end if
    goto[wait]

[shuffle]
    for a=1 to 500
        b=int(rnd(0)*52)+1:c=int(rnd(0)*52)+1
        d=deck(b,1):dd=deck(b,2)
        deck(b,1)=deck(c,1):deck(b,2)=deck(c,2)
        deck(c,1)=d:deck(c,2)=dd
    next a
    return

[redealold]
    for a=1 to reclaim
        Call DealCard hBox,saved(a,2),pos(saved(a,1),1),pos(saved(a,1),2)
        pos(saved(a,1),3)=saved(a,2):pos(saved(a,1),4)=saved(a,3)
    next a
    dealt=dealt-reclaim:score=0:reclaim=0:pic=0:dim jqk(3)
    return

[quit]
    close #qc:close #1:end

[moretest]
    more=0:nomore=0
    for a= 1 to 8
        for b=a+1 to 9
            if pos(a,4)+pos(b,4)=11 then more=1
        next b
    next a
    jqk=0
    for a=1 to 9
        if pos(a,4)>10 then jqk=1
    next a
    for a= 1 to 9
        if pos(a,4)=1 and jqk=1 then more=1
    next a
    dim jqktest(3)
    for a=1 to 9
        if pos(a,4)>10 then jqktest(pos(a,4)-10)=1
    next a
    if jqktest(1)=1 and jqktest(2)=1 and jqktest(3)=1 then more=1
    if more=0 then nomore=1: notice "No More Moves"
    return

[help]
    help$="Help"+chr$(13)
    help$=help$+"The object of the game is place pairs of cards on"+chr$(13)
    help$=help$+"existing cards such that each pair of covered cards"+chr$(13)
    help$=help$+"adds up to eleven, until the pack is used up."+chr$(13)+chr$(13)
    help$=help$+"Suit is irrelevant, Ace counts as one,"+chr$(13)
    help$=help$+"picture cards count as ten."+chr$(13)
    help$=help$+"Example moves are 6 & 5, 8 & 3, Jack & Ace, etc."+chr$(13)+chr$(13)
    help$=help$+"A Jack - Queen - King run is also permitted."+chr$(13)
    help$=help$+"Incorrrect moves will be indicated and the deck will back up."
    notice help$ 
    wait

Sub DealCard hndle,nC,x,y
    calldll #qc,"DealCard",hndle as long,nC as long,x as long,y as long,r as void
    End Sub
 


Enjoy!

JohnnyD
User IP Logged

Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1130
xx Re: Card Game Contest!
« Reply #9 on: Jul 16th, 2011, 9:56pm »

on Jul 14th, 2011, 02:26am, Rod wrote:
Hmmm.... I had in mind UNO which is a fast fun family game but it uses it's own card image set. The family I envisaged was Bart on one side, Homer on the other, Marge in the background and you as the fourth player.

I wonder if you can shoehorn your own images into the .dll? Never pulled a .dll appart before but I assume the images are just bytes in the file so in theory I should be able to create a copy .dll with my own card images?

I will be trying to write something for the contest.
As long as the files are the same size then you can replace the images.
User IP Logged

ZPtr.net
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
xx Re: Card Game Contest!
« Reply #10 on: Jul 18th, 2011, 08:16am »

on Jul 16th, 2011, 9:56pm, Dan Teel wrote:
As long as the files are the same size then you can replace the images.


Dan is correct, as usual. smiley

I tested this when Rod asked the question. The cards DLL worked fine when the card images were replaced. I hesitate to advocate this method because I'm not sure of the legality of altering an MS Windows DLL and redistributing it.

I've added to the Windows cards.dll tutorial. It now includes a second drawing function which allows you to use custom dimensions for the card display.

http://lbpe.wikispaces.com/cardsDLL

It is still quite easy to use this DLL, even with the extended drawing function. The cdtDrawExt adds arguments for the width and height of the card, but is otherwise identical to the cdtDraw function.

User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5294
xx Re: Card Game Contest!
« Reply #11 on: Jul 18th, 2011, 3:14pm »

on Jul 18th, 2011, 08:16am, Alyce Watson wrote:
I hesitate to advocate this method because I'm not sure of the legality of altering an MS Windows DLL and redistributing it.

Any DLL shipping with Windows includes a copyright and Microsoft will send some lawyers to you, if you violate it wink
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Janet
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 4111
xx Re: Card Game Contest!
« Reply #12 on: Jul 18th, 2011, 10:04pm »

on Jul 16th, 2011, 6:49pm, JohnnyD wrote:
Hi Alyce,

Thanks for the comments! It is a good five years or so since I did this and it was for personal use, so never thought of adding a helpfile. When I saw the contest, I just jumped right in with the entry with no thought of help.
Enjoy!

JohnnyD


Thanks for the help file, JohnnyD. grin
Nice game. Very addictive. I'm hoping others are quietly testing the waters and will submit entries over the next few weeks. I wasn't sure myself if I wanted to program a solitaire game or a two player game. I used to play Spite and Malice. That would be fun to program, but I'm not sure I have the 'card savvy' to come up with a challenging algorithm. Some links I found helpful

Rules of Solitaire Games

Alphabetical Listing of MultiPlayer Card Games

At the above site is a link to Invented Games. I found one game to be entertaining and doesn't require a ton of AI for computer game. We'll see what happens.

Thanks to Alyce for putting together such a wonderful qCards32.dll tutorial. This is a wonderful tool and I'm enjoying learning how to use it. smiley


User IP Logged

Windows 7 Professional, SP1, 64 bit Intel Core i5-4200U CPU @ 1.60 GHz 2.30 GHz 6.00 GB

"I am very busy finding out what people mean by what they say." -
Admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 14485
smiley Re: Card Game Contest!
« Reply #13 on: Aug 1st, 2011, 10:40am »

Those are great links, Janet!

My entry is an enhanced version of my memory game.

http://basic.wikispaces.com/AWCardGameContest

Is anybody else considering this? There is PLENTY of time to start a program, even if you've never used one of the DLLs. The cards.dll is very, very easy to use.

So, how about it? Is anybody else "game" for this contest?
User IP Logged

jaba
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 325
smiley Re: Card Game Contest!
« Reply #14 on: Aug 1st, 2011, 11:39am »

Alyce said: Quote:
My entry is an enhanced version of my memory game.

Alyce,
I'm experiencing odd behavior when trying your game. I'm not able to re-select any cards.

If I select two cards, then close the window, I see a second window which is under the first, and it displays all the cards face up. The first card position seems to hold a stack of all the cards that were initially turned up, and they close one at a time until the stack is empty, whereby the second window then closes.

Probably not what you had in mind?

jaba
User IP Logged

If I didn't first try it and get it wrong, I may never have figured out how to get it right.
Pages: 1 2 3  ...  6 Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls