Computer Science Canada

Loops and Drawing for a menu, using keys and jpegs,need help

Author:  Leftover [ Sat Jan 15, 2005 5:50 pm ]
Post subject:  Loops and Drawing for a menu, using keys and jpegs,need help

I'm at a bit of a stand still again.

I'm making steady progress on my game but once again I have come into a bump, this time at the menu.

I basically have a fading text intro, that then moves to a screen with logo and 2 buttons (Continue and New Game). I have it all going with a selector arrow moving up and down with the arrow keys to select 1 or the other, using lots of drawing, but here is where I am stuck.

Currently it is set up so if down key is pressed, it goes down to new game, and if up key is pressed (or by default) it is on continue. When enter is pressed at any time, it kills the music, which is what I want it to do as well.

code:

loop
    if hasch then
        enter := getchar
        if enter = chr (208) then
            Draw.Cls
            GUI.SetBackgroundColor (255)
            Pic.Draw (hand_dwn, 135, 155, picCopy)
            Pic.Draw (logo, 135, 325, picCopy)
            Pic.Draw (new_bl, 170, 155, picCopy)
            Pic.Draw (continue_bl, 170, 235, picCopy)
            Draw.FillBox (125, 30, 365, 58, 33)
            Font.Draw ("C 2005 SPORK", 126, 46, font2, 0)
            Font.Draw ("C 2005 NINTENDO", 126, 31, font2, 0)
            View.Update
        end if
        if enter = chr (200) then
            Draw.Cls
            GUI.SetBackgroundColor (255)
            Pic.Draw (hand_up, 135, 235, picCopy)
            Pic.Draw (logo, 135, 325, picCopy)
            Pic.Draw (new_bl, 170, 155, picCopy)
            Pic.Draw (continue_bl, 170, 235, picCopy)
            Draw.FillBox (125, 30, 365, 58, 33)
            Font.Draw ("C 2005 SPORK", 126, 46, font2, 0)
            Font.Draw ("C 2005 NINTENDO", 126, 31, font2, 0)
            View.Update
        end if
        if enter = chr (10) then
            Music.PlayFileStop
        end if
    end if
end loop


The first problem with that, not too serious, but it flickers the screen when it goes up or down"¦ Is there any way to clean up that flicker to make it look cleaner?

On to the main problem:

I can't figure out how I can make it so when it is on Continue and enter is pressed, it goes to the load menu, or if it is on New Game and enter is pressed, it goes to the New Game menu. I've tried so many things and they just don't work or mess up the program more and don't work. I am just so baffled right now and I'm sure it's so simple Razz.

The basic pseudocode I want is:

Chr(ascii), 10 is enter, 208 is down, 200 is up,

code:

If key = chr(208) then move pointer to new game
If key = chr(10) once pointer is on new game, then go to new game menu
If key = chr(200) then move pointer to continue, or leave it where it is (default on continue)
If key = chr(10) once pointer is on continue, then go to continue menu


I only had a few minutes to get on the net while working on this and couldn't find anything. I also spent about 2 hours trying different things that worked in my head but not in turing Sad.

If anyone can offer any help on either of the 2 problems I am having it will be put to good use Smile. Thanks in advanced, L.O.

Author:  Delos [ Sat Jan 15, 2005 8:00 pm ]
Post subject: 

Here's the thing w/ OOT. For optimal usage, work w/ classes and/or modules. Either or, you'll be using lots of procedures. With most other higher level langs, you can call a procedure before it's been declared. Not so in OOT.
Thus, I can see 3ish procedures you'll need for the basic framework here.
- game procedure: this contains the actual game, and reads specific data regarding the player etc, that is already stored
- new game procedure: creates player data, then calls the game proc to continue
- menu procedure: if the 'New Game' option is selected, calls the new game proc, otherwise loads saved data and calls the game proc.

Basically, in terms of chronology, think backwards.

Author:  Leftover [ Sat Jan 15, 2005 8:21 pm ]
Post subject: 

That makes sence and it's still early enough to change my program to that, but I still can't make my menu pick one of those procedures by pressing enter Smile

Is it just not possible to do it the way I want to? If so it seems pretty odd that code from 87 cand do it but not code from 2005 Very Happy

Author:  Leftover [ Sat Jan 15, 2005 10:04 pm ]
Post subject: 

Nevermind, I re read that about 50 times and I tried some stuff and got it.

code:

loop
    if hasch then
        enter := getchar
        if enter = chr (208) then
            ContNew := false
            GUI.SetBackgroundColor (255)
            Pic.Draw (hand_dwn, 135, 155, picCopy)
            Pic.Draw (logo, 135, 325, picCopy)
            Pic.Draw (new_bl, 170, 155, picCopy)
            Pic.Draw (continue_bl, 170, 235, picCopy)
            Draw.FillBox (125, 30, 365, 58, 33)
            Font.Draw ("C 2005 SPORK", 126, 46, font2, 0)
            Font.Draw ("C 2005 NINTENDO", 126, 31, font2, 0)
            View.Update
        end if
        if enter = chr (200) then
            ContNew := true
            GUI.SetBackgroundColor (255)
            Pic.Draw (hand_up, 135, 235, picCopy)
            Pic.Draw (logo, 135, 325, picCopy)
            Pic.Draw (new_bl, 170, 155, picCopy)
            Pic.Draw (continue_bl, 170, 235, picCopy)
            Draw.FillBox (125, 30, 365, 58, 33)
            Font.Draw ("C 2005 SPORK", 126, 46, font2, 0)
            Font.Draw ("C 2005 NINTENDO", 126, 31, font2, 0)
            View.Update
        end if
        if enter = chr (10) then
            if ContNew = true then
                continue   % This would be the procedure called when person wants to continue
            elsif ContNew = false then
                newgame  % This would be the procedure called when a person chooses to start a new game
            end if
        end if


Thanks again Delos, and it's nice to know that it's a bit easier in higher level programming, as it may be my choice for college if I can not get a place in Toronto. I just wish I had more time to read up on other langs Razz

Author:  Delos [ Sun Jan 16, 2005 9:57 am ]
Post subject: 

Hmm...if you want to know anything about higher level programming, speak to wtd...my experience in programming wanders sweet short paths away from OOT...so sad I know.

I would still suggest that you alter your proggie and use procedures instead. You will like them lots.


: