Computer Science Canada

Turing Help- Drawbox with mouse

Author:  konrbear [ Wed May 14, 2014 10:04 am ]
Post subject:  Turing Help- Drawbox with mouse

What is it you are trying to achieve?
Trying to make it so the first click points the first x, y and the second click points the second x1, y1 and after makes a sqaure.

What is the problem you are having?
I have it so you need to hold down the mouse to draw the sqaure, where i want it to have only 2 clicks then it draws the square.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
code:

var x, y, x1, y1, button, button1 : int                %variables to hold values picked up from the mouse
var ovalColor : int
var counter : int := 0
setscreen ("graphics:640, 400")
loop
    loop   %check the mouse over and over

        delay (1)
        mousewhere (x, y, button)
        if button = 1 then
            mousewhere (x, y, button)
            exit
        end if
    end loop
    loop  %check the mouse over and over

        delay (10)
        mousewhere (x1, y1, button1)
        if button = 1 then
            mousewhere (x1, y1, button1)
            exit
        end if
    end loop
    drawbox (x, y, x1, y1, red)

end loop


Please specify what version of Turing you are using
4.1.1

Author:  DemonWasp [ Wed May 14, 2014 12:08 pm ]
Post subject:  RE:Turing Help- Drawbox with mouse

Your first loop waits until the mouse button goes down (button = 1). If the second loop is waiting for the mouse button to come up, what should the condition be checking?


: