Computer Science Canada

Magic Eight-ball~ Help!

Author:  konrbear [ Thu Mar 20, 2014 2:35 pm ]
Post subject:  Magic Eight-ball~ Help!

What is it you are trying to achieve?
I want this magic eight ball to ask for the get on the first line, and random the choices


What is the problem you are having?
I've seemed to of broken the random choices and the get line each new loop goes to the next line.


Describe what you have tried to solve this problem
I've tried cls, different delays, and a few others


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

Turing:



%Variables
var answer : int
var question : string
var font1, font2: int
var test : int
font1 := Font.New ("serif:24: Underline")
font2 := Font.New ("serif:34: Bold")
assert font1 > 0
randomize
randint( answer, 1, 8)
loop

%Output & input
Draw.FillBox(0,0,maxx,maxy,red)
Font.Draw ("Ask the magic eight ball a question.", 100, 325, font1, white)

colorback (red)
color (white)
get question:*

%if statements
if question = "Is Connor cool?" then
    Font.Draw ("Yes!", 275, 250, font2, white)
   
elsif question = "Is kyle bad?" then
    Font.Draw ("Yes!", 275, 250, font2, white)
   
elsif answer = 1 then
    Font.Draw ("Lol!", 250, 250, font2, white)
   
elsif answer = 2 then
    Font.Draw ("Maybe", 250, 250, font2, white)
   
elsif answer = 3 then
    Font.Draw ("Please try again later", 125, 250, font2, white)
   
elsif answer = 4 then
    Font.Draw ("", 300, 250, font2, white)
   
elsif answer = 5 then
    Font.Draw ("Kyle!", 300, 250, font2, white)
   
elsif answer = 6 then
    Font.Draw ("is", 300, 250, font2, white)
   
elsif answer = 7 then
    Font.Draw ("bad", 300, 250, font2, white)
   
elsif answer = 8 then
    Font.Draw ("Connor", 225, 250, font2, white)

end if
delay(1000)
end loop


Author:  Insectoid [ Thu Mar 20, 2014 4:27 pm ]
Post subject:  RE:Magic Eight-ball~ Help!

Unless you're using an ancient version of Turing, you don't need to use randomize. It's not breaking your program, it's just not doing anything.

To solve your actual problem, you might want to look at where your randint() line is. Maybe that's not the best spot for it.


: