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

Username:   Password: 
 RegisterRegister   
 Making a GUI work in a loop
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
conbunthedestroyer




PostPosted: Thu Jun 08, 2017 5:54 pm   Post subject: Making a GUI work in a loop

What is it you are trying to achieve?
So, I have a school project and I need to make a quiz. Unfortunately, I appear to have run into some issues regarding the GUI aspects of it. More specifically, I can't seem to find a method in which it will only post one question, put the buttons (or the answers) down, wait for the answers and then move onto the next question once a GUI (or once again, answer) has been selected


Describe what you have tried to solve this problem
So, I've tried to implement a loop that will allow the program to wait for a switch (or a boolean variable in this case) that is activated only when an answer is chosen. This sorta just freezes the program though, and won't let the user actually pick any of the answers (so I took it out). If any of you would be able to help me out with making it advance, taht'd be great. Thanks!


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



Turing:


import GUI

forward proc aCorrectAns
forward proc bCorrectAns
forward proc cCorrectAns
forward proc dCorrectAns
forward proc eCorrectAns
forward proc correct
forward proc incorrect
forward proc reset
forward proc safeQuiz


var playFont : int := Font.New ("High Tower Text:20")
var playFont1 : int := Font.New ("High Tower Text:30")
var playFont3 : int := Font.New ("Garamond:30")
var playWindow : int := Window.Open ("graphics: max;800, nobuttonbar")
var aBut, bBut, cBut, dBut, eBut : int
var score : int := 0
var scoreString : string

var penalty : int

body proc safeQuiz
    penalty := 25
    cls
    bCorrectAns
    GUI.SetColour (aBut, 18)
    GUI.SetColour (bBut, 18)
    GUI.SetColour (cBut, 18)
    GUI.SetColour (dBut, 18)
    scoreString := intstr (score)
    Font.Draw (scoreString, 10, 100, playFont, white)
    Font.Draw ("QUESTION 1", 50, maxy - 60, playFont, white)
    Font.Draw ("What does the SCP in SCP Foundation stand for?", 250, maxy - 60, playFont1, white)
    Font.Draw ("A) Snap, Crackle, Pop", 130, 590, playFont3, white)
    Font.Draw ("B) Secure, contain, protect", 720, 590, playFont3, white)
    Font.Draw ("C) Sick, creepy, people", 130, 390, playFont3, white)
    Font.Draw ("D) ", 720, 390, playFont3, white)
    Font.Draw ("Special containment", 780, 410, playFont3, white)
    Font.Draw ("procedures", 780, 370, playFont3, white)
   
   
    %As you can see, if you take away the percent sign, it sorta just skips ahead to it
    %I would rather that it didn't do that
   
    %aCorrectAns
end safeQuiz

body proc aCorrectAns
    aBut := GUI.CreateButtonFull (70, 530, 500, " ", correct, 150, "a", false)
    bBut := GUI.CreateButtonFull (670, 530, 500, " ", incorrect, 150, "b", false)
    cBut := GUI.CreateButtonFull (70, 330, 500, " ", incorrect, 150, "c", false)
    dBut := GUI.CreateButtonFull (670, 330, 500, " ", incorrect, 150, "d", false)
    eBut := GUI.CreateButtonFull (500, 200, 500, " ", incorrect, 150, "e", false)
    GUI.Hide (eBut)
    cls
    GUI.Refresh
end aCorrectAns

body proc bCorrectAns
    aBut := GUI.CreateButtonFull (70, 530, 500, " ", incorrect, 150, "a", false)
    bBut := GUI.CreateButtonFull (670, 530, 500, " ", correct, 150, "b", false)
    cBut := GUI.CreateButtonFull (70, 330, 500, " ", incorrect, 150, "c", false)
    dBut := GUI.CreateButtonFull (670, 330, 500, " ", incorrect, 150, "d", false)
    eBut := GUI.CreateButtonFull (375, 130, 500, " ", incorrect, 150, "e", false)
    GUI.Hide (eBut)
    cls
    GUI.Refresh
end bCorrectAns

body proc cCorrectAns
    aBut := GUI.CreateButtonFull (70, 530, 500, " ", incorrect, 150, "a", false)
    bBut := GUI.CreateButtonFull (670, 530, 500, " ", incorrect, 150, "b", false)
    cBut := GUI.CreateButtonFull (70, 330, 500, " ", correct, 150, "c", false)
    dBut := GUI.CreateButtonFull (670, 330, 500, " ", incorrect, 150, "d", false)
    eBut := GUI.CreateButtonFull (maxx - 200, 200, 500, " ", incorrect, 150, "e", false)
end cCorrectAns

body proc dCorrectAns
    aBut := GUI.CreateButtonFull (70, 530, 500, " ", incorrect, 150, "a", false)
    bBut := GUI.CreateButtonFull (670, 530, 500, " ", incorrect, 150, "b", false)
    cBut := GUI.CreateButtonFull (70, 330, 500, " ", incorrect, 150, "c", false)
    dBut := GUI.CreateButtonFull (670, 330, 500, " ", correct, 150, "d", false)
    eBut := GUI.CreateButtonFull (maxx - 200, 200, 500, " ", incorrect, 150, "e", false)
end dCorrectAns

body proc eCorrectAns
    aBut := GUI.CreateButtonFull (70, 530, 500, " ", incorrect, 150, "a", false)
    bBut := GUI.CreateButtonFull (670, 530, 500, " ", incorrect, 150, "b", false)
    cBut := GUI.CreateButtonFull (70, 330, 500, " ", incorrect, 150, "c", false)
    dBut := GUI.CreateButtonFull (670, 330, 500, " ", incorrect, 150, "d", false)
    eBut := GUI.CreateButtonFull (maxx - 200, 200, 500, " ", incorrect, 150, "e", false)
end eCorrectAns

body proc correct
    cls
    reset
    score := score + 100
end correct

body proc incorrect
    cls
    reset
    score := score - penalty
end incorrect

body proc reset
    GUI.Dispose (aBut)
    GUI.Dispose (bBut)
    GUI.Dispose (cBut)
    GUI.Dispose (dBut)
    GUI.Dispose (eBut)
end reset

safeQuiz

loop
    exit when GUI.ProcessEvent
end loop



Please specify what version of Turing you are using
It's the newest one (the one on the download page on here). I don't remember what it's called Razz
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: