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

Username:   Password: 
 RegisterRegister   
 Mouse.where / if statements
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jessica359




PostPosted: Mon Mar 10, 2008 3:43 pm   Post subject: Mouse.where / if statements

Hey,
for this program I have 2 problems.
#1 In my introduction after the flash screen it says please write go to continue but i want to get the user to click on the beaver instead. I vagely remember doign something like that last year using mouse.where or GUI something like that, i really don't remember.

#2 At the end we have to show the outcome of the user's score with a graph. I want a certain graph to show up with a certain score. I don't know if i'm doing my if statements wrong or if its jsut not possible?

I have a few more glitches to work out but those 2 are the main problems.

Thanks Canada

code:

setscreen ("graphics:700;500")

proc map
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
end map

var answer : string
var s : int
s := 0
var font1 : int
font1 := Font.New ("Castellar:18")
assert font1 > 0

var font2 : int
font2 := Font.New ("Curlz MT:18")
assert font2 > 0

var font3 : int
font3 := Font.New ("Georgia:18")
assert font3 > 0

var font4 : int
font4 := Font.New ("Forte:18")
assert font4 > 0

var font5 : int
font5 := Font.New ("Castellar:35")
assert font5 > 0

var font6 : int
font6 := Font.New ("Georgia:30")
assert font6 > 0

var font7 : int
font7 := Font.New ("Arial Black:30")
assert font7 > 0

var font8 : int
font8 := Font.New ("Arial:14")
assert font8 > 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc flash
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("quebec flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("BC Flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("nova scotia flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("Alberta Flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("pei flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("saskatchewan flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("newfoundland flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("manitoba flag.jpg.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("nunavut flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("Ontario Flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("north west territories flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("New brunswick flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("yukon flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
end flash

%%%%%%%%%%%%%%%%%%%%%%
proc intro
    Pic.ScreenLoad ("CanadianFlag.jpg", -60, 0, picMerge)
    Font.Draw ("Are you a TRUE Canadian?", 55, 450, font6, 7)
    delay (1000)
    Font.Draw ("EH?", 550, 450, font7, 7)
    delay (1000)
    Font.Draw ("This is the 'Are you a TRUE Candadian EH?' Quiz", 5, 350, font8, 7)
    Font.Draw ("This quiz is on the capitals of the Canadian Provinces and Territories.", 5, 330, font8, 7)
    Font.Draw ("You have 3 tries for each province/territory. Your score will be displayed at the end.", 5, 310, font8, 7)
    Font.Draw ("Pretty Simple? Good LUCK!", 5, 290, font8, 7)
    Font.Draw ("PS. Turn up the volume!", 5, 250, font8, 7)
    Font.Draw ("Please write go to start.", 5, 270, font8, 7)
    Pic.ScreenLoad ("beaver.gif", 50, 40, picMerge)
    locatexy (300, 400)
    get answer
    if answer = "go" or answer = "Go" or answer = "GO"
            then
        cls
    end if

end intro



%%%%%%%%%%%%%%%%%%%%%

proc bc
    Music.PlayFileLoop ("Techno - O Canada.mp3")

    for decreasing c : 2 .. 0
        % British Colombia

        Font.Draw ("What is the Capital of British Colombia?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Victoria" or answer = "victoria" then
            Font.Draw ("WOOT -happy dance-", 400, 250, font2, 79)
            s := s + 1
            delay (2000)
            exit
        else
            Font.Draw ("YOU ARE SO...NOT RIGHT!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 420, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if

    end for
    cls
end bc

%%%%%%%%%%%%
proc ab
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Alberta
        Font.Draw ("What is the Capital of Alberta?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Edmonton" or answer = "edmonton" then
            Font.Draw ("RIGHTO", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("hahaha... no", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end ab

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc sas
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Saskatchewan
        Font.Draw ("What is the Capital of Saskatchewan?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Regina" or answer = "regina" then
            Font.Draw ("OH YA!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("NADA", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end sas

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc man
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Manitoba
        Font.Draw ("What is the Capital of Manitoba?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Winnipeg" or answer = "winnipeg" then
            Font.Draw ("YAY!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("NOPE", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end man

%%%%%%%%%%%%%%%%%%%%%%%%%%
proc ont
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Ontario
        Font.Draw ("What is the Capital of Ontario?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Toronto" or answer = "toronto" then
            Font.Draw ("Of course you know!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("Come on!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end ont

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc qu
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Quebec
        Font.Draw ("What is the Capital of Quebec?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Quebec" or answer = "quebec" then
            Font.Draw ("BIEN OUI!!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("ALLEZ, CE N'EST PAS DIFFICILE!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end qu

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc nb
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % New Brunswick
        Font.Draw ("What is the Capital of New Brunswick?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Fredericton" or answer = "fredericton" then
            Font.Draw ("SCORE!!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("MISS!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end nb

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc ns
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Quebec
        Font.Draw ("What is the Capital of Nova Scotia?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Halifax" or answer = "halifax" then
            Font.Draw ("HIT!!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("SUNK!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end ns

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc pei
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % pei
        Font.Draw ("What is the Capital of PEI?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Charlottetown" or answer = "charlottetown" then
            Font.Draw ("YUPPERS!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("BLAH NO!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end pei
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc nl
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Newfoundland and Labrador
        Font.Draw ("What is the Capital of Newfoundland?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "St.John's" or answer = "st.john's" or answer = "st.johns" or answer = "St.Johns" then
            Font.Draw ("Thumbs UP!!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("Thumbds Down!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end nl

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc nt
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Northwest Territories
        Font.Draw ("What is the Capital of Northwest Territories?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Yellowknife" or answer = "yellowknife" then
            Font.Draw ("GOOD!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("BAD!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end nt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc nu
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Nunavut
        Font.Draw ("What is the Capital of Nunavut?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Iqualuit" or answer = "iqualuit" or answer = "iqaluit" or answer = "iqaluit" then
            Font.Draw ("Positive!!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("Negative!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls
end nu

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc yu
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    for decreasing c : 2 .. 0
        % Yukon
        Font.Draw ("What is the Capital of Yukon?", 0, 450, font1, 111)
        locatexy (300, 400)
        get answer
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)


        if answer = "Whitehorse" or answer = "whitehorse" then
            Font.Draw ("YES!", 400, 250, font2, 79)
            s := s + 1
            delay (1000)
            exit
        else
            Font.Draw ("NO!", 350, 250, font4, 79)
            Font.Draw ("Number of gueses left", 10, 10, font2, 38)
            locatexy (650, 10)
            put c
        end if
        if c = 0 then
            cls
            Font.Draw ("GAME OVER!", 50, 50, font2, 56)
        end if
    end for
    cls

end yu

proc score
    Pic.ScreenLoad ("CanadianFlag.jpg", -60, 0, picMerge)
    Pic.ScreenLoad ("beaver.gif", 250, 150, picMerge)
    locatexy (270, 500)
    put "Your score is..."
    locatexy (400, 500)
    put s / 13 * 100
    Music.PlayFileStop
    delay (2500)
    cls
end score


proc graph
    drawfillbox (10, 0, 400, 500, 7)
    drawfillbox (500, 300, 450, 350, 55)
    drawfillbox (500, 200, 450, 250, 40)
    Font.Draw ("Wrong", 540, 210, font3, 7)
    Font.Draw ("Right", 540, 315, font3, 7)


    if s < 1 and s < 9 then
        % O right 100 wrong
        %Right
        drawfillbox (100, 0, 150, 0, 55)
        %wrong
        drawfillbox (250, 0, 300, 490, 40)
    elsif s > 10 and s < 19 then
        % 10 right 90 wrong
        %Right
        drawfillbox (100, 0, 150, 50, 55)
        %wrong
        drawfillbox (250, 0, 300, 450, 40)
    elsif s > 20 and s < 29 then
        % 20 right 80 wrong
        %Right
        drawfillbox (100, 0, 150, 100, 55)
        %wrong
        drawfillbox (250, 0, 300, 400, 40)

    elsif s > 30 and s < 39 then
        % 30 right 70 wrong
        %Right
        drawfillbox (100, 0, 150, 150, 55)
        %wrong
        drawfillbox (250, 0, 300, 350, 40)

    elsif s > 40 and s < 49 then
        % 30 right 70 wrong
        %Right
        drawfillbox (100, 0, 150, 200, 55)
        %wrong
        drawfillbox (250, 0, 300, 300, 40)

    elsif s > 50 and s < 59 then
        % 50 right 50 wrong
        %Right
        drawfillbox (100, 0, 150, 250, 55)
        %wrong
        drawfillbox (250, 0, 300, 250, 40)

    elsif s > 60 and s < 69 then
        % 60 right 40 wrong
        %Right
        drawfillbox (100, 0, 150, 300, 55)
        %wrong
        drawfillbox (250, 0, 300, 200, 40)

    elsif s > 70 and s < 79 then
        % 70 right 30 wrong
        %Right
        drawfillbox (100, 0, 150, 350, 55)
        %wrong
        drawfillbox (250, 0, 300, 150, 40)

    elsif s > 80 and s < 89 then
        % 80 right 20 wrong
        %Right
        drawfillbox (100, 0, 150, 400, 55)
        %wrong
        drawfillbox (250, 0, 300, 100, 40)

    elsif s > 90 and s < 99 then
        % 90 right 10 wrong
        %Right
        drawfillbox (100, 0, 150, 450, 55)
        %wrong
        drawfillbox (250, 0, 300, 50, 40)

    elsif s > 100 then
        % 100 right 0 wrong
        %Right
        drawfillbox (100, 0, 150, 490, 55)
        %wrong
        drawfillbox (250, 0, 300, 0, 40)
    end if
end graph

flash
intro
map
bc
ab
sas
man
ont
qu
nb
ns
pei
nl
nu
nt
yu
score
graph
Sponsor
Sponsor
Sponsor
sponsor
Sean




PostPosted: Mon Mar 10, 2008 5:19 pm   Post subject: Re: Mouse.where / if statements

Well, for #1, you are wanting to click the Beaver, trace it's x and y coordinates and have the mouse click anywhere between it.
A.J




PostPosted: Mon Mar 10, 2008 5:43 pm   Post subject: Re: Mouse.where / if statements

And for #2, I don't see where the user's score is stored? (I am sry, but I am kinda in a hurry Very Happy)
But Iwould advise you to make a save/load option. PM me or just ask me when you finally give up Very Happy

A.J
Jessica359




PostPosted: Mon Mar 10, 2008 7:04 pm   Post subject: RE:Mouse.where / if statements

For #1, i know the coordinates so i would use what? Mouse.where?

For #2 score is stored as "s".

This is really confusing! :S

Very Happy thanks
Jessica359




PostPosted: Tue Mar 11, 2008 1:52 pm   Post subject: RE:Mouse.where / if statements

Alright,

So far i got everything the way i wanted it except for the graph, i am still stuck on it.
Is there a way mayby int he if statement to say that
if score is greater then 90 and less then 80
put ...

thanks Very Happy
Sean




PostPosted: Tue Mar 11, 2008 2:16 pm   Post subject: Re: Mouse.where / if statements

What type of graph are you attempting to accomplish?
Jessica359




PostPosted: Tue Mar 11, 2008 5:57 pm   Post subject: RE:Mouse.where / if statements

A bar graph,
that depending on the user's score it will display a different bard graph. Like if the user gets a 40% you will see 2 bars, the one that says "wrong" will be higer then the one that says "right".
syntax_error




PostPosted: Tue Mar 11, 2008 7:04 pm   Post subject: RE:Mouse.where / if statements

look up draw.box
Sponsor
Sponsor
Sponsor
sponsor
Sean




PostPosted: Wed Mar 12, 2008 6:52 am   Post subject: Re: Mouse.where / if statements

Draw.FillBox should be used.

You will want it to check the total score, then draw a graph according to the percentage, so you should have the same width of the bar, but they 2nd Y co-ordinate that effects the height should be minipulated depending on the percent of how much you got right or wrong.
A.J




PostPosted: Wed Mar 12, 2008 12:02 pm   Post subject: Re: Mouse.where / if statements

Vilament is right.
Draw.FillBox can be used in creating the "life increasing" part
here's a simple (and crude) example:
Turing:

var x := maxx div 2
var y := maxy div 2
Draw.FillBox (x - 115, y - 25, x + 115, y + 25, blue)
Draw.FillBox (x - 110, y - 20, x + 110, y + 20, yellow)
Draw.FillBox (x - 100, y - 10, x + 100, y + 10, white)
for i : -100 .. 100
    Draw.FillBox (x - 100, y - 10, x + i, y + 10, green)
    delay(10)
end for

Tell me if this helps, as it may not be what you're looking for Very Happy
Jessica359




PostPosted: Wed Mar 12, 2008 7:17 pm   Post subject: RE:Mouse.where / if statements

Ya i get what you guys mean but i think i'm doing something wrong in my if statements or would case construct work better in this case?

Or probably the asnwer is sitting right in front of me and I am completely blind WinkVery Happy
A.J




PostPosted: Wed Mar 12, 2008 7:39 pm   Post subject: Re: Mouse.where / if statements

I don't think any of your if statements are the problem.
For #1, just Draw a bow around the beaver and check if the user clicks anywhere in the box using the co-ordinates of the mouse to see if they are in range.
For #2: Your bar graph looks okay, but if you want to add things like numbers showing how many the person got wring, just add the numbers beside our graph so that people will know the indexing of your graph.
I know, I know...don't tell me.. I MAKE NO SENSE!!
just see if this what u wanted Very Happy

A.J
Sean




PostPosted: Wed Mar 12, 2008 9:36 pm   Post subject: Re: Mouse.where / if statements

I agree with A.J.

The if statements are not the problem, they are fine. I suggest drawing an invisable box, or a black box around it, so they know where to click.

You'll want to check the starting x co-ordinate, to the end x co-ordinate, then the y's. If the click is in the box, or the dimension, then it should work.
Jessica359




PostPosted: Thu Mar 13, 2008 10:35 am   Post subject: RE:Mouse.where / if statements

Awesome! thanks to both of you I got #1 working but #2 still is a blank.

If you look at the program i put out up in my first post, if the user gets 100 it should ouput 2 specific bars, one that outputs how much he got right and another of how much he got wrong. But the only graph thats working is if the suer gets 0 as a score. any otehr score the graph doesn't work.
For teh if statements I told it to that if the score is (some much) then ouput these 2 bars but I have no clue why its not working. Instead of saying if score is greater then 90 then out this graph would there be a way to say if score is in between 90 and 100 then put this graph?

Sorry if i'm not making any sense and if i'm not getting what ur saying Wink
Once somehow this is figured out its probably gunna be a dum blond thing as usual Wink

thanks for all your help sory if its frustrating Wink
A.J




PostPosted: Thu Mar 13, 2008 10:54 am   Post subject: Re: Mouse.where / if statements

I finally get what you are looking for Very Happy
instead of what you did, I think this will be better :
Turing:

proc graph
    drawfillbox (10, 0, 400, 500, 7)
    drawfillbox (500, 300, 450, 350, 55)
    drawfillbox (500, 200, 450, 250, 40)
    Font.Draw ("Wrong", 540, 210, font3, 7)
    Font.Draw ("Right", 540, 315, font3, 7)
    var right := floor ((s / 13) * 490)
    var wrong := floor (((13 - s) / 13) * 490)
    if right = 13 then
        drawfillbox (100, 0, 150, right, 55)
        return
    elsif right = 0 then
        drawfillbox (250, 0, 300, wrong, 40)
        return
    else
        drawfillbox (100, 0, 150, right, 55)
        drawfillbox (250, 0, 300, wrong, 40)
    end if
end graph

This way, you don't have to check every single possibility of s.
This checks the percentage of correct answers (s/13) and finds that many percent of
490 (since 490 covers the full screen). So if the person gets 13 (perfect!)the bar graph would be
(13/13)*490, which covers the full screen.
Another mistake of yours is if a person gets perfect, you draw the 'wrong' graph also!
you SHOULDN'T do that. If a person gets everything wrong or everything right, you shouldn't draw the other graph at all.
So, I checked if s=0 or s=13 and I only drew the appropriate graph.
Tell me if this helps Very Happy

A.J
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 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: