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

Username:   Password: 
 RegisterRegister   
 mouse
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tridi




PostPosted: Wed Jan 03, 2007 1:05 am   Post subject: mouse

Why won't the text show up when I hover over the red circle?



code:
%Set screen up
import GUI
setscreen ("nocursor")
setscreen ("noecho")


%Declaration Section
%Global Variables
var quitBtn, menuBtn, playBtn, continueBtn, testBtn : int := 0
var pictureID : int
var rangex, rangey, button : int
var winID1 := Window.Open ("postion:200;200,graphics:640;400")
var location : string
var mistakes : int := 0
%var teachWin := Window.Open ("graphics:640;400")


%Procedures
proc title
    cls
    locate (1, 32)
    put "Testing"
end title

proc goodBye
    title
    locate (3, 1)
    put "Thanks for playing!"
    locate (24, 1)
    put "Brought to you by -------"
    delay (2000)
    Window.Close (winID1)
end goodBye

proc teachSection
    title
        GUI.Show (menuBtn)
    locatexy (155, 35)
    drawfilloval (170, 155, 25, 25, 12)
    mousewhere (rangex, rangey, button)
    locate (3, 1)
    put "Hover on the red circle."
    if button = 1 then
        if rangex >= 145 and rangex <= 195 and rangey >= 130 and rangey <= 180 then
            colourback (0)
            locate (20, 50)
            put "Circle"
        else
            colourback (0)
            locatexy (155, 35)
            put "That is not one of the locations!"
        end if
    end if
    View.Update
end teachSection

proc introduction
    title
    locate (3, 1)
    put "(put intro here)"
    GUI.Show (menuBtn)
    loop
        exit when GUI.ProcessEvent
    end loop
end introduction


proc mainMenu
    title
    GUI.Show (playBtn)
    GUI.Show (quitBtn)
    loop
        exit when GUI.ProcessEvent
    end loop
end mainMenu

playBtn := GUI.CreateButtonFull (222, 250, 200, "Play", teachSection, 25, '^F', false)
quitBtn := GUI.CreateButtonFull (222, 190, 200, "Quit", GUI.Quit, 25, KEY_ESC, false)
menuBtn := GUI.CreateButton (545, 0, 0, "Main Menu", mainMenu)


%Main Program
introduction
loop
    exit when GUI.ProcessEvent
end loop
goodBye
Sponsor
Sponsor
Sponsor
sponsor
Prince Pwn




PostPosted: Wed Jan 03, 2007 2:28 am   Post subject: (No subject)

You need your mousewhere(x,y,button) inside a loop. Change your teachSection to:

code:

proc teachSection
    title
    GUI.Show (menuBtn)
    locatexy (155, 35)
    drawfilloval (170, 155, 25, 25, 12)
    loop
        mousewhere (rangex, rangey, button)
        locate (3, 1)
        put "Hover on the red circle."
        if whatdotcolour (rangex, rangey) = brightred/*and button = 1*/ then
            colourback (0)
            locatexy (155, 35)
            put "Circle"
        else
            colourback (0)
            locatexy (155, 35)
            put "That is not one of the locations!"
        end if
    end loop
    View.Update
end teachSection
Clayton




PostPosted: Wed Jan 03, 2007 10:32 am   Post subject: (No subject)

Also, you should be using either View.WhatDotColor() (like Prince Pwn did above) or Math.Distance() to figure out whether the mouse is over your circle or not. Check out the Turing Walkthrough for the Collision Detection tutorial. It should have everything you need there.
tridi




PostPosted: Wed Jan 03, 2007 10:48 am   Post subject: (No subject)

Thank you so much for your help! Very Happy Very Happy Very Happy
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  [ 4 Posts ]
Jump to:   


Style:  
Search: