Playing Card Object

User projects written in or related to FreeBASIC.
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Playing Card Object

Postby bcohio2001 » Mar 18, 2013 19:36

In the "Archives" a while back was rdc's Card Object.
Here is my take on it.

Files at Github:
Playing Card Object

See my last post for changes made.
Any comments or questions welcome.
Last edited by bcohio2001 on Nov 23, 2019 14:41, edited 7 times in total.
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Mar 21, 2013 19:37

Version 0.2 March 21, 2013
Added:
-- Trade Sub in CardGroup type
-- CreateNSPlayDeck sub to create "non-standard" deck of cards, such as a Euchre deck.
-- Init cards through INI file instead of DATA statements.
-- Able to change card back displayed.

Future plans:
-- "Special" cards or graphics.
-- Rework original bmp file to make smaller, the bottom row is half empty.
-- Find another graphic of cards.
-- Find and impliment a "rotation" algorhythm.
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Mar 25, 2013 22:39

Version 0.3 March 25, 2013
-- Clarified INI requirements at bottom of Cards.bi file.
-- In CardGroup type:
---- Added NumSelected function to return the number of selected cards.
---- Added TakeSelCards to remove them.
---- Overloaded to hold the selected cards for later use.
---- Added AddSelCards to take the selected cards. (Be sure not to excede Maximum cards!)
---- Added MoveSelCards to move selected cards from one CardGroup directly to another CardGroup. (Be sure not to excede Maximum cards!)
---- Added Shuffle, DIFFERENT FROM "Card.Shuffle" which shuffles the whole deck.
---- ALL values are now private.
------ The number of cards in the group can be retrieved by the NumCards property.
------ Use IsMovable property to retrieve the "arrangeablity" of the group.
------ Call SetLoc to set/change where group will start being displayed.
------ Call SetSize to set/change maximum amout of cards allowed.
------ Call SetDirection to set/change how the cards will be displayed.
------ Call SetArrange to set/change arrangablity or how "pile" is displayed.
------ Call SetEmpty to set/change what is shown if no cards will be displayed.

Future plans:
-- "Crunch" and "Hover" for when a group "goes off" screen.
-- Rework original bmp file to make smaller, the bottom row is half empty.
-- Find another graphic of cards.
-- Find and impliment a "rotation" algorhythm.
rdc
Posts: 1725
Joined: May 27, 2005 17:22
Location: Texas, USA
Contact:

Re: Playing Card Object

Postby rdc » Apr 01, 2013 0:21

Cool stuff.
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Apr 21, 2013 17:06

rdc wrote:Cool stuff.

High praise from the "creator"

Also, an update:
Version 0.4 April 21, 2013
-- Modified "ini" files to increase "LabelHeight".
-- Card and CardGroup objects are now in seperate .bi files.
-- Support other graphic formats, using FreeImage.
---- Latest dll included. (3.15.4) FreeImage.bi reports (3.15.1)
-- In CardGroup type:
---- Right click and hold to "arrange" cards.
---- The "right to left" or "bottom to top" corrected, but a graphical glitch still needs to be addressed.
---- Show less of card, hide part of the "label", for when a group would "go off" screen.
---- When hovering over a "hidden" card, will display the card.

Future plans:
-- Rework original bmp file to make smaller, the bottom row is half empty.
-- Find another graphic of cards.
-- Find and impliment a "rotation" algorhythm.
-- Allow SetSize to accept "0" for a "dynamic" group.
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Mar 10, 2016 18:01

http://www.mediafire.com/download/n1d5tjkj42tjse1/Cards_0_05.zip

Version 0.5 March 10, 2016
-- Using "FBImage" to load graphic files. (dlls included)
-- Two Graphics and their Ini files included
---- "card-deck-01.jpg" "CD1Jpg.ini"
---- "cards.bmp" "Standard.ini" This is the default.
-- Ini data has changed.
---- Source for creation of new Ini files -- "Ini Creator.bas"
------ Keyboard control only! See "Ini Creator.txt"
-- In CardGroup type
---- Eliminated Private tag.
---- Removed GroupClick function.
-- Added AllGroups Type
---- Register saves a pointer to a CardGroup.
---- Scan, a replacement for CardGroup.GroupClick. Scans all registered groups for mouse event instead of main program looping and missing event.
---- Arrangement of cards in a group, if allowed.
-- Seperated code from both 'bi' files.

Future plans:
-- Drag and drop into/onto groups.
-- Rework original bmp file to make smaller, the bottom row is half empty.
-- Find and impliment a "rotation" algorhythm.
-- Allow SetSize to accept "0" for a "dynamic" group.
Last edited by bcohio2001 on May 17, 2016 23:09, edited 1 time in total.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Playing Card Object

Postby datwill310 » Mar 17, 2016 23:52

This looks amazing, but I don't know where to "start"!
I tried compiling Solitare.bas but it threw loads of errors concerning "Unsupported statement in -gen gcc mode".
Any guide lines on how to use this library?
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Mar 18, 2016 6:10

datwill310 wrote:This looks amazing, but I don't know where to "start"!

Refer to test programs for ideas.

datwill310 wrote:I tried compiling Solitare.bas but it threw loads of errors concerning "Unsupported statement in -gen gcc mode".

I use FBEdit's quick run for all my tests. Which I believe is just "fbc -console xxxxxx.bas", or something to that effect.
So I do not know which statements you are referring to.

datwill310 wrote:Any guide lines on how to use this library?

Er....documentation is not my strong point. A lot of comments in the code. The sample/test code tests most, if not all, aspects.
St_W
Posts: 1496
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Playing Card Object

Postby St_W » Mar 18, 2016 12:02

datwill310 wrote:I tried compiling Solitare.bas but it threw loads of errors concerning "Unsupported statement in -gen gcc mode".

gcc is used by default for 64-bit and ARM builds of FreeBasic. Seems the library doesn't support that.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Playing Card Object

Postby datwill310 » Mar 18, 2016 12:32

St_W wrote:
datwill310 wrote:I tried compiling Solitare.bas but it threw loads of errors concerning "Unsupported statement in -gen gcc mode".

gcc is used by default for 64-bit and ARM builds of FreeBasic. Seems the library doesn't support that.

I've tried -gen gas (my system is a 64-bit system, not 32-bit so that didn't work), -gen gcc [explicitly], and -gen llvm (the application to run with was not actually on my computer so so much for that one :D), but none of the three worked. Is this library only for 32-bit systems, then?

bcohio2001 wrote:Refer to test programs for ideas.

bcohio2001 wrote:Er....documentation is not my strong point. A lot of comments in the code. The sample/test code tests most, if not all, aspects.

OK, I will.

bcohio2001 wrote:
datwill310 wrote:I tried compiling Solitare.bas but it threw loads of errors concerning "Unsupported statement in -gen gcc mode".
I use FBEdit's quick run for all my tests. Which I believe is just "fbc -console xxxxxx.bas", or something to that effect. So I do not know which statements you are referring to.

Maybe the problem is that you use a 32-bit system? I doubt my theory there and I am unsure. This is what I got in my FBEdit output control:
FBEdit wrote:Build error(s)
C:\Program Files\FreeBASIC-1.05.0-win64\fbc -gen gcc "Solitare.bas"
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\Cards.bas(366) error 285: Unsupported statement in -gen gcc mode in 'Dim As Any Ptr arg = va_first()'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\Cards.bas(373) error 285: Unsupported statement in -gen gcc mode, found 'va_arg' in 'SuitMult(ArrPos) = va_arg(arg, Integer) - 1'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\Cards.bas(374) error 285: Unsupported statement in -gen gcc mode, found 'va_next' in 'arg = va_next(arg, Integer)'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\Cards.bas(382) error 285: Unsupported statement in -gen gcc mode, found 'va_arg' in 'Pips(ArrPos) = va_arg(arg, Integer) - 1'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\Cards.bas(383) error 285: Unsupported statement in -gen gcc mode, found 'va_next' in 'arg = va_next(arg, Integer)'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\CardGroup.bas(621) error 285: Unsupported statement in -gen gcc mode in 'arg = va_first()'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\CardGroup.bas(624) error 285: Unsupported statement in -gen gcc mode, found 'va_arg' in 'NextPass = va_arg(arg, CardGroup Ptr)'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\CardGroup.bas(635) error 285: Unsupported statement in -gen gcc mode, found 'va_next' in 'arg = va_next(arg, CardGroup Ptr)'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\AllGroups.bas(11) error 285: Unsupported statement in -gen gcc mode in 'arg = va_first()'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\AllGroups.bas(13) error 285: Unsupported statement in -gen gcc mode, found 'va_arg' in 'Passed = va_arg(arg, CardGroup Ptr)'
C:\Users\Daniel\Downloads\Code-Related Apps\Cards_0_05\AllGroups.bas(13) error 132: Too many errors, exiting

Build error(s)
Last edited by datwill310 on Mar 21, 2016 16:04, edited 1 time in total.
St_W
Posts: 1496
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Playing Card Object

Postby St_W » Mar 18, 2016 12:51

datwill310 wrote:Maybe the problem is that you use a 32-bit system? I doubt my theory there and I am unsure. This is what I got in my FBEdit output control: [...]

Variable argument lists are not supported by "-gen gcc"; that's the root problem. Furthermore "-gen gas" is not supported on non-x86 systems. So you either have to use a 32-bit version of FreeBasic (it runs perfectly fine on a 64-bit system too; at least on Windows - certain Linux distributions may cause some troubles) or remove/replace the VarArgs code.

btw (@fxm) is this mentioned anywhere in the documentation? The category page for VarArgs is only minimal without any explanation: http://www.freebasic.net/wiki/wikka.php ... atPgVarArg
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Playing Card Object

Postby datwill310 » Mar 18, 2016 15:00

St_W wrote:Variable argument lists are not supported by "-gen gcc"; that's the root problem. Furthermore "-gen gas" is not supported on non-x86 systems. So you either have to use a 32-bit version of FreeBasic (it runs perfectly fine on a 64-bit system too; at least on Windows - certain Linux distributions may cause some troubles) or remove/replace the VarArgs code.

I think I'll get a 32-bit version of Free BASIC rather than tinker with code which I don't fully understand yet :)! Thanks!
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Mar 18, 2016 15:59

Yes I use the 32 bit version of Freebasic. At this point I see no need for me to 'upgrade' to 64 bit.
I will make a note in my first post about not being compatible with 64 bit compiler.
bcohio2001
Posts: 553
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Playing Card Object

Postby bcohio2001 » Mar 21, 2016 15:39

Version 0.5.1 March, 21, 2016
Added:
-- DOCUMENTATION!!!! "Cards.txt"

Fixes: (hacks)
-- 64 bit compiler, at this time, does not allow variable arguments. (va_first(), va_arg() and va_next() macros.)
---- These 'hacks' have not been tested and they are 'ugly'! But are usable on 32 bit systems.
---- Card.CreateNSPlayDeck Cdecl (NumDecks As Integer, NumSuits As Integer, NumCardsPerSuit As Integer, UseJokers As Integer, DeckName As String="Standard", ...)
------ "Hacked" -> Card.Create_NSPlayDeck(NumDecks As Integer, Suits() As Integer, Pips() As Integer, UseJokers As Integer, DeckName As String="Standard")
---- CardGroup.Trade Cdecl (NumPass As Integer, ...)
------ "Hacked" -> CardGroup.TradeGroups(Others() As CardGroup Ptr)
---- AllGroups.RegisterAll Cdecl (NumGroups As Integer, ...)
------ This was never tested.
------ Added as an afterthought to augment the AllGroups.Register sub which 'registers' one at a time.
-- Modified "Test_Cards_1.bas", "Test_CardGroup_1.bas" and "Test_CardGroup_2.bas" to be 64 bit compliant. "Test_Cards_2.bas" and "Solitare.bas were fine.

Removed:
-- CardGroup.TakeSelCards() sub, with no parameters.
---- It took the cards out of group, but the cards went nowhere.

Future plans:
-- Drag and drop into/onto groups.
-- Rework original bmp file to make smaller, the bottom row is half empty.
-- Find and impliment a "rotation" algorhythm.
-- Allow SetSize to accept "0" for a "dynamic" group.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Playing Card Object

Postby datwill310 » Mar 21, 2016 16:00

bcohio2001 wrote:Version 0.5.1 March, 21, 2016
Added:
-- DOCUMENTATION!!!! "Cards.txt"

Fixes: (hacks)
-- 64 bit compiler, at this time, does not allow variable arguments. (va_first(), va_arg() and va_next() macros.)
---- These 'hacks' have not been tested and they are 'ugly'! But are usable on 32 bit systems.
---- Card.CreateNSPlayDeck Cdecl (NumDecks As Integer, NumSuits As Integer, NumCardsPerSuit As Integer, UseJokers As Integer, DeckName As String="Standard", ...)
------ "Hacked" -> Card.Create_NSPlayDeck(NumDecks As Integer, Suits() As Integer, Pips() As Integer, UseJokers As Integer, DeckName As String="Standard")
---- CardGroup.Trade Cdecl (NumPass As Integer, ...)
------ "Hacked" -> CardGroup.TradeGroups(Others() As CardGroup Ptr)
---- AllGroups.RegisterAll Cdecl (NumGroups As Integer, ...)
------ This was never tested.
------ Added as an afterthought to augment the AllGroups.Register sub which 'registers' one at a time.
-- Modified "Test_Cards_1.bas", "Test_CardGroup_1.bas" and "Test_CardGroup_2.bas" to be 64 bit compliant. "Test_Cards_2.bas" and "Solitare.bas were fine.

Removed:
-- CardGroup.TakeSelCards() sub, with no parameters.
---- It took the cards out of group, but the cards went nowhere.

Future plans:
-- Drag and drop into/onto groups.
-- Rework original bmp file to make smaller, the bottom row is half empty.
-- Find and impliment a "rotation" algorhythm.
-- Allow SetSize to accept "0" for a "dynamic" group.

This is great! Thanks a lot!

Return to “Projects”

Who is online

Users browsing this forum: AndyA and 8 guests