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

Username:   Password: 
 RegisterRegister   
 My procedures are not working.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
G-lant




PostPosted: Mon May 31, 2004 1:08 pm   Post subject: My procedures are not working.

EHHH people My procedures are not working, Im not sure why, my buddy here is having the same problem, well here is my program so far.... if some one can help PLEASE, please help.

code:
%My Game Menu
import GUI
Pic.ScreenLoad ("C:/game/Map1.jpg", 0, 0, picCopy)
View.Set ("graphics: 975, 800")
View.Set ("nocursor")
var font, font2, font3 : int
var first, second : int                 % The menus.
var item : array 1 .. 6 of int         % The menu items.
var name : array 1 .. 6 of string (20) :=
    init ("Quit", "Map", "Player", "Controls", "mapsel", "--") %, "Player select")
%(, "B", "---", "C", "D",
%"Disable B Menu Item", "Enable B Menu Item", "---",
%"Disable Second Menu", "Enable Second Menu")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

font := Font.New ("Agent Orange:16")
font2 := Font.New ("Times:9")
font3 := Font.New ("Times:14")



procedure HumTank
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            Text.Locate (maxrow, 1)
            put name (i) + "s Selected"
            %body
            drawfillbox (50, 220, 80, 250, 40)
            drawbox (50, 220, 80, 250, black)
            %turret
            drawfillbox (60, 240, 70, 265, 40)
            drawbox (60, 230, 70, 265, black)
            %body
            drawline (50, 240, 60, 250, black)
            drawline (50, 230, 60, 220, black)
            drawline (70, 220, 80, 230, black)
            drawline (80, 240, 70, 250, black)
            drawline (60, 240, 50, 240, black)
            drawline (60, 230, 50, 230, black)
            drawline (60, 230, 60, 220, black)
            drawline (70, 230, 70, 220, black)
            drawline (70, 230, 80, 230, black)
            drawline (70, 240, 80, 240, black)
            drawline (60, 240, 65, 230, black)
            drawline (70, 240, 65, 230, black)

            %var Hu : int := GUI.CreateButtonFull (50, 10, 0, "Humans",
            %Humtank, 0, '^D', true)
            %var quitBtn : int := GUI.CreateButton (200, 10, 0, "Quit", GUI.Quit)
        end if
    end for
end HumTank

procedure MenuSelected
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            Text.Locate (maxrow, 1)
            put name (i) + " selected option" ..
        end if
    end for
end MenuSelected

procedure Mapsel
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            put "Map One: Grassland"
            %locatexy (100, 330)
            Pic.ScreenLoad ("H:/map12.jpg", 0, 0, picCopy)
        end if
    end for
end Mapsel

procedure Map
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            Text.Locate (maxrow, 1)
            put name (i) + "s menu selected" ..
            delay (800)
            Mapsel
        end if
    end for
end Map

procedure Playsel
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            cls
            %Text.Locate (maxrow, 1)
            %put name (i) + " Test                          " ..
            Draw.Text ("Humans", 13, 330, font, 40)
            HumTank
            drawline (13, 313, 140, 313, black)
        end if
    end for
end Playsel

procedure Player
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            Text.Locate (maxrow, 1)
            put name (i) + "s select menu" ..
            delay (800)
            cls
            Playsel
        end if
    end for
end Player
%menu 2 items

procedure controls
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            Text.Locate (maxrow, 1)
            put name (i) + "s option selected" ..
            delay (800)
            cls
            put "The controls are: "
            put ""
            put ""
            put " Player One"
            put " -----------"
            put ""
            put " Forward : 'W'"
            put " Down : 'S'"
            put " Left : 'A'"
            put " Right : 'D'"
        end if
    end for
end controls




% Create the menus
first := GUI.CreateMenu ("Game")
item (3) := GUI.CreateMenuItem (name (3), Player)
item (2) := GUI.CreateMenuItem (name (2), Map)
item (1) := GUI.CreateMenuItem (name (1), GUI.Quit)
%item (4) := GUI.CreateMenuItem (name (4), Playsel)

second := GUI.CreateMenu ("Options")
item (4) := GUI.CreateMenuItem (name (4), controls)
loop
    exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
wiktor29




PostPosted: Mon May 31, 2004 1:23 pm   Post subject: procedures

Hey man . I'm having a similar prob.
I'm making a trivia game. Each question is a procedure. After the second question the buttons stop working. IT won't go to question three.
rhomer




PostPosted: Mon May 31, 2004 2:00 pm   Post subject: (No subject)

IN...

code:
item (3) := GUI.CreateMenuItem (name (3), Player)



YOU are making item (3) into a menu selection i believe, and when that menu item is selected it goes to the procedure "Player". In Procedure player...

code:
for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then



you are asking if item (1 - 6) is equal to GUI.GetEventWidgetID.

I think the problem is that at this time...your program doesnt know what item (1 - 6) is equal to.. You must declare their values first...i think
aside




PostPosted: Tue Jun 01, 2004 12:00 am   Post subject: (No subject)

yup, set some values for your items, like this:
code:
var item : array 1 .. 6 of int := init (1, 2, 3, 4, 5, 6)   

it should work
G-lant




PostPosted: Tue Jun 01, 2004 12:39 pm   Post subject: (No subject)

Thanks man that really helps, and it works now, thats awsome. I can like finish myfinal project now.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: