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

Username:   Password: 
 RegisterRegister   
 Clickable buttons
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sammi




PostPosted: Sun Oct 16, 2011 5:21 pm   Post subject: RE:Clickable buttons

oh im sorry! i didnt even know i could do that!!!!!
Sponsor
Sponsor
Sponsor
sponsor
sammi




PostPosted: Sun Oct 16, 2011 7:38 pm   Post subject: RE:Clickable buttons

me and my dad have tried everything and we still cant get the darn buttons to go away after i click 'no'. we think it has something to do with putting cls in somewhere but thats not working and we couldn't anything in the walkthrough can someone please help.


Turing:

import GUI
View.Set ("graphics, offscreen only")

procedure ExitButton
    cls ()
    put "Aww you can't tell me your done already....."
    delay (2000)
    put "ok fine......bye bye"
end ExitButton

%% DECLARING MY VARIABLES %%
var Question : string %the typing cursor
var Answer : int  % part of the array
var valid : boolean %number check
var words : array 1 .. 11 of string %the answers
%var Mouse.Where(350, 50, YesButton)

%% PARTS OF THE ARRAY %%
words (1) := "Yes"
words (2) := "No"
words (3) := "Maybe"
words (4) := "Thats for me to know and you to find out :)"
words (5) := "Of course"
words (6) := "I doubt it"
words (7) := "In your dreams"
words (8) := "Keep dreaming"
words (9) := "How the heck am I suppossed to know?"
words (10) := "Obviously"
words (11) := "Absolutely"

%%% MAGIC BALL PROGRAM %%%
procedure MagicBall
    cls () %refresh screen
    loop

        valid := true % sets questions to valid until it hits check

        % Asking the question
        locatexy (200, 390)
        put "Ask the Magic 8-Ball a question"

        % drawing the ball
        Draw.FillOval (330, 250, 100, 100, brightred)

        % Getting a response
        locatexy (250, 250)
        get Question : *

        % Make sure the question contains no numbers
        for i : 1 .. length (Question) % Represents the Character of the string
            for b : 1 .. 9 % checks to see if the character, i, has a number.
                if Question (i) = intstr (b) then % If it does, it sets valid to false.
                    valid := false % if it finds a number then it recognizes an improper question
                    cls ()
                    exit
                end if
            end for
        end for

        locatexy (200, 100) % position of answer and "invalid" comment

        if valid then
            Answer := Rand.Int (1, 11) % pick any one of my answers
            put words (Answer)
            delay (2000) % lets person read answer
            cls () %gets rid of the answer
            locatexy (200, 100)
            put "Would you like to ask another question?"
           
            loop
                var YesButton : int := GUI.CreateButton (250, 50, 0, "Yes", MagicBall)
                var NoButton : int := GUI.CreateButton (350, 50, 0, "No", ExitButton)
                exit when GUI.ProcessEvent
            end loop

        else
            locatexy (200, 220)
            put "Thats not a question silly!!!"
            delay (1500)
            cls ()
        end if

    end loop
end MagicBall
MagicBall
Aange10




PostPosted: Sun Oct 16, 2011 7:51 pm   Post subject: Re: RE:Clickable buttons

sammi @ 16/10/2011, 6:38 pm wrote:
me and my dad have tried everything and we still cant get the darn buttons to go away after i click 'no'. we think it has something to do with putting cls in somewhere but thats not working and we couldn't anything in the walkthrough can someone please help.



Try this

Turing:

%Declare this variable at the top
var exit_counter : int := 0
procedure ExitButton
loop
    cls ()
    put "Aww you can't tell me your done already....."
    if exit_counter = 0 then
        delay (2000)
    end if
    put "ok fine......bye bye"
    delay (1000) % Prevents flickering
    exit_counter := 1
end loop
end ExitButton


That should fix your problem. It indefinitely loops the drawling, so that it doesn't continue on to redrawing the buttons. It only delays the first time it execute, aswell. (That away you can't tell it's looping)

also the quit command will stop the program, if you want to use that.
... Also, your global variables need to be defined BEFORE your procedures. (So move the extibutton procedure down, right above your magiball procedure)

EDIT: Also, using

Turing:

        Draw.FillOval (330, 250, 100, 100, black)
        Draw.FillOval (330, 250, 60, 60, white)
        Draw.FillOval (330, 275, 30, 30, brightred)
        Draw.FillOval (330, 220, 30, 30, brightred)
        Draw.FillOval (330, 275, 15, 15, white)
        Draw.FillOval (330, 220, 15, 15, white)


To draw your 8 ball would look much better 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 2 of 2  [ 18 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: