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

Username:   Password: 
 RegisterRegister   
 Checking if checkbox is unchecked
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: Thu Jan 20, 2005 6:46 pm   Post subject: Checking if checkbox is unchecked

I'm making a yahtzee game, and I want to check if the checkbox is NOT checked. I know that

if cbstatus then
blah
end if

will check if it is checked. I've tried using 'not' before the cbstatus but it doesn't work. Please help! I've also tried looking if the check boxes work

code:

% The "GUI.CreateButtonFull" program.
import GUI

procedure DoNothing1 (x : boolean)
end DoNothing1
var die, die2, die3, die4, die5 : int
randint (die, 1, 6)
randint (die2, 1, 6)
randint (die3, 1, 6)
randint (die4, 1, 6)
randint (die5, 1, 6)
procedure RollDice
    cls
    %%%%%%%%%%%%%%%%%%%
    var c1 := GUI.CreateCheckBox (320, 280, "Hold", DoNothing1)
    var c2 := GUI.CreateCheckBox (220, 280, "Hold", DoNothing1)
    var c3 := GUI.CreateCheckBox (120, 280, "Hold", DoNothing1)
    var c4 := GUI.CreateCheckBox (420, 280, "Hold", DoNothing1)
    var c5 := GUI.CreateCheckBox (520, 280, "Hold", DoNothing1)
    var cb1Status : boolean := GUI.GetCheckBox (c1)
    var cb2Status : boolean := GUI.GetCheckBox (c2)
    var cb3Status : boolean := GUI.GetCheckBox (c3)
    var cb4Status : boolean := GUI.GetCheckBox (c4)
    var cb5Status : boolean := GUI.GetCheckBox (c5)
    if  cb1Status = true then
        randint (die, 1, 6)
    end if
    if  cb2Status then
        randint (die2, 1, 6)
    end if
    if cb3Status then
        randint (die3, 1, 6)
    end if
    if  cb4Status then
        randint (die4, 1, 6)
    end if
    if  cb5Status then
        randint (die5, 1, 6)
    end if
    drawbox (300, 300, 350, 350, black)
    drawbox (400, 300, 450, 350, black)
    drawbox (500, 300, 550, 350, black)
    drawbox (200, 300, 250, 350, black)
    drawbox (100, 300, 150, 350, black)
    GUI.Refresh
    colorback (white)
    var die0 : string := intstr (die)
    var die02 : string := intstr (die2)
    var die03 : string := intstr (die3)
    var die04 : string := intstr (die4)
    var die05 : string := intstr (die5)
    Draw.Text (die0, 320, 325, defFontID, black)
    Draw.Text (die02, 220, 325, defFontID, black)
    Draw.Text (die03, 120, 325, defFontID, black)
    Draw.Text (die04, 420, 325, defFontID, black)
    Draw.Text (die05, 520, 325, defFontID, black)
end RollDice


loop
    View.Set ("graphics:600;400,nobuttonbar")
    var draw : int := GUI.CreateButtonFull (50, 10, 0, "Roll Dice",
        RollDice, 0, '^D', true)
    drawbox (300, 300, 350, 350, black)
    drawbox (400, 300, 450, 350, black)
    drawbox (500, 300, 550, 350, black)
    drawbox (200, 300, 250, 350, black)
    drawbox (100, 300, 150, 350, black)
    loop
        exit when GUI.ProcessEvent
    end loop

end loop


however, it doesn't work properly. If the checkbox IS checked, it should roll. This does not happen
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sat Jan 22, 2005 8:50 pm   Post subject: (No subject)

Can you tell me a little something about the game? Like how it works and stuff?
Leftover




PostPosted: Sun Jan 23, 2005 1:48 am   Post subject: (No subject)

That would be a good start, I believe Very Happy
person




PostPosted: Tue Jan 25, 2005 8:37 pm   Post subject: (No subject)

how do u play the game?
basketball4ever




PostPosted: Wed Jan 26, 2005 1:14 am   Post subject: (No subject)

person wrote:
how do u play the game?


well if you dont know how to play x_X dont ask... but heres the rules off a page

Quote:
Yahtzee can be played in solitary or by a group. The group version simply consists of a number of players playing the solitary version simultaneously, with the highest score winning. I'll explain the solitary version, since that's what the applet lets you play (although you could use the "Clone Window" option to let multiple players play).
The game consists of 13 rounds. In each round, you roll the dice and then score the roll in one of 13 categories. You must score once in each category -- which means that towards the end of the game you may have to settle for scoring zero in some categories. The score is determined by a different rule for each category; see the section on Scoring below.

The object of the game is to maximize your total score (of course Smile. The game ends once all 13 categories have been scored.

Rolling the Dice
You have five dice which you can roll, represented by the die faces at the top of the applet window. To start with, you roll all dice by clicking on the Roll All button. After you roll all dice, you can either score the current roll, or re-roll any or all of the five dice.
To re-roll some of the dice, click on the toggle button underneath the die face you want to re-roll, then click on the Re-roll button. This will re-roll the selected dice, leaving the unselected ones unchanged.

You can roll the dice a total of three times -- the initial roll (in which you must roll all the dice), plus two re-rolls of any or all dice. After rolling three times, you must score the roll.

Once you've scored the roll, you roll all the dice again and repeat the process. You continue until all 13 categories have been filled, at which time the game is over.


Scoring
Once you have the dice face combination you want to score, you score the roll in one of the 13 categories. You do this by clicking on one of the radio buttons in either the Upper Scores or Lower Scores box. Once a category has been scored, it is closed out for the rest of the game; you cannot change a category's score once it's been set. Each category defines its own scoring rules, as described below.
Upper Scores
In the upper scores, you total only the specified die face. So if you roll:
3,3,4,3,6
and score in the Threes category, your total for that entry would be 9. This same roll would yield zero points if you scored it in the Aces (Ones), Twos, or Fives category, four points if you scored it in the Fours category, or six points if you scored it in the Sixes category.
When the game is over, if you score 63 or more upper points (an average of 3 die faces per category), you will get an upper bonus of 35 points. Of course do don't need to score exactly three die faces in each upper category to get the bonus, as long as the upper total is at least 63.


Lower Scores
In the lower scores, you score either a set amount (defined by the category), or zero if you don't satisfy the category requirements.
3 and 4 of a Kind
For 3 of a Kind, you must have at least three of the same die faces. If so, you total all the die faces and score that total. Similarly for 4 of a Kind, except that you must have 4 of the 5 die faces the same. So for example, if you rolled:
5,5,3,2,5
you would receive 20 points for 3 of a Kind, but zero points for 4 of a Kind.

Straights
Like in poker, a straight is a sequence of consecutive die faces; a small straight is 4 consecutive faces, and a large straight is 5 consecutive faces. Small straights score 30 points and large straights score 40 points. Thus, if you rolled:
5,4,3,2,6
you could score either a small straight or a large straight, since this roll satisfies both.

Full House
Again as in poker, a Full House is a roll where you have both a 3 of a kind, and a pair. Full houses score 25 points.

Yahtzee
A Yahtzee is a 5 of a Kind (i.e. all the die faces are the same), and it scores 50 points. If you roll more than one Yahtzee in a single game, you will earn a 100 point bonus for each additional Yahtzee roll, provided that you have already scored a 50 in the Yahtzee category. If you have not scored in the Yahtzee category, you will not receive a bonus. If you have scored a zero in the Yahtzee category, you cannot receive any bonuses during the current game.
You can also use subsequent Yahtzee's as jokers in the lower scores section, provided the following criteria have been satisfied:
5,5,5,5,5
You have scored a zero or 50 in the Yahtzee category.
You have filled the corresponding category in the upper scores section. For example, if you have rolled:

the Fives category must also be filled.
If this is the case, you can use the Yahtzee as a joker to fill in any lower scores category. You score the category as normal. Thus for the Small Straight, Large Straight, and Full House categories, you would score 30, 40, and 25 points respectively. For the 3 of a Kind, 4 of a Kind, and Chance categories, you would score the total of the die face. [/code]


http://grail.sourceforge.net/demo/yahtzee/rules.html

looks like poker to me : P well sorta like it... so ur design should be like a poker game.
Trojan Man




PostPosted: Wed Jan 26, 2005 2:59 am   Post subject: (No subject)

Since by default value of CheckBox is false, which means if u don't check it, it remains false, try making this:

code:

if cbStatus = false then
%your code
end if


Hope that helps...
Bacchus




PostPosted: Wed Jan 26, 2005 6:57 am   Post subject: (No subject)

im not entirely sure about checkboxes since ive never used them, but a boolean should work with not infront of the variable, give specific detail, if you put not does it give you an error you just not run?
person




PostPosted: Wed Jan 26, 2005 6:46 pm   Post subject: (No subject)

the check boxes are in turing help
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: