BlackJack Game Scripting

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

BlackJack Game Scripting

Postby cpkspikyhair » Sun Apr 20, 2008 2:55 pm

I was thinking about a game that incorporates the rules of BlackJack so anyone could play it anytime against the computer.

I have the thought of the game already made (i.e. how the cards will look, the poker table, the card backing), but I am new to scripting, so I am going to need all the help I can get.

To make it easier to script, I am going to have cards with only a number or letter on them, like 2-10 and J, Q, K, and A. I was wondering how to set values for the cards and to have the computer add the values to tell you when you win, lose, bust, etc.

In every deck, there are 4 of each type of card. Is it possible to create a database for the deck? What I mean is that I want the computer to subtract the cards from the deck database when they are played, so the computer doesn't lay out five of the same card before shuffling the deck :D .

If you could help me out with this, that would be great. I will need more help later on, but these are the prominent problems.

EDIT: Type-O
Last edited by cpkspikyhair on Sun Apr 20, 2008 7:07 pm, edited 1 time in total.
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sun Apr 20, 2008 3:08 pm

Hmm... Got some ideas. That database you asked for isn't really necessary... Just add a variable for each card type and add 1 to it each time a card of that type is drawn. Example: create an integer named 1s and each time the player draws a card of that type, execute this code
Code: Select all
If 1s<4
1s=1s+1
end if

To do that for each card type, create the needed variables, then use a Select Case command:
Code: Select all
randomize
cardtype=int(RND*14)+1
Select Case cardtype
Case 1
card="1"
Case 2
card="2"
etc
Case 14
card="A"
End Select
Select Case card
case "1"
If 1s<4
1s=1s+1
end if
etc
End Select



hope this helps, others soon to come. Please ask if you don't understand the code
EDIT: To retrieve the value from a card type use the Select again: (note that card variable is a variant)
Code: Select all
Select Case card
case "1"
cardpoints=1
...
case "A"
cardpoints=10


I 'd also suggest taking the value of the card to load an image for it during game...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sun Apr 20, 2008 7:05 pm

I think your suggestion is necessary for the game to work, so how would I go about doing that, as well?

Also, for your code:

Code: Select all
If 1s<4
1s=1s+1
End If


Do I need to make a different integer for each card type? Like 2s for the 3 card and 3s for the 4 card?

Also, I had a typing error. The cards are 2-10, not 1-10. If that changes any coding you previously made, let me know. Sorry :( !
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sun Apr 20, 2008 7:45 pm

You have to create an integer for each card type, yes. 1s for aces, 2s for twos etc... Name them whatever you want. If you create a short project send it to me to check it for you :P


To change the appearance picture of the cards use the Action.LoadAPicture command as described in the manual of AM in conjuction with a Select Case
Example:
Code: Select all
Select Case card
case "1"
Action.LoadAPicture Hotspot(index), "imagefilename.extention"
etc
End Select


I wish you the best results, be sure to update us and ask for help if you face any problems
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sun Apr 20, 2008 8:55 pm

Thank you so much for the help, Lyberodoggy!

I do need one more thing, though.

Since there will be a total of nine possible player card hotspots (2, 2, 2, 2, 3, 3, 3, 3, any card), how will I make it so the computer adds up what the player has tells you if you are over 21? Also, how can I make the dealer do the same?

Another problem is comparing the cards you have to the dealer's hand. What code can make it know if you win or not?

Again, thanks for all the help you have been, Lyberodoggy :D !

EDIT: I also need to know how, if the player were to go over 21 and they had an Ace, to change the "cardpoints" for that Ace to "1" instead of "11".
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby cpkspikyhair » Sun Apr 20, 2008 11:15 pm

I typed in all of your codes, and I get 2 errors:

1. Expected 'Then'
2. Object does not support this property or method.

Also, the card doesn't show up.

I looked for type-o's but didn't find any. If you could help me check for problems, that would be great.

Code: Select all
randomize
cardtype=int(RND*13)+1
Select Case cardtype
Case 1
card="A"
Case 2
card="2"
Case 3
card="3"
Case 4
card="4"
Case 5
card="5"
Case 6
card="6"
Case 7
card="7"
Case 8
card="8"
Case 9
card="9"
Case 10
card="10"
Case 11
card="J"
Case 12
card="Q"
Case 13
card="K"
End Select
Select Case card
case "A"
If cA<4
cA=cA+1
end if
case "2"
If c2<4
c2=c2+1
end if
case "3"
If c3<4
c3=c3+1
end if
case "4"
If c4<4
c4=c4+1
end if
case "5"
If c5<4
c5=c5+1
end if
case "6"
If c6<4
c6=c6+1
end if
case "7"
If c7<4
c7=c7+1
end if
case "4"
If c8<4
c8=c8+1
end if
case "9"
If c9<4
c9=c9+1
end if
case "10"
If cT<4
cT=cT+1
end if
case "J"
If cJ<4
cJ=cJ+1
end if
case "Q"
If cQ<4
cQ=cQ+1
end if
case "K"
If cK<4
cK=cK+1
end if
End Select
Select Case card
case "A"
cardpoints=11
case "2"
cardpoints=2
case "3"
cardpoints=3
case "4"
cardpoints=4
case "5"
cardpoints=5
case "6"
cardpoints=6
case "7"
cardpoints=7
case "8"
cardpoints=8
case "9"
cardpoints=9
case "10"
cardpoints=10
case "J"
cardpoints=10
case "Q"
cardpoints=10
case "K"
cardpoints=10
End Select
Select Case card
case "A"
Action.LoadAPicture Hotspot(1), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(1), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(1), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(1), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(1), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(1), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(1), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(1), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(1), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(1), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(1), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(1), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(1), "King.bmp"
End Select


I think something is wrong with the beginning of the code, but I am not sure :? .

Also, the card pictures go in the Hotspot Graphics folder, right?
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Mon Apr 21, 2008 10:39 am

Nice coding! Anyway, after each If you need a "then"
Example
Code: Select all
If cA<4 Then
actions
End If


Sorry for that one.
As for the points, create a points integer, then have a Select Case to store points in it depending on the card. Do the same with a dealerpoints integer and create an If like this one:
Code: Select all
If points<dealerpoints or points=dealerpoints Then
'code for player lose
Else If points>dealerpoints and points<=21 Then
'code for player win
End If


I can't figure out why you get the other error. Please send me a sample (no need for good graphics) to work on it and tell you what to do...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Mon Apr 21, 2008 10:30 pm

The Object error and the card-showing problem fixed themselves when the 'Then" error was fixed :D .

I will still send you the game file, though. I only have the coding for dealing the cards, so only expect that :wink: . Schoolwork still has me pinned, but expect a betting and winning code in there by next week!
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Tue Apr 22, 2008 7:47 am

Okay cpkspikyhair... looking forward to be amazed :P
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Tue Apr 22, 2008 11:33 pm

Thank you for all of the help, but I think I might be able to do the rest on my own. But if I ever need technical help, I know who to ask for it :D !
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Wed Apr 23, 2008 7:48 am

hehe! Thanks :oops:
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ron_Emad2 » Wed Apr 23, 2008 8:51 am

hello
thanks Lyberodoggy
if you can
build a sample project with this code for Amator user(for example = Ron_Emad2 :lol: )
with thanks
emad
Hello
I from iran
i cant speak english correctly
please forgive me
User avatar
Ron_Emad2
Active Member
 
Posts: 85
Joined: Fri Oct 13, 2006 12:08 pm
Location: Iran-Kashan

Postby Lyberodoggy » Wed Apr 23, 2008 10:41 am

Hehe, sorry ron, this code is used by cpkspikyhair. But you will soon see his game using it...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ron_Emad2 » Wed Apr 23, 2008 12:08 pm

:D :D
oh // it is very good// i like see vest game with adventuremaker
but I wish cpkspikyhair game coomin soon
Hello
I from iran
i cant speak english correctly
please forgive me
User avatar
Ron_Emad2
Active Member
 
Posts: 85
Joined: Fri Oct 13, 2006 12:08 pm
Location: Iran-Kashan

Postby cpkspikyhair » Wed Apr 23, 2008 11:01 pm

Man, another major problem :cry: .

I don't know what is wrong. Can you check this code? This is for the "Hit" button, which gives you another card.

I got an error saying 'Object variable not set.'

Code: Select all
If Hotspot(12).Picture = Nothing Then
randomize
cardtype3=int(RND*13)+1
Select Case cardtype3
Case 1
card3="A"
Case 2
card3="2"
Case 3
card3="3"
Case 4
card3="4"
Case 5
card3="5"
Case 6
card3="6"
Case 7
card3="7"
Case 8
card3="8"
Case 9
card3="9"
Case 10
card3="10"
Case 11
card3="J"
Case 12
card3="Q"
Case 13
card3="K"
End Select
Select Case card3
case "A"
If cA<4 Then
cA=cA+1
end if
case "2"
If c2<4 Then
c2=c2+1
end if
case "3"
If c3<4 Then
c3=c3+1
end if
case "4"
If c4<4 Then
c4=c4+1
end if
case "5"
If c5<4 Then
c5=c5+1
end if
case "6"
If c6<4 Then
c6=c6+1
end if
case "7"
If c7<4 Then
c7=c7+1
end if
case "4"
If c8<4 Then
c8=c8+1
end if
case "9"
If c9<4 Then
c9=c9+1
end if
case "10"
If cT<4 Then
cT=cT+1
end if
case "J"
If cJ<4 Then
cJ=cJ+1
end if
case "Q"
If cQ<4 Then
cQ=cQ+1
end if
case "K"
If cK<4 Then
cK=cK+1
end if
End Select
Select Case card3
case "A"
cardpoints3=11
case "2"
cardpoints3=2
case "3"
cardpoints3=3
case "4"
cardpoints3=4
case "5"
cardpoints3=5
case "6"
cardpoints3=6
case "7"
cardpoints3=7
case "8"
cardpoints3=8
case "9"
cardpoints3=9
case "10"
cardpoints3=10
case "J"
cardpoints3=10
case "Q"
cardpoints3=10
case "K"
cardpoints3=10
End Select
Select Case card3
case "A"
Action.LoadAPicture Hotspot(12), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(12), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(12), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(12), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(12), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(12), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(12), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(12), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(12), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(12), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(12), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(12), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(12), "King.bmp"
End Select
ElseIf Hotspot(13).Picture = Nothing Then
randomize
cardtype4=int(RND*13)+1
Select Case cardtype4
Case 1
card4="A"
Case 2
card4="2"
Case 3
card4="3"
Case 4
card4="4"
Case 5
card4="5"
Case 6
card4="6"
Case 7
card4="7"
Case 8
card4="8"
Case 9
card4="9"
Case 10
card4="10"
Case 11
card4="J"
Case 12
card4="Q"
Case 13
card4="K"
End Select
Select Case card4
case "A"
If cA<4 Then
cA=cA+1
end if
case "2"
If c2<4 Then
c2=c2+1
end if
case "3"
If c3<4 Then
c3=c3+1
end if
case "4"
If c4<4 Then
c4=c4+1
end if
case "5"
If c5<4 Then
c5=c5+1
end if
case "6"
If c6<4 Then
c6=c6+1
end if
case "7"
If c7<4 Then
c7=c7+1
end if
case "4"
If c8<4 Then
c8=c8+1
end if
case "9"
If c9<4 Then
c9=c9+1
end if
case "10"
If cT<4 Then
cT=cT+1
end if
case "J"
If cJ<4 Then
cJ=cJ+1
end if
case "Q"
If cQ<4 Then
cQ=cQ+1
end if
case "K"
If cK<4 Then
cK=cK+1
end if
End Select
Select Case card4
case "A"
cardpoints4=11
case "2"
cardpoints4=2
case "3"
cardpoints4=3
case "4"
cardpoints4=4
case "5"
cardpoints4=5
case "6"
cardpoints4=6
case "7"
cardpoints4=7
case "8"
cardpoints4=8
case "9"
cardpoints4=9
case "10"
cardpoints4=10
case "J"
cardpoints4=10
case "Q"
cardpoints4=10
case "K"
cardpoints4=10
End Select
Select Case card4
case "A"
Action.LoadAPicture Hotspot(13), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(13), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(13), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(13), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(13), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(13), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(13), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(13), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(13), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(13), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(13), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(13), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(13), "King.bmp"
End Select
ElseIf Hotspot(14).Picture = Nothing Then
randomize
cardtype5=int(RND*13)+1
Select Case cardtype5
Case 1
card5="A"
Case 2
card5="2"
Case 3
card5="3"
Case 4
card5="4"
Case 5
card5="5"
Case 6
card5="6"
Case 7
card5="7"
Case 8
card5="8"
Case 9
card5="9"
Case 10
card5="10"
Case 11
card5="J"
Case 12
card5="Q"
Case 13
card5="K"
End Select
Select Case card5
case "A"
If cA<4 Then
cA=cA+1
end if
case "2"
If c2<4 Then
c2=c2+1
end if
case "3"
If c3<4 Then
c3=c3+1
end if
case "4"
If c4<4 Then
c4=c4+1
end if
case "5"
If c5<4 Then
c5=c5+1
end if
case "6"
If c6<4 Then
c6=c6+1
end if
case "7"
If c7<4 Then
c7=c7+1
end if
case "4"
If c8<4 Then
c8=c8+1
end if
case "9"
If c9<4 Then
c9=c9+1
end if
case "10"
If cT<4 Then
cT=cT+1
end if
case "J"
If cJ<4 Then
cJ=cJ+1
end if
case "Q"
If cQ<4 Then
cQ=cQ+1
end if
case "K"
If cK<4 Then
cK=cK+1
end if
End Select
Select Case card5
case "A"
cardpoints5=11
case "2"
cardpoints5=2
case "3"
cardpoints5=3
case "4"
cardpoints5=4
case "5"
cardpoints5=5
case "6"
cardpoints5=6
case "7"
cardpoints5=7
case "8"
cardpoints5=8
case "9"
cardpoints5=9
case "10"
cardpoints5=10
case "J"
cardpoints5=10
case "Q"
cardpoints5=10
case "K"
cardpoints5=10
End Select
Select Case card5
case "A"
Action.LoadAPicture Hotspot(14), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(14), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(14), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(14), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(14), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(14), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(14), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(14), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(14), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(14), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(14), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(14), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(14), "King.bmp"
End Select
ElseIf Hotspot(15).Picture = Nothing Then
randomize
cardtype6=int(RND*13)+1
Select Case cardtype6
Case 1
card6="A"
Case 2
card6="2"
Case 3
card6="3"
Case 4
card6="4"
Case 5
card6="5"
Case 6
card6="6"
Case 7
card6="7"
Case 8
card6="8"
Case 9
card6="9"
Case 10
card6="10"
Case 11
card6="J"
Case 12
card6="Q"
Case 13
card6="K"
End Select
Select Case card6
case "A"
If cA<4 Then
cA=cA+1
end if
case "2"
If c2<4 Then
c2=c2+1
end if
case "3"
If c3<4 Then
c3=c3+1
end if
case "4"
If c4<4 Then
c4=c4+1
end if
case "5"
If c5<4 Then
c5=c5+1
end if
case "6"
If c6<4 Then
c6=c6+1
end if
case "7"
If c7<4 Then
c7=c7+1
end if
case "4"
If c8<4 Then
c8=c8+1
end if
case "9"
If c9<4 Then
c9=c9+1
end if
case "10"
If cT<4 Then
cT=cT+1
end if
case "J"
If cJ<4 Then
cJ=cJ+1
end if
case "Q"
If cQ<4 Then
cQ=cQ+1
end if
case "K"
If cK<4 Then
cK=cK+1
end if
End Select
Select Case card6
case "A"
cardpoints6=11
case "2"
cardpoints6=2
case "3"
cardpoints6=3
case "4"
cardpoints6=4
case "5"
cardpoints6=5
case "6"
cardpoints6=6
case "7"
cardpoints6=7
case "8"
cardpoints6=8
case "9"
cardpoints6=9
case "10"
cardpoints6=10
case "J"
cardpoints6=10
case "Q"
cardpoints6=10
case "K"
cardpoints6=10
End Select
Select Case card6
case "A"
Action.LoadAPicture Hotspot(15), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(15), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(15), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(15), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(15), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(15), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(15), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(15), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(15), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(15), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(15), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(15), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(15), "King.bmp"
End Select
ElseIf Hotspot(16).Picture = Nothing Then
randomize
cardtype7=int(RND*13)+1
Select Case cardtype7
Case 1
card7="A"
Case 2
card7="2"
Case 3
card7="3"
Case 4
card7="4"
Case 5
card7="5"
Case 6
card7="6"
Case 7
card7="7"
Case 8
card7="8"
Case 9
card7="9"
Case 10
card7="10"
Case 11
card7="J"
Case 12
card7="Q"
Case 13
card7="K"
End Select
Select Case card7
case "A"
If cA<4 Then
cA=cA+1
end if
case "2"
If c2<4 Then
c2=c2+1
end if
case "3"
If c3<4 Then
c3=c3+1
end if
case "4"
If c4<4 Then
c4=c4+1
end if
case "5"
If c5<4 Then
c5=c5+1
end if
case "6"
If c6<4 Then
c6=c6+1
end if
case "7"
If c7<4 Then
c7=c7+1
end if
case "4"
If c8<4 Then
c8=c8+1
end if
case "9"
If c9<4 Then
c9=c9+1
end if
case "10"
If cT<4 Then
cT=cT+1
end if
case "J"
If cJ<4 Then
cJ=cJ+1
end if
case "Q"
If cQ<4 Then
cQ=cQ+1
end if
case "K"
If cK<4 Then
cK=cK+1
end if
End Select
Select Case card7
case "A"
cardpoints7=11
case "2"
cardpoints7=2
case "3"
cardpoints7=3
case "4"
cardpoints7=4
case "5"
cardpoints7=5
case "6"
cardpoints7=6
case "7"
cardpoints7=7
case "8"
cardpoints7=8
case "9"
cardpoints7=9
case "10"
cardpoints7=10
case "J"
cardpoints7=10
case "Q"
cardpoints7=10
case "K"
cardpoints7=10
End Select
Select Case card7
case "A"
Action.LoadAPicture Hotspot(16), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(16), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(16), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(16), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(16), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(16), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(16), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(16), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(16), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(16), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(16), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(16), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(16), "King.bmp"
End Select
ElseIf Hotspot(17).Picture = Nothing Then
randomize
cardtype8=int(RND*13)+1
Select Case cardtype8
Case 1
card8="A"
Case 2
card8="2"
Case 3
card8="3"
Case 4
card8="4"
Case 5
card8="5"
Case 6
card8="6"
Case 7
card8="7"
Case 8
card8="8"
Case 9
card8="9"
Case 10
card8="10"
Case 11
card8="J"
Case 12
card8="Q"
Case 13
card8="K"
End Select
Select Case card8
case "A"
If cA<4 Then
cA=cA+1
end if
case "2"
If c2<4 Then
c2=c2+1
end if
case "3"
If c3<4 Then
c3=c3+1
end if
case "4"
If c4<4 Then
c4=c4+1
end if
case "5"
If c5<4 Then
c5=c5+1
end if
case "6"
If c6<4 Then
c6=c6+1
end if
case "7"
If c7<4 Then
c7=c7+1
end if
case "4"
If c8<4 Then
c8=c8+1
end if
case "9"
If c9<4 Then
c9=c9+1
end if
case "10"
If cT<4 Then
cT=cT+1
end if
case "J"
If cJ<4 Then
cJ=cJ+1
end if
case "Q"
If cQ<4 Then
cQ=cQ+1
end if
case "K"
If cK<4 Then
cK=cK+1
end if
End Select
Select Case card8
case "A"
cardpoints8=11
case "2"
cardpoints8=2
case "3"
cardpoints8=3
case "4"
cardpoints8=4
case "5"
cardpoints8=5
case "6"
cardpoints8=6
case "7"
cardpoints8=7
case "8"
cardpoints8=8
case "9"
cardpoints8=9
case "10"
cardpoints8=10
case "J"
cardpoints8=10
case "Q"
cardpoints8=10
case "K"
cardpoints8=10
End Select
Select Case card8
case "A"
Action.LoadAPicture Hotspot(17), "Ace.bmp"
case "2"
Action.LoadAPicture Hotspot(17), "2.bmp"
case "3"
Action.LoadAPicture Hotspot(17), "3.bmp"
case "4"
Action.LoadAPicture Hotspot(17), "4.bmp"
case "5"
Action.LoadAPicture Hotspot(17), "5.bmp"
case "6"
Action.LoadAPicture Hotspot(17), "6.bmp"
case "7"
Action.LoadAPicture Hotspot(17), "7.bmp"
case "8"
Action.LoadAPicture Hotspot(17), "8.bmp"
case "9"
Action.LoadAPicture Hotspot(17), "9.bmp"
case "10"
Action.LoadAPicture Hotspot(17), "10.bmp"
case "J"
Action.LoadAPicture Hotspot(17), "Jack.bmp"
case "Q"
Action.LoadAPicture Hotspot(17), "Queen.bmp"
case "K"
Action.LoadAPicture Hotspot(17), "King.bmp"
End Select
End If


I am really sorry for the length, but I didn't want to cut it down, just in case I have made a type-o.

Thanks for the help,

cpkspikyhair
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Thu Apr 24, 2008 8:02 am

I can't see the problem, I will probably have to recreate it and because I 'm leaving today for vacations I 'll try to do it as soon as possible

You should check weather all the variables and hotspots mentioned in the code exist and are declared

Also for the card code
You can use select with both actions instead of two selects.
Example:
Code: Select all
Select Case card
case "A"
If cA<4 Then
cA=cA+1
end if
cardpoints3=11
case "2"
...
End Select


For the Ace problem, you can use an If to convert the points of it in "1" instead of "11"

EDIT: Found the problem: The first line of your code... It was very smart to use it but for some reason I can't see it doesn't work. I 'll try to find a solution. But if I don't come up with something you can still use the old and secure method of the variables. Just create an integer boolean (A variable which can have only two values: 0 or 1) and make it so that when a card is in that hotspot, it has a value of 1 and when not, 0.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Thu Apr 24, 2008 10:37 pm

I figured it out with your integer variable idea :D !

Have a nice vacation 8) !
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Fri Apr 25, 2008 11:26 am

Thanks! Luckily I found a laptop with broadband over here :P
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Fri Apr 25, 2008 9:22 pm

That's great!

Ok, another technical question. Can you have an If...Then inside another If...Then?

Example:

Code: Select all
If playerpoints>21 Then
If AceVAR>0 Then
AceVAR = AceVAR - 1
playerpoints = playerpoints - 10
Else
...
End If
End If


In other words, is there a way to make it so one thing happens if both requirements are met instead of only 1?

Thanks for the help,

cpkspikyhair

EDIT:I have figured out my first question with the "Select Case True" command.

The next problem is that the code that makes the player bust if they go over 21 doesn't always work. Sometimes, you need to prees "hit" again. Is that possible to fix?

Also, now that I look at it, I don't think that this code will actually stop the dealing of 4 of the same card:

Code: Select all
If cA<4 Then
cA = cA + 1
End If


All I think it will do is stop the variable from increasing once it gets to 4.
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Tue Apr 29, 2008 6:45 pm

Indeed... You need the cardtype variable to be unable to take that value if 4 cards of the same type have been drawn.

You can of course use multiple ifs inside other ifs but if you use else ifs in this version of VBS you will need an additional end if. Example
Code: Select all
If condition Then
Actions
Else If condition Then
Actions
End if
End if


You can also use two conditions in an if like
If condition1 AND condition2 Then
OR
If condition1 OR condition2 Then
But it usually doesn't work in this version of VBS...

As for the problem with 21, probably some conditions aren't set as they should be... Sorry but I can't check that right now due to lack of time.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Tue Apr 29, 2008 9:36 pm

I will make another executable so you can check it when you have more time :D .

Anyhow, it would be very helpful to me and (probably) Lyberodoggy if someone else stepped in and helped, too. The more people, the better.
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Wed Apr 30, 2008 6:14 pm

While reading about programming in C#, I learned that there you can easily simulate deck suffling and sharing by creating an array with two indicators example: array(0)(0) are the coordinates of the ace of spades, array(0)(1) are for deuce of spades etc... I don't know if there 's such a method in VBS though, but you could use external programs like OCX files to do what you want in AM using C# programming. GM please check this and help us :P
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Candle » Wed Apr 30, 2008 7:56 pm

(0)(0) are you trying to draw boobies there Lyberodoggy?

lol
Please don't PM me questions, ask here in the forums!
``````````````
Between grand theft and a legal fee, there only stands a law degree.
User avatar
Candle
Administrator
 
Posts: 3077
Joined: Sat Feb 07, 2004 2:21 am
Location: Rudy's Bar

Postby GM-Support » Wed Apr 30, 2008 9:29 pm

Lyberodoggy wrote:While reading about programming in C#, I learned that there you can easily simulate deck suffling and sharing by creating an array with two indicators example: array(0)(0) are the coordinates of the ace of spades, array(0)(1) are for deuce of spades etc... I don't know if there 's such a method in VBS though, but you could use external programs like OCX files to do what you want in AM using C# programming. GM please check this and help us :P


The following code should do the job:

Code: Select all
Dim MyArray(WIDTH, HEIGHT)
MyArray(X,Y) = Z


Where you must replace WIDTH, HEIGHT, X, Y, and Z with values

For example:
Code: Select all
Dim MyArray(8, 8)
MyArray(4,3) = "Hello"
GM-Support
Forum Admin and Games Page admin
 
Posts: 2221
Joined: Thu Jun 05, 2003 7:52 pm

Postby cpkspikyhair » Thu May 01, 2008 1:21 am

Thank you for addressing that, but that is not my main problem right now. Should I post the project file so you can help me troubleshoot my problem?
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Fri May 02, 2008 8:52 am

Yes please, that would make it easier... I 'll try to check on the code and fix it if I can with the new knowledge I 've aqcuired about arrays
To GM: Thanks!!! Really!
To Candle: lol, no that wasn't my intention :lol:
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Lyberodoggy » Fri May 02, 2008 8:16 pm

I tried to simulate a deck using an array like this:
Code: Select all
deck(3,12)

note that coordinates include a value of "0"
It basically would be deck(shape,figure) where shape would range from 0 to 3 (Spades, Hearts, Diamonds, Clubs) and figure would range from 0 to 12 (Ace, Deuce,...,King)
So far so good.
Then when I tried to suffle it and show each card's place ranging from 1 to 52 using this code:
Code: Select all
dim deck(3,12)
dim shape
dim figure
dim i
shape=0
figure=0
for i=1 to 52
do while deck(shape,figure)=""
randomize
shape=int(RND*3)
randomize
figure=int(RND*12)
deck(shape,figure)=i
loop
next
for shape=0 to 3
for figure=0 to 12
msgbox deck(shape,figure)
next
next

I got an everlasting loop...
I even tried this primitive one:
Code: Select all
dim deck(3,12)
dim shape
dim figure
dim i
shape=0
figure=0
for i=1 to 52
if deck(shape,figure)="" then
randomize
shape=int(RND*3)
randomize
figure=int(RND*12)
deck(shape,figure)=i
else
i=i-1
end if
next
for shape=0 to 3
for figure=0 to 12
msgbox deck(shape,figure)
next
next

but it didn't work either.
If I exclude the do while command it works fine, but some coordinates don't get a value
Somebody help please :(
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sat May 03, 2008 4:33 pm

Is it safe to post the project file in the forums?
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby Lyberodoggy » Sat May 03, 2008 4:38 pm

Well, I can't promise about that, because it is public, but you could upload it somewhere and pm certain people...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby cpkspikyhair » Sat May 03, 2008 4:54 pm

I sent the project to you. If anyone else wants to help, just post.
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Next

Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests

cron