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

Username:   Password: 
 RegisterRegister   
 back to main menu (GUI Problem)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Velocity




PostPosted: Wed Dec 07, 2011 11:04 pm   Post subject: back to main menu (GUI Problem)

What is it you are trying to achieve?
So once i click instructions after the person has read them i want to make it so that there can be a button inside it to return the user to the main menu.

What is the problem you are having?
Variable has not been declared. It doesnt allow me to put it there!!!!! <<< (in the instructions menu)

Describe what you have tried to solve this problem
I tried to make different procedures and put them in seperate places...
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:






Please specify what version of Turing you are using
4.1.1a


[size = 48]I want to know how to format it properly so that it works!!![/size]
[size = 32]Please help dont mind the messy-ness (I will re organize it after i finish my project!!![/size]
Sponsor
Sponsor
Sponsor
sponsor
Velocity




PostPosted: Wed Dec 07, 2011 11:05 pm   Post subject: RE:back to main menu (GUI Problem)

Turing:


%Sorry for that but here is the code.

%Ilan Portman
%Grade 11 Final Project
%Brick Breaker vs AI
%December 7th, 2011
import GUI
procedure TheGame
    setscreen ("graphics:1024;950, nobuttonbar")
    %---------------------------
    %Player Co-ords            %
    var x1, y1, x2, y2 : int   %
    x1 := 250                  %
    y1 := 25                   %
    x2 := 350                  %
    y2 := 50                   %
    %---------------------------

    %---------------------------
    %Ball Co-ords              %
    var ballx, bally : int     %
    ballx := 512               %
    bally := 200               %
    %---------------------------

    %----------------------------------------
    %Game Basics                            %
    var lives : int := 3                    %
    var score : int := 0                    %
    var timePlaying : int := Time.Elapsed   %
    %----------------------------------------

    var arrowKeys : array char of boolean

    loop
        Input.KeyDown (arrowKeys)

        if arrowKeys (KEY_RIGHT_ARROW) then
            x1 += 5
            x2 += 5
        end if
        if arrowKeys (KEY_LEFT_ARROW) then
            x2 -= 5
            x1 -= 5
        end if

        drawfillbox (x1, y1, x2, y2, red)
        delay (10)
        cls
        drawfillbox (250, 900, 350, 925, 101)
        drawfillbox (0, 457, 1050, 462, 51)
        drawfilloval (ballx, bally, 15, 15, 48)
        if arrowKeys (KEY_ESC) then
            cls
            exit
        end if
    end loop

    if x1 > 925 then
        x1 -= 50
    elsif x2 < 25 then
        x2 += 50
    end if
    View.UpdateArea (0, 0, maxx, maxy)
end TheGame

procedure Options

end Options

procedure Game
    TheGame
end Game

procedure Instructions
    colorback (16)
    color (48)
    cls
    drawfillbox (0, 0, maxx, maxy, 51)
    locate (4, 1)
    put "The objective of the game is..."
    locate (7, 1)
    color (58)
    put "to destroy all of the blocks on your side of the screen (bottom)"
    locate (10, 1)
    color (73)
    put "Before the computer destroys all of his blocks on his side of the screen (top)"
    locate (13, 1)
    color (81)
    put "You will use the 'Left' and 'Right' Arrow keys to move left and right"
    locate (16, 1)
    color (96)
    put "Good Luck and go smash some blocks!"
    var mainMenu : int := GUI.CreateButton (maxx, 0, 0, "Back To Main Menu", TheTitleScreen)
end Instructions

procedure TheTitleScreen

    var game_Button : int := GUI.CreateButton (300, 300, 0, "Click To Play!", Game)
    var optionMenu_Button : int := GUI.CreateButton (300, 200, 0, "Options Menu", Options)
    var instructions_Button : int := GUI.CreateButton (300, 100, 0, "Learn How To Play", Instructions)
end TheTitleScreen

TheTitleScreen

loop
    exit when GUI.ProcessEvent
end loop

Velocity




PostPosted: Thu Dec 08, 2011 1:15 am   Post subject: RE:back to main menu (GUI Problem)

karma to helper cause i was trying for 30 mins now and i cant find no answer to it... Ima hit the sheets cus i got school tomorrow but anyone help is greatly appreciated!!!!!
Tony




PostPosted: Thu Dec 08, 2011 2:23 am   Post subject: RE:back to main menu (GUI Problem)

think about what's on your function call stack. Start poping items off (via terminating function calls) until you are back to where you are.

Naturally, you'd find that the relavant part of the code is
code:

TheTitleScreen

loop
    exit when GUI.ProcessEvent
end loop

Your title menu had to exit for the GUI loop to start.

By the time the game starts, the main menu is off the stack. There is nothing to get back to.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Thu Dec 08, 2011 8:36 am   Post subject: RE:back to main menu (GUI Problem)

so there is no need for a GUI.ProcessEvent?
Velocity




PostPosted: Thu Dec 08, 2011 8:43 am   Post subject: RE:back to main menu (GUI Problem)

anyways thanks for trying, i gave you karma anyways.

EDIT: I mean thanks for helping me, although i am to stupid to realize what you meant, i guess my mind cant comprehend the knowledge that you put forth...
Tony




PostPosted: Thu Dec 08, 2011 2:10 pm   Post subject: RE:back to main menu (GUI Problem)

I was talking about http://en.wikipedia.org/wiki/Stack-based_memory_allocation

Once you exit your game's loop, where will the control flow end up?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Thu Dec 08, 2011 7:43 pm   Post subject: RE:back to main menu (GUI Problem)

Well i got it to work thanks alot guys Smile but i have a new problem! With my flickering.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: