Computer Science Canada

Window Follow

Author:  Carey [ Fri Mar 28, 2008 7:37 am ]
Post subject:  Window Follow

Quick program that took like 2 minuts to make.

Turing:
%size of window
const hx := 100
const hy := 100

var mx, my, mb : int
var x, y := 10
var win := Window.Open ("graphics:" + intstr (hx * 2) + ";" + intstr (hy * 2) + ", position:0;0")
loop
    Mouse.Where (mx, my, mb)
    %remove the next line to evoke frustrated screams :)
    exit when mb > 0
    if mx not= hx or my not= hy then
        x -= hx - mx
        y -= hy - my
        setscreen ("position:" + intstr (x) + ";" + intstr (y))
    end if
end loop

Author:  Sean [ Fri Mar 28, 2008 11:58 am ]
Post subject:  Re: Window Follow

It's an interesting program but if you click, it stops and you can't start it again.

Now, your challenge would be to fix that. Mr. Green

Other then that, I like it!

Author:  DaveAngus [ Fri Mar 28, 2008 12:07 pm ]
Post subject:  RE:Window Follow

Really cool.
I like that.
And yes the whole clicking thing would be a good fix.
Also, maybe use that to make something within the run box.
So make an object follow it.
I'm not sure just trying to help you keep thinking about programs.
Good job none the less!

-Dave

Author:  Sean [ Fri Mar 28, 2008 12:53 pm ]
Post subject:  Re: Window Follow

Turing:

exit when mb > 0


My bad, didn't notice the exit when I first took a look at it.

Author:  SIXAXIS [ Fri Mar 28, 2008 10:23 pm ]
Post subject:  Re: Window Follow

I changed the code a bit so that to move the window you have to click and to exit you can press ALT+F4.

Turing:

%size of window
const hx := 100
const hy := 100

var mx, my, mb : int
var chars : array char of boolean
var x, y := 10
var win := Window.Open ("graphics:" + intstr (hx * 2) + ";" + intstr (hy * 2) + ", position:0;0")
loop
    Input.KeyDown (chars)
    if chars (KEY_ALT) and chars (KEY_F4) then
        exit
    end if
    Mouse.Where (mx, my, mb)
    if mb = 1 then
        %remove the next line to evoke frustrated screams :)
        if mx not= hx or my not= hy then
            x -= hx - mx
            y -= hy - my
            setscreen ("position:" + intstr (x) + ";" + intstr (y))
        end if
    end if
end loop


Hope you don't mind I changed it Carey.

Author:  BigBear [ Sat Mar 29, 2008 8:45 am ]
Post subject:  Re: Window Follow

I like how you click the x in the top corner to terminate program it just teleports and doesn't work.
You should close the window when alt-F4 is pressed.

Author:  Carey [ Mon Mar 31, 2008 12:05 pm ]
Post subject:  RE:Window Follow

Ha. Ya it was fun to stick it in the startup folder with the exit line removed and watch my brother (not great with computers) try for about 10 minutes to close it, until i took pity on him and told him how to get to the task manager to shut it down.

@SIXAXIS nah i don't mind. Its cool your way too. maybe put it on a delay or something so when the user finally gets it to stop following the mouse and thinks they have won......They click the x and it teleports again Smile ahh.......infinite doom and carnage Smile Without the press alt-F4 of course >Smile


: