Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Showing Dice in Yahtzee
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Blade




PostPosted: 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 Very Happy
how would you guys go about doing this?
Sponsor
Sponsor
Sponsor
sponsor
Asok




PostPosted: 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
Blade




PostPosted: 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




PostPosted: 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.
Blade




PostPosted: 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... Smile
but i havent really gotten that far into turing... would you mind giving me an example to learn off of?
Asok




PostPosted: 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




PostPosted: 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 Laughing 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.
Blade




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Asok




PostPosted: 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 Laughing 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?
Blade




PostPosted: 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:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: