Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > BlackJack


Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2005, 03:18 PM
Quicksilver2002 Quicksilver2002 is offline
Newcomer
 
Join Date: Nov 2005
Posts: 15
Default BlackJack


Have a balck jack game with an array like this.
Num(0) = me.uiAceHearts.Image
Num(1) = me.uiTwoHearts.Image
...and so on

I have it showing random cards, but I need to let it know some how that the Two of Hearts isworth 2 points. I have a text box below the cards that i want to show this value.

Do I need to se up another array? Or how can i do this With out a bunch of If..Then's
Reply With Quote
  #2  
Old 11-07-2005, 07:13 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

You could probably calculate if from the index.
The Mod function will give you a remainder, so assuming your suits follow one another and run Ace to King in each group then
Code:
PointValue = Index Mod 13 + 1 'Should return 1 for Ace, 2 for 2, 3 for 3, etc. If PointValue > 10 then PointValue = 10 'set 11, 12, 13 (J,Q,K) back to 10
Then you just need a way to decide if 1 (Ace) should be 11.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 11-08-2005, 11:59 AM
Quicksilver2002 Quicksilver2002 is offline
Newcomer
 
Join Date: Nov 2005
Posts: 15
Default

Thanks for the reply Passel! That looks good, but I'm confused about the Index part. What is the Index? Will that be my Num?
Reply With Quote
  #4  
Old 11-08-2005, 01:07 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

I don't know.
You said you had an array
Num(0) = ...
Num(1) = ...
etc...

Index would be the index into that array, i.e. the number 0 or 1 etc which indicates what card we are refering to.
You probably shouldn't actually name the variable "Index" since control s have Index properties, but whatever variable you are using to identify the card and index into the num array is what I meant.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #5  
Old 11-08-2005, 03:39 PM
Quicksilver2002 Quicksilver2002 is offline
Newcomer
 
Join Date: Nov 2005
Posts: 15
Default

Thanks Passel. You the man!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->