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

Username:   Password: 
 RegisterRegister   
 Why won't it exit?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
baz.




PostPosted: Sun Jan 20, 2008 7:30 pm   Post subject: Why won't it exit?

Okay, I have to make a game for an assignment, yet for some reason, when I click the exit button it won't exit. Instead, it goes to the result screen.
Can some one tell me how that is possible? It will clear screen alright. But why on earth would it go to the results screen when it clearly says "exit"?
here's the code for the selection statements.
var x1instruction, x2instruction, y1instruction, y2instruction : real
var x1lesson, x2lesson, y1lesson, y2lesson : real
var x1quiz, x2quiz, y1quiz, y2quiz : real
var x1exit, x2exit, y1exit, y2exit : real
var button : int
var x, y : int


x1instruction := 240 - 40
x2instruction := 240 + 40
x1lesson := 340 - 40
x2lesson := 340 + 40
x1quiz := 440 - 40
x2quiz := 440 + 40
x1exit := 550 - 40
x2exit := 550 + 40

var btnNum, btnUpDown : int
loop
mousewhere (x, y, button)
if x1instruction <= x and x <= x2instruction and button = 1 then
y1instruction := -sqrt (40 ** 2 - (x - 240) ** 2) + 40
y2instruction := sqrt (40 ** 2 - (x - 240) ** 2) + 40

if y1instruction <= y and y <= y2instruction then
instruction_screen
end if
end if

if x1lesson <= x and x <= x2lesson and button = 1 then
y1lesson := -sqrt (40 ** 2 - (x - 340) ** 2) + 40
y2lesson := sqrt (40 ** 2 - (x - 340) ** 2) + 40

if y1lesson <= y and y <= y2lesson then
lesson_screen1
end if
end if

if x1quiz <= x and x <= x2quiz and button = 1 then
y1quiz := -sqrt (40 ** 2 - (x - 440) ** 2) + 40
y2quiz := sqrt (40 ** 2 - (x - 440) ** 2) + 40

if y1quiz <= y and y <= y2quiz then
var screens : int
randomize
randint (screens, 1, 2)

if screens = 1 then
quiz_screen1version1
elsif screens = 2 then
quiz_screen1version2
end if
end if
end if

if x1exit <= x and x <= x2exit and button = 1 then
y1exit := -sqrt (40 ** 2 - (x - 550) ** 2) + 40
y2exit := sqrt (40 ** 2 - (x - 550) ** 2) + 40

if (y1exit <= y and y <= y2exit) then
exit
end if
end if



if x1lesson <= x and x <= x2lesson and button = 1 then
y1lesson := -sqrt (40 ** 2 - (x - 340) ** 2) + 40
y2lesson := sqrt (40 ** 2 - (x - 340) ** 2) + 40

if y1lesson <= y and y <= y2lesson then
lesson_screen1
end if
end if

end loop
*btw, as you can see, I'm using circle buttons.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Jan 20, 2008 8:19 pm   Post subject: RE:Why won\'t it exit?

just because you call a variable something, doesn't mean that you have the right code behind it.

exit exits a loop. Step through your code to see where your program ends up after that.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: