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

Username:   Password: 
 RegisterRegister   
 Order of Procedures?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Badsniper




PostPosted: Wed May 11, 2011 9:43 pm   Post subject: Order of Procedures?

What is it you are trying to achieve?


I am trying to get my game to loop back to my menu if a certain character is pressed


What is the problem you are having?


The procedures will not allow this to happen because one is declared before another


Describe what you have tried to solve this problem


I've switched around my procedures a few times, but it didn't help.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


import GUI

var credits : int := Pic.FileNew ("CREDITS.bmp")
var screen : int
var goback : boolean
screen := Window.Open ("graphics:700;700;nobuttonbar;title:ODIWUAAC_BETA_VERSION_1.0;offscreenonly;nocursor")

var creditscroll := -1 * Pic.Height (credits) + maxy

include "Movement.t"

proc CREDITS
    cls
    Pic.Draw (credits, 0, creditscroll, 0)
    View.UpdateArea (0, 0, maxx, maxy)
    loop
        cls
        Pic.Draw (credits, 0, creditscroll, 0)
        creditscroll += 1
        View.UpdateArea (0, 0, maxx, maxy)
        delay (1)
        exit when creditscroll >= 0
    end loop
end CREDITS

proc GAME_COMPONENT
    cls
    for b : 1 .. 3
        movement
        if done = false then
            level += 1
        else
            MENU
        end if
    end for
end GAME_COMPONENT

var button1 : int := GUI.CreateButtonFull (maxx div 2 - 100, maxy div 2 + 100, 200, "Start Game", GAME_COMPONENT, 50, "^Z", false)
var button2 : int := GUI.CreateButtonFull (maxx div 2 - 100, maxy div 2 - 100, 200, "Credits", CREDITS, 50, "^X", false)

proc MENU
    GUI.Enable (button1)
    GUI.Enable (button2)
    View.Update
    loop
        exit when GUI.ProcessEvent
    end loop
end MENU


MENU



Please specify what version of Turing you are using


4.1.1 I believe... (?)
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed May 11, 2011 10:00 pm   Post subject: RE:Order of Procedures?

The issue here is that even if you *could* do it this way (well, you can, but I won't tell you how), your program will constantly use up more ram.

The program starts inside MENU. Now, let's say you click 'start game'. You now have an instance of GAME_COMPONENT running inside MENU. If you then finish the game and return to the menu, you'll have a menu running inside the game procedure, running inside another menu procedure.

Instead of calling menu from GAME_COMPONENT, return to the menu by ending the GAME_COMPONENT procedure.
tyuo9980




PostPosted: Thu May 12, 2011 8:57 pm   Post subject: Re: Order of Procedures?

what i do is run the menu as the main program, not a procedure. so then after ur game ends or whatever just exit the loop in ur procedure and itll return back to the menu.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: