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

Username:   Password: 
 RegisterRegister   
 Need help with making buttons work and waiting for them to be clicked before continuing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GalacticVenus




PostPosted: Sun Dec 06, 2009 3:43 pm   Post subject: Need help with making buttons work and waiting for them to be clicked before continuing

What is it you are trying to achieve?
Waiting for user input before the vampire attacks/making the buttons clickable


What is the problem you are having?
Either the vampire attacks while the user is still making decisions or the buttons become completely unclickable


Describe what you have tried to solve this problem
Mucking around with the code


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Look at the attachment for more details.

Turing:

var action : boolean

procedure Attacking
    EnemyHP := EnemyHP - HeroAttack %...the enemy takes damage equal to your attack
    /*Draw.Text (HeroAttack, 213, 408, text, red) Need as a string, somehow*/
    put Hero, " attacked the Vampire for ", HeroAttack, " damage."
    action := true
end Attacking

loop
    action := false

    loop
        Attack := GUI.CreateButton (120, 250, 0, "Attack", Attacking)
        Defend := GUI.CreateButton (270, 250, 0, "Defend", Defence)
        CastCure := GUI.CreateButton (420, 250, 0, "Cure (80)", Cure)
        CastFire := GUI.CreateButton (570, 250, 0, "Fire (40)", Fire)
        exit when action = true
    end loop

    %Artificial intelligence

end loop


Please specify what version of Turing you are using
4.1.1



As it is now, the vampire waits for me to do something, but the buttons are unclickable.
It used to be that I could click the buttons, but without any sort of delay, the vampire would go before I could click anything.



Turing Battle.zip
 Description:
The program (so far) and (temporary) pictures

Download
 Filename:  Turing Battle.zip
 Filesize:  9.62 MB
 Downloaded:  512 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Dec 06, 2009 3:54 pm   Post subject: RE:Need help with making buttons work and waiting for them to be clicked before continuing

buttons are "clickable" only while GUI.ProcessEvents is being evaluated.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
GalacticVenus




PostPosted: Sun Dec 06, 2009 4:01 pm   Post subject: RE:Need help with making buttons work and waiting for them to be clicked before continuing

Thank you. It works perfectly now. Smile
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  [ 3 Posts ]
Jump to:   


Style:  
Search: