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

Username:   Password: 
 RegisterRegister   
 Mouse.ButtonMoved/Mouse.ButtonWait
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CooKieLord




PostPosted: Thu Jan 05, 2006 9:35 pm   Post subject: Mouse.ButtonMoved/Mouse.ButtonWait

Hello, I am new here and I was looking up some threads that might be relevant to my question, without too much luck. I'm making a program similar to the popular TV show "Who Wants to be a Millionnaire?" for my Computer Programming class. Now I'm presented with a problem that has stumped me.

I tried using a GUI with buttons for the four choices. I found it ugly, and wanted to use a background with the actual colours and interface that they used in the TV show. Now to pick the answers, the user must click within the boundries that I've set, in order to pick the answer.

code:
for x : 1 .. 15
    Window.SetActive (boutton)
    Font.Draw (question (x), 70, maxy - 35, defFontID, white)
    Font.Draw (reponsea (x), 75, (maxy div 2) - 15, defFontID, white)
    Font.Draw (reponseb (x), (maxx div 2) + 60, (maxy div 2) - 15, defFontID, white)
    Font.Draw (reponsec (x), 75, 15, defFontID, white)
    Font.Draw (reponsed (x), (maxx div 2) + 60, 15, defFontID, white)
    loop
        if buttonmoved ("down") and m1 >= 0 and m1 <= 170 and m2 <= -350 and m2 >= -380 and mb = 1 then
            buttonwait ("down", mx, my, dummy1, dummy2)
            a
        end if

        if buttonmoved ("down") and m1 >= 230 and m1 <= 400 and m2 <= -350 and m2 >= -380 and mb = 1 then
            buttonwait ("down", mx, my, dummy1, dummy2)
            b
        end if

        if buttonmoved ("down") and m1 >= 0 and m1 <= 170 and m2 <= -395 and m2 >= -425 and mb = 1 then
            buttonwait ("down", mx, my, dummy1, dummy2)
            c
        end if

        if buttonmoved ("down") and m1 >= 230 and m1 <= 400 and m2 <= -3395 and m2 >= -425 and mb = 1 then
            buttonwait ("down", mx, my, dummy1, dummy2)
            d
        end if
        exit when out = true
    end loop
    cls
    Window.SetActive (boutton)
    Pic.ScreenLoad ("choix2.bmp", 0, 0, picMerge)
    Window.SetActive (text)
    put reponse
    delay (5000)
end for


The last bit of the coding is just to test to see if it worked, for now.

Now the essential problem that arrises is, how to make the program, wait for the input to happen. Much like the "get" statement, I need the program to wait until the user click on one of the four imaginary boxes.

I've read the "How to post" stickies and such, and I hope that this is a good format. If not, please, tell me what's wrong, I'll try and fix it up so I meet the standards.

Thanks in advance for all the help you've provided.

-CooKieLord
Sponsor
Sponsor
Sponsor
sponsor
Albrecd




PostPosted: Thu Jan 05, 2006 9:40 pm   Post subject: (No subject)

put it in a loop
CooKieLord




PostPosted: Thu Jan 05, 2006 11:03 pm   Post subject: (No subject)

Ok I remember putting it in a loop (as you can see in my coding) and once I click on an answer (When I run the program), it returns a "Variable has no value" error at this line

code:
if buttonmoved ("down") and m1 >= 0 and m1 <= 170 and m2 <= -350 and m2 >= -380 and mb = 1 then


For refrence, "m1" refers to the "x" coordinate on my mouse and "m2" refers to the "y" coordinate.
Saad85




PostPosted: Fri Jan 06, 2006 1:20 am   Post subject: (No subject)

you probably didnt put the mousewhere command in the loop.
CooKieLord




PostPosted: Mon Jan 09, 2006 1:28 pm   Post subject: (No subject)

I tried putting a mousewhere in the loop but it still doesn't work. I tried completely removing the mousebuttonmoved and mousebuttonwait for mousewhere, but it doesn't show me results at the moment. I'm tyring to redo it but I can't manage it to work. Maybe it's my squares?

code:
for x : 1 .. 15
    Window.SetActive (boutton)
    Font.Draw (question (x), 70, maxy - 35, defFontID, white)
    Font.Draw (reponsea (x), 75, (maxy div 2) - 15, defFontID, white)
    Font.Draw (reponseb (x), (maxx div 2) + 60, (maxy div 2) - 15, defFontID, white)
    Font.Draw (reponsec (x), 75, 15, defFontID, white)
    Font.Draw (reponsed (x), (maxx div 2) + 60, 15, defFontID, white)
    loop
        mousewhere (m1, m2, mb)
        if m1 >= 0 and m1 <= 170 and m2 <= -350 and m2 >= -380 and mb = 1 then
                        a
            %        end if

        elsif m1 >= 230 and m1 <= 400 and m2 <= -350 and m2 >= -380 and mb = 1 then
                        b
            %end if

        elsif m1 >= 0 and m1 <= 170 and m2 <= -395 and m2 >= -425 and mb = 1 then
                        c
            %end if

        elsif m1 >= 230 and m1 <= 400 and m2 <= -3395 and m2 >= -425 and mb = 1 then
                        d
        end if
        exit when out = true
    end loop

    if reponse = bonne (x) then
        Window.SetActive (text)
        put "Tu as gagner de l'argent."
    else
        put "Tu as perdu ton argent."
    end if
    cls
    Window.SetActive (boutton)
    Pic.ScreenLoad ("choix2.bmp", 0, 0, picMerge)
    Window.SetActive (text)
end for
%


The "a", "b", "c," and "d" are procedures that change the answer (reponse) (Sorry, I go to a french school Razz) and looks like this essentially

code:
procedure a

    reponse := "a"
    out := true

end a
Albrecd




PostPosted: Mon Jan 09, 2006 1:36 pm   Post subject: (No subject)

What part of the program is having the error? (I mean what specific area [line for example], I know that it's with the mouse input.)
CooKieLord




PostPosted: Mon Jan 09, 2006 2:12 pm   Post subject: (No subject)

Well this is a section of the program I'm working on, so it's this section that is causing me a problem, the mouse input.

I didn't finish it yet since I like to solve problems as I'm programming (So right now, I don't have the lifelines and completed money system) but this is what I have so far. Please don't mind the french, I do go to a french school.

It starts at line 250.



Millionnaire.zip
 Description:
Final Prject for my french school. Who wants to be a millionnaire remake.

Download
 Filename:  Millionnaire.zip
 Filesize:  63.48 KB
 Downloaded:  129 Time(s)

CooKieLord




PostPosted: Wed Jan 11, 2006 2:07 pm   Post subject: (No subject)

Forgive my double posting, but I decided to bump this topic rather than making a new one. I have overcome my major problem in this project, and all that is left is to make my lifelines. They are working properly, except for the "Ask the Audience" one. I'm not sure as to how to go and divide 100% randomly into 4 and having the right answer with the highest %.

Example: The corretc answer is c).

The user would ask the audience, and then 100 would be randomly divided into 4, but the answer "c" would be the highest.

"The Audience says 'a':10%, 'b': 34%, 'c' 51% and 'd':5%"
But the answers generated has to be diffrent everytime the lifeline is used. I'm not sure is I,m clear on this, but any help is very appreciated.
(As well, maybe have a mod modify the topic name to "Who Wants to be a Millionnaire" or something please Smile )
Sponsor
Sponsor
Sponsor
sponsor
chrispminis




PostPosted: Wed Jan 11, 2006 5:35 pm   Post subject: (No subject)

Try using random integers and a little arithmetic. For example say c is the correct answer then.
code:

c := Rand.Int (50, 100)
then

a := Rand.Int (1, 100 - c)

b := Rand.Int (1, 100 - c - a)

d := Rand.Int (1, 100 - c - a - b)


Or something like that.
codemage




PostPosted: Thu Jan 12, 2006 10:30 am   Post subject: (No subject)

That might end you up with a total response of much less than 100% because of how the last one is calculated.

Perhaps...

var c := Rand.Int (20, 65)
var a := Rand.Int (1, 85 - c)
var b := Rand.Int (1, 85 - c - a)
var d := (100 - c - a - b)

(You'll have to tweak the numbers a bit - it's possible to get errors)

And... if you want to be capricious, you can do an AOL ask the audience that always gives the wrong answer. Surprised
CooKieLord




PostPosted: Thu Jan 12, 2006 6:18 pm   Post subject: (No subject)

codemage wrote:
That might end you up with a total response of much less than 100% because of how the last one is calculated.

Perhaps...

var c := Rand.Int (20, 65)
var a := Rand.Int (1, 85 - c)
var b := Rand.Int (1, 85 - c - a)
var d := (100 - c - a - b)

(You'll have to tweak the numbers a bit - it's possible to get errors)

And... if you want to be capricious, you can do an AOL ask the audience that always gives the wrong answer. Surprised


I pretty much used that, thanks alot!
chrispminis




PostPosted: Thu Jan 12, 2006 6:37 pm   Post subject: (No subject)

Oh yeah, my bad, I meant it to be that d is the rest but i got caught up in repeating random integers lol.
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  [ 12 Posts ]
Jump to:   


Style:  
Search: