Computer Science Canada

offscreenonly + mouse.buttonmoved/wait problem

Author:  mrphillang [ Sun Dec 19, 2010 3:45 pm ]
Post subject:  offscreenonly + mouse.buttonmoved/wait problem

Offscreenonly + Mouse.ButtonMoved / Wait Problem


What is the problem you are having?
I'm trying to have a button where if the user clicks within the given perimeter, the window will close or to another screen. But this nullifies whenever I add in offscreenonly into the Window.Open (""). I'm using Mouse.ButtonMoved and Wait because I'm trying to avoid using any GUI functions!


Describe what you have tried to solve this problem
Well I used buttonmoved and wait for my menu, and I didn't include offscreenonly within window.open. What I did was if the user clicked within the perimeter for "New Game" it closed the window and opened a new one with the game. Within the new window, I did Window.Open and included offscreenonly. That let me get past the menu section. But within the game, I want an "Exit" button but how would I be able to do that with offscreenonly + buttonmoved / wait?


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I don't want to post my whole project because I know a lot of my classmates are on this site too... Too much cheating going on Razz Here's a simulation of what I'm trying to get at:

Turing:


% I know some variables are missing and pieces of code might be too. But what I'm trying to get at here is the Window.Open including the offscreeonly and Mouse.ButtonMoved / Wait

var winID : int
winID := Window.Open ("position:200;60,graphics:600;600,nobuttonbar,nocursor")

loop
        if Mouse.ButtonMoved ("down") then
            Mouse.ButtonWait ("down", mousex, mousey, btnNumber, btnUpDown)
            if mousex > centerx - 100 and mousex < centerx + 100 and mousey > centery and mousey < centery + 50 then
                newGame := true
                Window.Close (winID)
                exit
            end if
        end if
end loop

if newGame := true then
    loop
        winID := Window.Open ("position:200;60,graphics:600;600,nobuttonbar,nocursor,offscreeonly")
        if chars (KEY_RIGHT_ARROW) then
            x := x + 1
        end if
        drawfillbox (x, y, x + 10, y + 10, brightred)
        View.Update
        cls
    end loop
end if


Please specify what version of Turing you are using
4.1.1

Author:  TokenHerbz [ Sun Dec 19, 2010 5:42 pm ]
Post subject:  RE:offscreenonly + mouse.buttonmoved/wait problem

in your new game, why are you looping Window.Open. put that before the loop, and close the window after that loop.

offscreenonly should work (from how it looks) and if you want to continue to use any Mouse abilities, you have to tell that program that in your new window, in your new game loop.

ex: Mouse.Where(mx,my,mb) or in your case, the others.

Author:  mrphillang [ Sun Dec 19, 2010 6:00 pm ]
Post subject:  RE:offscreenonly + mouse.buttonmoved/wait problem

Yeah when I was typing in the code I meant for that to go before the loop. But that concern I'm having is even with the following code:

code:
var winID : int
winID := Window.Open ("position:200;60,graphics:600;600,nobuttonbar,nocursor,offscreenonly")

loop
        if Mouse.ButtonMoved ("down") then
            Mouse.ButtonWait ("down", mousex, mousey, btnNumber, btnUpDown)
            if mousex > centerx - 100 and mousex < centerx + 100 and mousey > centery and mousey < centery + 50 then
                newGame := true
                Window.Close (winID)
                exit
            end if
        end if
end loop


If I were to click within the given perimeters, nothing will happen unless I minisize and then open the window again.

Author:  TokenHerbz [ Sun Dec 19, 2010 6:24 pm ]
Post subject:  RE:offscreenonly + mouse.buttonmoved/wait problem

add View.Update

is your program (white) and not showing anything?

your code doesn't show it "drawing" anything.

But assuming your trying to "draw" a button to click on, your loops are in the wrong place, but try adding "View.Update"


Maybe i don't even get the question, I read what your wrote, but yeah,... Did i answer it?!

Author:  TokenHerbz [ Sun Dec 19, 2010 6:28 pm ]
Post subject:  RE:offscreenonly + mouse.buttonmoved/wait problem

if that is indeed the case, I'll explain why...

offscreenonly makes your prgrams "outputs" not show up, but it hides them in a secret buffer of magical sorts. If you want to see these magical outputs, we have to use View.Update.

id recommend the following type of format.

loop
cls
draw stuff
View.update
delay (if you want one)
end loop


: