Computer Science Canada

Need help with making buttons work and waiting for them to be clicked before continuing

Author:  GalacticVenus [ 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.

Author:  Tony [ 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.

Author:  GalacticVenus [ 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


: