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

Username:   Password: 
 RegisterRegister   
 Who Wants to be A Millionaire Game Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
imanoob




PostPosted: Wed Jan 15, 2014 12:46 am   Post subject: Who Wants to be A Millionaire Game Help

I have a project for ICS and I am having trouble with my game of Who Wants to Be A Millionaire. (IM A NOOB)

What I am having trouble with:
Using Help options is mandatory, so I attempted to use the 3 standard options in Who wants to be a millionaire, Call a friend, 50/50, and Ask the Audience. This works to an extent, only the user may only use these options ONCE per game.

My Problem:
In my program I could not figure out how to make the options disappear once they were used. Preferably once they are used, they say the word "Used" or something along those lines. The output of the help options are done sloppily but i dont mind that.

Also, when you click my help options it re-arranges all the answers so that the first one, A, is ALWAYS the correct answer! This is my BIGGEST problem.

I would really appreciate any help.

My code is attached, Yes it is long BUT THATS ONLY CAUSE THERE ARE 30 questions. i attached it on NOTEPAD.



WHO WANTS TO BE A MILLIONAIRE.txt
 Description:

Download
 Filename:  WHO WANTS TO BE A MILLIONAIRE.txt
 Filesize:  89.88 KB
 Downloaded:  1138 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Wed Jan 15, 2014 8:53 am   Post subject: RE:Who Wants to be A Millionaire Game Help

You'll save yourself a lot of pain if you learn to use arrays and file IO to keep question data separate from your code.

What you need to do is change how the buttons are rendered, and remove the click-detection for those options which have been used (or, make clicking them display a "hey, you already used that" message). Unfortunately, you have probably 30-60 instances of this code throughout your program. You should have exactly one. Computers don't forget, so don't bother repeating yourself.

You'll notice that repeating yourself leads to buggy behaviour: in several of your questions, you draw duplicate answers. See level9q2 for an example, though there are several.
Planet_Fall




PostPosted: Fri Jan 17, 2014 2:32 pm   Post subject: Re: Who Wants to be A Millionaire Game Help

Found your problem.

What the stuff in comments was doing was put the answers in new locations when you just wanted them to stay in the right place.
However by how the code is written, by clicking the right answer. It makes it wrong.
The only thing I can think of is to make the answer location into a procedure and the Mouse.Where command into a procedure as well.
Sorry. Neutral I know this isn't much help.

Turing:


% The ask the audience help option.
body proc audience
if audienceCounter=0 then % Is used to determine where this help option has been used or not
audienceCounter:=1

%             THIS IS THE PROBLEM
%    drawfillbox (25, 200, 200, 250, purple)
%    drawfillbox (25, 100, 200, 150, yellow)
%    drawfillbox (425, 100, 600, 150, green)
%    drawfillbox (425, 200, 600, 250, brightblue)
     locate (14,1)

put "90% of the audience believes that, ", answer," is the correct answer."

%             THIS IS THE PROBLEM
%    Font.Draw (answer, 30, 225, defFontID, yellow)
%    Font.Draw (wrongAnswer1, 30, 125, defFontID, purple)
%    Font.Draw (wrongAnswer2, 430, 125, defFontID, yellow)
%    Font.Draw (wrongAnswer3, 430, 225, defFontID, brightgreen)
   
   loop % Check for button clicks
        Mouse.Where (x, y, button)
     exit when button=1 and  x >= 25 and x <= 200 and y >= 200 and y <= 250 or button=1 and x >= 25 and x <= 200 and y >= 100 and y <= 150 or button =1 and x >= 425 and x <= 600 and y >= 100 and y <= 150 or button =1 and x >= 425 and x <= 600 and y >= 200 and y <= 250 or button=1 and x >= 25 and x <= 50 and y >= 25 and y <= 50
     end loop   
     if button = 1 then % Used when the button is clicked to deside what answer the user has chosen, or whether the user chose a help option
            if x >= 25 and x <= 200 and y >= 200 and y <= 250 then
                correctAnswer
                clickCounter:=1
            elsif x >= 25 and x <= 200 and y >= 100 and y <= 150 then
                loser
                clickCounter:=1
            elsif x >= 425 and x <= 600 and y >= 100 and y <= 150 then
                loser
                clickCounter:=1
            elsif x >= 425 and x <= 600 and y >= 200 and y <= 250 then
                loser
                clickCounter:=1
                         
             end if
        end if
       
      elsif audienceCounter=1 then
             locate (7,2)
put "You have already used this help option"

drawfillbox (25, 200, 200, 250, purple)
    drawfillbox (25, 100, 200, 150, yellow)
    drawfillbox (425, 100, 600, 150, green)
    drawfillbox (425, 200, 600, 250, brightblue)
     
    Font.Draw (answer, 30, 225, defFontID, white)
   Font.Draw (wrongAnswer1, 30, 125, defFontID, purple)
    Font.Draw (wrongAnswer2, 430, 125, defFontID, yellow)
    Font.Draw (wrongAnswer3, 430, 225, defFontID, brightgreen)
   
   loop % Checks for button clicks
        Mouse.Where (x, y, button)
     exit when button=1 and  x >= 25 and x <= 200 and y >= 200 and y <= 250 or button=1 and x >= 25 and x <= 200 and y >= 100 and y <= 150 or button =1 and x >= 425 and x <= 600 and y >= 100 and y <= 150 or button =1 and x >= 425 and x <= 600 and y >= 200 and y <= 250
     end loop   
     if button = 1 then
            if x >= 25 and x <= 200 and y >= 200 and y <= 250 then
                correctAnswer
                clickCounter:=1
            elsif x >= 25 and x <= 200 and y >= 100 and y <= 150 then
                loser
                clickCounter:=1
            elsif x >= 425 and x <= 600 and y >= 100 and y <= 150 then
                loser
                clickCounter:=1
            elsif x >= 425 and x <= 600 and y >= 200 and y <= 250 then
                loser
                clickCounter:=1
                end if
                end if
    end if
end audience
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  [ 3 Posts ]
Jump to:   


Style:  
Search: