Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Showing Dice in Yahtzee
Author Message

Posted: Sun Mar 16, 2003 11:45 pm   Post subject: Showing Dice in Yahtzee

hey, i'm making a yahtzee program... and i want my dice to be shown, as they're being rolled, like how i dice should look like... you see the face of the dice, and it randomly changes as its rolling... its hard to explain though, but i know what i'm talking about
how would you guys go about doing this?

Asok

Posted: Sun Mar 16, 2003 11:52 pm   Post subject: (No subject)

I'm not sure how many dice are in yahtzee but this is how you do 2, you can add more on your own.

 code: var die1,die2 : int %you call the randoms whenever you want to roll die1 := Rand.Int (1,6) die2 := Rand.Int (1,6) %drawing dice if die1 = 1 then Draw.Box (290,440,310,460,black) Draw.FillOval (300,450,2,2,black) elsif die1 = 2 then Draw.Box (290,440,310,460,black) Draw.FillOval (295,445,2,2,black) Draw.FillOval (305,455,2,2,black) elsif die1 = 3 then Draw.Box (290,440,310,460,black) Draw.FillOval (300,450,2,2,black) Draw.FillOval (295,455,2,2,black) Draw.FillOval (305,445,2,2,black) elsif die1 = 4 then Draw.Box (290,440,310,460,black) Draw.FillOval (295,455,2,2,black) Draw.FillOval (305,445,2,2,black) Draw.FillOval (295,445,2,2,black) Draw.FillOval (305,455,2,2,black) elsif die1 = 5 then Draw.Box (290,440,310,460,black) Draw.FillOval (300,450,2,2,black) Draw.FillOval (295,455,2,2,black) Draw.FillOval (305,445,2,2,black) Draw.FillOval (295,445,2,2,black) Draw.FillOval (305,455,2,2,black) elsif die1 = 6 then Draw.Box (290,440,310,460,black) Draw.FillOval (295,455,2,2,black) Draw.FillOval (305,445,2,2,black) Draw.FillOval (295,445,2,2,black) Draw.FillOval (305,455,2,2,black) Draw.FillOval (295,450,2,2,black) Draw.FillOval (305,450,2,2,black) end if if die2 = 1 then Draw.Box (290+40,440,310+40,460,black) Draw.FillOval (300+40,450,2,2,black) elsif die2 = 2 then Draw.Box (290+40,440,310+40,460,black) Draw.FillOval (295+40,445,2,2,black) Draw.FillOval (305+40,455,2,2,black) elsif die2 = 3 then Draw.Box (290+40,440,310+40,460,black) Draw.FillOval (300+40,450,2,2,black) Draw.FillOval (295+40,455,2,2,black) Draw.FillOval (305+40,445,2,2,black) elsif die2 = 4 then Draw.Box (290+40,440,310+40,460,black) Draw.FillOval (295+40,455,2,2,black) Draw.FillOval (305+40,445,2,2,black) Draw.FillOval (295+40,445,2,2,black) Draw.FillOval (305+40,455,2,2,black) elsif die2 = 5 then Draw.Box (290+40,440,310+40,460,black) Draw.FillOval (300+40,450,2,2,black) Draw.FillOval (295+40,455,2,2,black) Draw.FillOval (305+40,445,2,2,black) Draw.FillOval (295+40,445,2,2,black) Draw.FillOval (305+40,455,2,2,black) elsif die2 = 6 then Draw.Box (290+40,440,310+40,460,black) Draw.FillOval (295+40,455,2,2,black) Draw.FillOval (305+40,445,2,2,black) Draw.FillOval (295+40,445,2,2,black) Draw.FillOval (305+40,455,2,2,black) Draw.FillOval (295+40,450,2,2,black) Draw.FillOval (305+40,450,2,2,black) end if

Posted: Sun Mar 16, 2003 11:55 pm   Post subject: (No subject)

holy crap... i kinda thought there woulda been a way to do it with lotta less code... ah well... add 3 more to that and i've got it...
Asok

Posted: Sun Mar 16, 2003 11:59 pm   Post subject: (No subject)

the bulk of it is just copy and pasting, will take little time.

btw, there is a way to do that in a lot less lines, and that is to store the image and use Pic.Draw rather than redraw the image, but the concept is the same either way you choose to do it.

Posted: Mon Mar 17, 2003 1:14 am   Post subject: (No subject)

i like less lines, because then i dont have to go through so much when i try to find something...
but i havent really gotten that far into turing... would you mind giving me an example to learn off of?
Asok

Posted: Mon Mar 17, 2003 1:27 am   Post subject: (No subject)

the tutorial here should explain it for you: http://www.compsci.ca/bbs/viewtopic.php?t=191

you would need to make 6 .bmp's one of each side of the die. then replace the code for the dice die with Pic.Draw
azndragon

Posted: Mon Mar 17, 2003 7:09 am   Post subject: (No subject)

You might wanna consider learning Yahtzee rules and arrays. Being able to sort out EVERY single combination of dice is gonna be A LOT of work Based on my calculations, there are 46656 total combinations of dice, so it's gonna take a while. Someone please try and verify my number.

Posted: Mon Mar 17, 2003 7:15 am   Post subject: (No subject)

it only shows me how to load up a pic and display it.. cant you make ur own pics with turing and save them?

EDIT:
sorry, i looked it up in the help file... i learnt from there... but thx anyways

Asok

Posted: Mon Mar 17, 2003 10:50 am   Post subject: (No subject)

azndragon wrote:
You might wanna consider learning Yahtzee rules and arrays. Being able to sort out EVERY single combination of dice is gonna be A LOT of work Based on my calculations, there are 46656 total combinations of dice, so it's gonna take a while. Someone please try and verify my number.

I don't know how you play yahtzee but don't you just add up the sum of the dice?

Posted: Mon Mar 17, 2003 11:45 am   Post subject: (No subject)

lol, he meant the combonations of the dice...

but no... its kinda like playing poker, but with dice... you can have

aces, twos, threes, fours, fives, and sixes <-- add up all the numbers corresponding... so for ace, if you have 3 ones then you add up the ones and you add it to your scorecard

theres also, 3 of a kind, 4 of a kind small straight, large straight, full house, yahtzee, and chance

those are all just common sense, so i'm not gonna explain it...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 10 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: