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

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




PostPosted: Fri May 30, 2008 11:13 am   Post subject: Help with Yahtzee

I am programming Yahtzee and I am having BIG problems this is my code please help me! BooHoo
%23 April
%yahtzee.t
%to play yahtzee
var winMain : int := Window.Open ("graphics:781;541")
var x, rad, dx, dy, da, db, dc, dd, de, c : int
var xa : int
var ya : array 1 .. 5 of int
ya (1) := 25
ya (2) := 125
ya (3) := 225
ya (4) := 325
ya (5) := 425
rad := 5
x := 350
xa := 701
c := black
var current : int
var anykey : string (1)
current := 1
var dv : array 1 .. 5 of int

%drawfill (maxx, maxy, blue, black)

procedure scorecard
put "1="
put "2="
put "3="
put "4="
put "5="
put "6="
put "total score"
put "bonus"
put "(if score is over 63)"
put "Total upper section"
put "3 of a kind"
put "4 of a kind"
put "Full house"
put "Small straight"
put "sequence of 4"
put "Large straight"
put "sequence of 5"
put "Yahtzee 5 of a kind"
put "chance"
put "total of lower section"
put "total of upper section"
put "Grand total"


drawbox (0, 540, x, 445, c)
drawbox (0, 425, x, 445, c)
drawbox (0, 425, x, 445, c)
drawbox (0, 395, x, 445, c)
drawbox (0, 380, x, 395, c)
drawbox (0, 365, x, 380, c)
drawbox (0, 350, x, 365, c)
drawbox (0, 335, x, 350, c)
drawbox (0, 300, x, 335, c)
drawbox (0, 270, x, 300, c)
drawbox (0, 225, x, 270, c)
drawbox (0, 270, x, 240, c)
drawbox (0, 240, x, 200, c)
drawbox (0, 185, x, 200, c)
drawline (190, 185, 190, 540, c)
end scorecard

procedure dice1

drawbox (dx, dy, dx + 80, dy + 80, black)
Draw.FillOval (dx + 40, dy + 40, rad, rad, black)

end dice1

procedure dice2
drawbox (dx, dy, dx + 80, dy + 80, black)
Draw.FillOval (dx + 25, dy + 25, rad, rad, black)
Draw.FillOval (dx + 55, dy + 55, rad, rad, black)
end dice2

procedure dice3
drawbox (dx, dy, dx + 80, dy + 80, black)
Draw.FillOval (dx + 25, dy + 25, rad, rad, black)
Draw.FillOval (dx + 55, dy + 55, rad, rad, black)
Draw.FillOval (dx + 40, dy + 40, rad, rad, black)

end dice3

procedure dice4

drawbox (dx, dy, dx + 80, dy + 80, black)
Draw.FillOval (dx + 25, dy + 25, rad, rad, black)
Draw.FillOval (dx + 55, dy + 55, rad, rad, black)
Draw.FillOval (dx + 25, dy + 55, rad, rad, black)
Draw.FillOval (dx + 55, dy + 25, rad, rad, black)

end dice4

procedure dice5

drawbox (dx, dy, dx + 80, dy + 80, black)
Draw.FillOval (dx + 40, dy + 40, rad, rad, black)
Draw.FillOval (dx + 25, dy + 25, rad, rad, black)
Draw.FillOval (dx + 55, dy + 55, rad, rad, black)
Draw.FillOval (dx + 25, dy + 55, rad, rad, black)
Draw.FillOval (dx + 55, dy + 25, rad, rad, black)

end dice5

procedure dice6

drawbox (dx, dy, dx + 80, dy + 80, black)
Draw.FillOval (dx + 25, dy + 40, rad, rad, black)
Draw.FillOval (dx + 55, dy + 40, rad, rad, black)
Draw.FillOval (dx + 25, dy + 25, rad, rad, black)
Draw.FillOval (dx + 55, dy + 55, rad, rad, black)
Draw.FillOval (dx + 25, dy + 55, rad, rad, black)
Draw.FillOval (dx + 55, dy + 25, rad, rad, black)

end dice6

procedure rolldice
for k : 1 .. 20
dx := 700
dy := 25


randint (da, 1, 6)
randint (db, 1, 6)
randint (dc, 1, 6)
randint (dd, 1, 6)
randint (de, 1, 6)

drawfillbox (dx + 1, dy + 1, dx + 79, dy + 79, white)

if da = 1 then
dice1
elsif da = 2 then
dice2
elsif da = 3 then
dice3
elsif da = 4 then
dice4
elsif da = 5 then
dice5
elsif da = 6 then
dice6

end if
dx := dx
dy := dy + 100

drawfillbox (dx + 1, dy + 1, dx + 79, dy + 79, white)

if db = 1 then
dice1
elsif db = 2 then
dice2
elsif db = 3 then
dice3
elsif db = 4 then
dice4
elsif db = 5 then
dice5
elsif db = 6 then
dice6
end if

dx := dx
dy := dy + 100

drawfillbox (dx + 1, dy + 1, dx + 79, dy + 79, white)

if dc = 1 then
dice1
elsif dc = 2 then
dice2
elsif dc = 3 then
dice3
elsif dc = 4 then
dice4
elsif dc = 5 then
dice5
elsif dc = 6 then
dice6
end if
dx := dx
dy := dy + 100

drawfillbox (dx + 1, dy + 1, dx + 79, dy + 79, white)

if dd = 1 then
dice1
elsif dd = 2 then
dice2
elsif dd = 3 then
dice3
elsif dd = 4 then
dice4
elsif dd = 5 then
dice5
elsif dd = 6 then
dice6
end if

dx := dx
dy := dy + 100

drawfillbox (dx + 1, dy + 1, dx + 79, dy + 79, white)

if de = 1 then
dice1
elsif de = 2 then
dice2
elsif de = 3 then
dice3
elsif de = 4 then
dice4
elsif de = 5 then
dice5
elsif de = 6 then
dice6
end if
delay (200)
end for

end rolldice

procedure selection %help from Tim


loop


getch (anykey)

if ord (anykey) = 208 then
drawfill (xa + 1, ya (current) + 1, red, black)
drawfill (xa + 1, ya (current) + 26, white, black)
elsif current = 5 then
current := 1
drawfill (xa + 1, ya (current) + 1, red, black)
drawfill (xa + 1, ya (current) + 401, white, black)
else
current := current + 1

end if

if ord (anykey) = 200 then
drawfill (xa + 1, ya (current) + 1, red, black)
drawfill (xa + 1, ya (current) - 26, white, black)
elsif current = 1 then
current := 5
drawfill (xa + 1, ya (current) + 1, red, black)
drawfill (xa + 1, ya (current) - 401, white, black)
else
current := current - 1

end if

end loop

end selection

procedure scoretok
if dv (1) = dv (2) = dv (3) then
scoretok
elsif dv (2) = dv (3) = dv (4) then
scoretok
elsif dv (3) = dv (4) = dv (5) then
scoretok
end scoretok
%Main Program

scorecard
rolldice
selection
Sponsor
Sponsor
Sponsor
sponsor
Sean




PostPosted: Fri May 30, 2008 2:46 pm   Post subject: Re: Help with Yahtzee

Well, you never stated what you needed help with.

Must do that before you expect an answer with your corrections. People can find many problems with your code, that could be completely opposite to what you want. Be specific Laughing
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  [ 2 Posts ]
Jump to:   


Style:  
Search: