Problems with IF statement and Buttons. Need GUI Help
Author |
Message |
PhoxFroot
|
Posted: Sun Apr 03, 2016 2:15 pm Post subject: Problems with IF statement and Buttons. Need GUI Help |
|
|
Hi, so I'm a noob to turing and I literally have no idea what I'm doing. I know the basics and all, but the real question I have is that I'm trying to make a button that if clicked on, would make a series of text pop up. I don't know if ever played a game called Lifeline, but it's a game where there's a 2 option and depending on which option you choose, the story changes. So sorta similar to that, I want to create a button allowing that. So here's my problem (sorry for that large ass text), how would I do it? See, idk whether I should use a if statement or not, and even if I do, what would I write afterwards. To clear things up, if I did make a if statement, would I need to refer back to the button being clicked and then make a put command saying "this-this-and-this" or what would I do? My codes at the bottom. Feel free to change it if you must. Thanks for your time and help.
import GUI
procedure Yes
put "Thank God"
end Yes
procedure No
put "oh, ha ha"
end No
var button1 : int := GUI.CreateButton(100, 300, 0, "Yes", Yes)
var button2 : int := GUI.CreateButton(300, 300, 0, "No", No)
loop
exit when GUI.ProcessEvent
end loop |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dreadnought
|
Posted: Sun Apr 03, 2016 10:40 pm Post subject: Re: Problems with IF statement and Buttons. Need GUI Help |
|
|
Remember that you can declare some variables before you declare your procedures (you don't need to give the variables values immediately). This can allow you to have your yes and no procedures alter your buttons.
Start small, how can you get from what you currently have to a game with 4 outcomes (i.e. where the first 2 buttons lead to two more options)? Can you think of a way of doing this? Hopefully, this gives you some inspiration.
You might also find some inspiration in finite state machines. The idea is basically that your program or system is always in exactly one "state". The current "state" can transition into a new state when an event occurs. Look them up if you want to know more. |
|
|
|
|
|
|
|