05-28-2005, 06:59 AM
Pages: 1 2
05-29-2005, 12:20 AM
Pyro, you finished your card dealie?
05-29-2005, 01:00 AM
Quote:ok how do you do it
What do you mean, exactly? Do you want to know how to make a program into one, or how to use one that already exsists?
btw:
Thank you for opening the forum back up.
05-29-2005, 01:10 AM
I don't know about pyro, but I'd like to know how to make code into a library. (using FB).
05-29-2005, 01:15 AM
He told me at school that he wanted to make a random card shuffler library that could be ported for different games or programs. What he has is pretty good, maybe he wants to use it for making QBHearts or something (or FBHearts, whatever).
05-29-2005, 10:03 PM
05-30-2005, 02:37 AM
as a matter a fact i wanted to know how to make a librarie out of my card shuffler
05-30-2005, 03:55 AM
hmmm i didnt quite get it
well this is the program im trying to turn into a lib
well this is the program im trying to turn into a lib
Code:
declare sub init(np,nc)
declare function chkcardval(cname$)
declare function chkcardsuit$(cname$)
declare function rndcard$()
dim shared np
dim shared nc
'dims the player array
'the first d is the number of players
'the second d is the number of in wich he gets the card
'(sorry cant explain think of any other way to explain that)
dim shared player$(np,52)
dim shared dummie$(np,52)
randomize timer
function rndcard$()
SS=int(rnd*4)+1 'this is selects the suit
card=int(rnd*13)+1 ' this selects the card number
'names the suits
select case SS
case 1
suit$="Spades"
case 2
suit$="Clubs"
case 3
suit$="Diamonds"
case 4
suit$="Hearts"
end select
'selects the card names
select case card
case 1
cname$="Ace"
case 11
cname$="Jack"
case 12
cname$="Queen"
case 13
cname$="King"
case else
cname$=str(card)
end select
rndcard$=cname$ + " of " + suit$ 'puts it all together
end function
function chkcardval(caval$)
cname$=left$(caval$,2)'gets leftmost 2 letters
'puts numbers to the card names
select case cname$
case "Ja"
cval=11
case "Qu"
cval=12
case "Ki"
cval=13
case "Ac"
cval=1
case else
cval=val(caval$)
end select
'returns the value
chkcardval=cval
end function
function chkcardsuit$(cname$)
'just chekcs the rightmost 2 letters and checks for the suit name
select case right$(cname$,2)
case "es"
chkcardsuit$="Spades"
case "bs"
chkcardsuit$="Clubs"
case "ds"
chkcardsuit$="Diamonds"
case "ts"
chkcardsuit$="Hearts"
case else
chkcardsuit$="Not a suit"
end select
end function
sub init(np,nc)
for p=1 to np ' does for number of players
for i=1 to (nc) ' divides the deck
1
dummie$ (p,i) = rndcard$() ' gets the card
for a= 1 to np
for n = 1 to (nc) 'this checks to make
if a=p and n=i then n=n+1
if dummie$ (p,i) = dummie$ (a,n) then goto 1'sure the card isnt
next 'repeated
next
next
next
'the rest of this prints out the player and card names
ap=1
for p=1 to np ' for the number of players
for cn=1 to 13 'checks card numbers
for ca = 1 to nc 'for the number of cards that the player has
if chkcardsuit$(dummie$(p,ca)) = "Clubs" and chkcardval(dummie$(p,ca)) = cn then ' checks and sorts
player$(p,ap)=dummie$(p,ca)
ap=ap+1 'for clubs and number
end if
next
next
'checks for spades and numbers
for cn=1 to 13
for ca = 1 to nc
if chkcardsuit$(dummie$(p,ca)) = "Spades" and chkcardval(dummie$(p,ca))=cn then
player$(p,ap)=dummie$(p,ca)
ap=ap+1
end if
next
next
'checks for diamonds and numbers
for cn=1 to 13
for ca = 1 to nc
if chkcardsuit$(dummie$(p,ca)) = "Diamonds" and chkcardval(dummie$(p,ca))=cn then
player$(p,ap)=dummie$(p,ca)
ap=ap+1
end if
next
next
'checks for hearts and numbers
for cn=1 to 13
for ca = 1 to nc
if chkcardsuit$(dummie$(p,ca)) = "Hearts" and chkcardval(dummie$(p,ca))=cn then
player$(p,ap)=dummie$(p,ca)
ap=ap+1
end if
next
next
next
end sub
[/code]
05-30-2005, 07:48 AM
Why don't you just leave it as a .bas file? All you have to do is stick it in the include flder for FB, and then #INCLUDE it in the programs that need it. That's what I do. It's really easy to modify that way... espaecially if you associate .bas files with FBIDE.
05-30-2005, 08:55 AM
Ha... didnt know you could do that... cool. thanks!
Pages: 1 2