Computer Science Canada

Problem with Window

Author:  KukuriChan [ Tue Mar 16, 2004 9:14 am ]
Post subject:  Problem with Window

I'm suppose to be doing a dice game during this break but there's something wrong with my program. See, I have a problem with my code. When you choose the play button, it loads the screen instantly but then it goes right to the procedure that tells you how to play and then goes to the next procedure. How do you make it so that the procedure is only active when you choose it? I tried putting it in the conditional loop but there was an error when I did that. Sad If anybody can help me I'll be really happy.


code:

loop
    if Mouse.ButtonMoved ("up") then
        Mouse.ButtonWait ("down", x, y, buttonnumber, buttonupdown)
        if x >= 220 and x <= 300 and y >= 100 and y <= 130 then
            delay (300)
            cls
            Pic.ScreenLoad ("chess-game-carpet600.jpg", 0, 0, picXor)
            exit
        elsif x < 220 and x > 300 and y < 100 and y > 130 then
            return     % goes back to the beginning if out of range of button
        end if
        if x >= 320 and x <= 400 and y >= 100 and y <= 130 then
            exit
        elsif x < 320 and x > 400 and y < 100 and y > 130 then
            return
        end if
        if x >= 420 and x <= 500 and y >= 100 and y <= 130 then
            delay (400)
            Window.Select (helpWindow)
        elsif x < 420 and x > 500 and y < 100 and y < 130 then
            return
        end if
    end if
end loop

drawfillbox (maxx, 0, 600, maxy, grey)
Font.Draw ("Menu", 550, 600, button, 0)
include "proc howtoplay.t"
include "N ame.t"

Author:  McKenzie [ Tue Mar 16, 2004 11:15 am ]
Post subject: 

Don't want to be harsh but this sounds more like a riddle than a question.
1. Please give a good topic name ("Trouble with dice game" - the Massey crowd knows what that means)
2. Zip ALL of the files you are using and attach them.
3. Include more comments in your code to indicate what you think is going on.

Author:  recneps [ Tue Mar 16, 2004 11:15 am ]
Post subject: 

First off, you might wanna check out my "Buttons for dummies", and get some purdy GUI Wink (its in tutorial Section) and all you gotta do, is assign the procedure to the button, so say you click "How to play" then itll load the procedure on how to play. and so on and so on for em all.

Edit: Heres my Buttons For Dummies http://www.compsci.ca/v2/viewtopic.php?t=3583

and damn, Mckenzies fast Wink

Author:  KukuriChan [ Tue Mar 16, 2004 11:22 am ]
Post subject: 

K. I attached the file.

Maybe making a GUI button is a good idea but isn't there another way to fix the problem?

Author:  Paul [ Tue Mar 16, 2004 11:26 am ]
Post subject: 

I don't see the file.
As for the GUI buttons, if you want to use them, go ahead. But I usually make my own buttons, cause my teacher says, turing is a learning language where you make everything from scratch, if you wanna do fancy GUI stuff, go learn VB.

Author:  recneps [ Tue Mar 16, 2004 11:28 am ]
Post subject: 

Umm im not seeing something attached :/
and Paul, hes already made his own buttons Wink but for the way hes got it done, GUI is alot easier

Author:  Paul [ Tue Mar 16, 2004 11:33 am ]
Post subject: 

K, I see it now...
there are advantages with GUI buttons, but with your own buttons you can make them look however you want Very Happy instead of the stupid grey stuff.

Author:  KukuriChan [ Tue Mar 16, 2004 11:35 am ]
Post subject: 

I attached it...twice accidentally. Oops.


I've used GUI buttons before but they weren't that good. I mean it's good for having separate procedures but other than that, I didn't know how to use it so that once you click on one button, you can activate another button too. GUI's have a lot of limits.

Author:  Paul [ Tue Mar 16, 2004 11:39 am ]
Post subject: 

Ok I dunno, I don't have much experience with it, but it only ran on my computer after I took out "import GUI" on N ame.t, b4 that it just said syntax error there. Maybe I shouldn't have done it, but I didn't even see a play button... it just went straight to the instructions.
Hehe I use to play this game when I was a kid,
"shuo ming" your saying instructions? like instruction book is "shuo ming shu"?

Author:  KukuriChan [ Tue Mar 16, 2004 11:46 am ]
Post subject: 

yeah, that's my problem. I don't want it to go straight to the instruction page. ^^;;;

Author:  Paul [ Tue Mar 16, 2004 11:50 am ]
Post subject: 

oh I see on the bottom of howtoplay.t you called howtoplay proc, so when you include it, maybe it calls it automatically? so if you take out "howtoplay" at the bottom of the file, it wont run automatically, so in my inexperience, I would itake out the calling of the procedure at the end of the howtoplay.t and then include the file first, then call it with a if/ gui whatever. I took it out, and it didn't go to help file automatically, though its still kinda messed. But at least the quit button and the chart at the bottom left works now...

[edit] I was messing around with it, and at the title screen, after I took out the calling of the help file procedure at the end of the help file, it just automatically goes to the n ame.t file, without letting you choose buttons, I moved the "include n ame.t" somewhere else, I dunno where you want it, and now all the buttons at the beginning works.

If you press play, it goes to the pic, if you press quit, it quits, and if you press help, it goes to help file.

Heres all the changes I made:
1. at the end of howtoplay.t, I took out "howtoplay"
2. moved the "include n ame.t" somewhere else (after the button clicking part)
I might be totally wrong at doing this, but eh, the buttons work for me now.

Author:  KukuriChan [ Tue Mar 16, 2004 12:06 pm ]
Post subject: 

can you attach the file for me Paul? Smile

Author:  McKenzie [ Tue Mar 16, 2004 12:08 pm ]
Post subject: 

Paul is right. The call at the bottom of how to play was a problem, and you need to look at the overall organization before you continue. You have a mish-mash of code that is going to become harder and harder to modify.
Because you are trying to mix GUI with non-GUI you will run into a few problems e.g. The GUI proceseEvent loop at the bottom of your name code takes control of the program until you click quit, then you have a chance to click play.

Author:  Paul [ Tue Mar 16, 2004 12:13 pm ]
Post subject: 

Well since I dunno what your thoughts are, I dunno how to modify it. And I have no experience with GUI. If you want it...
this is at the bottom of the howtoplay.t
before:
code:

end for

end howtoplay
howtoplay

after
code:

end for

end howtoplay

sorry Sad
yes on the flight.t , part of the reason that it won't work was
code:

include "proc howtoplay.t"
include "N ame.t"%<--I dunno, this was interfering somehow.

after:
code:

include "proc howtoplay.t"
%include "N ame.t"%%<---moved to whereever you want, I dunno where.

Author:  KukuriChan [ Tue Mar 16, 2004 12:14 pm ]
Post subject: 

So, if I took out the GUI button and switch the code around, it should solve my problems?

Author:  KukuriChan [ Tue Mar 16, 2004 12:25 pm ]
Post subject: 

How come when you click the quit button, it won't close the window? Is there something wrong with the code?

Author:  Paul [ Tue Mar 16, 2004 12:31 pm ]
Post subject: 

you only closed one window when you opend 2
Window.Close (winID)
Window.Close (helpWindow)

Author:  KukuriChan [ Tue Mar 16, 2004 1:23 pm ]
Post subject: 

Oh. Thanks a lot Paul. I forgot I had two windows. :p

Author:  the_short1 [ Tue Mar 16, 2004 2:18 pm ]
Post subject: 

i dont know why your making this a multi part program... like include such and such... why not have it all in one??? that would take care of some of your problems im sure... the only benifits i see doing that is too keep it organized if you have a huge program with many levels.....

if someone could shed light on that...


EDIT: before closing the window... may i suggest adding a cool clear screen method to clear the screen???

some examples here:
http://www.compsci.ca/v2/viewtopic.php?t=2917&postdays=0&postorder=asc&start=0
(look thru all 3 pages for more.)
they realy add the touch b4 the window closes..

Author:  KukuriChan [ Tue Mar 16, 2004 5:26 pm ]
Post subject: 

I am going to have it all in one. I'm just doing it in parts so that's it's easier for myself.

I checked out the posts and.... those are really cool ideas on how to clear screen. ^^ Maybe I can make one of my own.

Author:  the_short1 [ Tue Mar 16, 2004 7:39 pm ]
Post subject: 

you can use one of them from there... if you want... just list that person's name in apropriate credits...and thx...and.... i see.... yea maybe i shoulda though to do that with my huge pac man game... but i didn't... its all in one... 3000 lines of code

Author:  recneps [ Tue Mar 16, 2004 9:03 pm ]
Post subject: 

Number of lines isnt what counts, its how good the program is and how efficient it runs Wink

Author:  KukuriChan [ Wed Mar 17, 2004 9:27 am ]
Post subject: 

are you serious I can do that??? just use one of them and then list the other person's name in the credits? Shocked I never knew I could do that. ^^;; I thought that people would sue me if I do that..... well... maybe not sue me... but you get the idea right?

Author:  recneps [ Wed Mar 17, 2004 10:58 am ]
Post subject: 

Also, the source code section says: "Free source code and other....."
In other words, its free to use, just mention the person's name somewhere Wink

Author:  KukuriChan [ Wed Mar 17, 2004 11:04 am ]
Post subject: 

Ok. ^^ Whoever I use gets to be in my credits page then. Plus, thanks in advance. Very Happy


: