Mouse clicks
Author |
Message |
Tupacalypse_Vinsanity
|
Posted: Sat Jan 28, 2006 3:02 pm Post subject: Mouse clicks |
|
|
Well i got the records working in my turing, thanks to everyone for any help.
I have a problem though, in my game at the beginning there are buttons that you have to click to either login or register:
code: | procedure Beginning
fork MusicPrelude %Plays the prelude music
Pic.Draw (pic, 0, 0, picCopy)
View.Set ("nocursor")
getch (key)
cls
Pic.Draw (pic2, 0, 0, picCopy)
loop
View.Set ("nooffscreenonly")
Mouse.Where (x, y, button)
buttonwait ("down", x, y, bnum, bud)
if x <= 280 and x >= 120 and y <= 180 and y >= 80 then
View.Update
button := button + 1
LogIn
elsif x <= 660 and x >= 501 and y <= 180 and y >= 80 then
View.Update
button := button + 1
Register
end if
exit when button = 1
View.Update
View.Set ("offscreenonly")
end loop
end Beginning |
That works fine, but after you logged in, you have the option to play the game or to exit the game, and the buttons are in the same location, but when i click to exit, itll run the exit procedure, but THEN run the login procedure and says the variable has no value....
code: | procedure LoggedIn
cls
Pic.Draw (pic4, 0, 0, picCopy)
View.Update
loop
View.Set ("offscreenonly")
Mouse.Where (x, y, button1)
buttonwait ("down", x, y, bnum1, bud1)
if x <= 280 and x >= 120 and y <= 180 and y >= 80 then
View.Update
button1 := button1 + 1
Play
elsif x <= 660 and x >= 501 and y <= 180 and y >= 80 then
View.Update
button1 := button1 + 1
ExitGame
end if
exit when button1 = 1
View.Update
end loop
end LoggedIn |
Anyone know how to fix this? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tupacalypse_Vinsanity
|
Posted: Sat Jan 28, 2006 3:06 pm Post subject: Oh sorry for bumping |
|
|
I dont see an edit button anywhere... I just noticed that the locations to press for login isnt even in the same place as where the exit button is. |
|
|
|
|
|
Delos
|
Posted: Sat Jan 28, 2006 3:36 pm Post subject: (No subject) |
|
|
I'm not too sure about this, but I have a feeling that this is a nesting problem. If you look at your first 'Beginning' procedure, you'll notice that a particular button click calls 'LogIn', but that that call occurs within a loop.
The programme then runs through the nested LogIn, and upon its termination, it returns to the last place it was, which was in Beginning.
You may want to try put some well placed 'exits' to get you out of those pesky loops you've gotten yourself into.
I'm a little hesitant as I don't completely understand what you mean by "same location" (is that as in same x-,y- coords; or same area of code?). Also, you have calls to 'LogIn', and I see a 'LoggedIn' proc - so I'm hoping these are two seperate procedures.
Additionally, which variable produces the error? |
|
|
|
|
|
Tupacalypse_Vinsanity
|
Posted: Sat Jan 28, 2006 5:43 pm Post subject: ~ |
|
|
Yeah the location as in the x,y coordinates.
LogIn is a totally different procedure than LoggedIn, you have to go through LogIn to get to LoggedIn
The variable that produces the error is in the login procedure when it goes to check the records username + pass with the username/pass you put in, im guessing it says no variable since when you click it runs it even though you didnt enter a username or pass for it to check, thats all i can think of |
|
|
|
|
|
Tupacalypse_Vinsanity
|
Posted: Sun Jan 29, 2006 2:16 pm Post subject: (No subject) |
|
|
Oh and the exit whens, i have them in there as you can see, when the area is clicked it says button gets 1 and the loop says exit when 1. |
|
|
|
|
|
Clayton
|
Posted: Sun Jan 29, 2006 7:11 pm Post subject: (No subject) |
|
|
y dont u just make actual buttons *shiver* this may be an nicer way to get your code straightened out so that you wont have these problems, i cant really think of wats going on other than the nesting problem mentioned above |
|
|
|
|
|
Delos
|
Posted: Sun Jan 29, 2006 11:33 pm Post subject: (No subject) |
|
|
Attach your source so we can look through the whole thing. Will make debugging a little easier.
(Please ensure that it runs upon pressing F1). |
|
|
|
|
|
Tupacalypse_Vinsanity
|
Posted: Mon Jan 30, 2006 7:10 am Post subject: Uhm |
|
|
Here, it includes all pictures, sounds, etc..
Also im having a problem, whenever you beat the game or you choose to exit, it also does the variable has no value thing, yet they are both the same code as the gameover procedure and its the only one that will close the window. Im thinking they are linked to this problem also. If you can fix anything, thatd be great, you will see what i have a problem with.
http://s53.yousendit.com/d.aspx?id=0ZOAU15LGYXN407QIFEX66SZ0R |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|