Computer Science Canada

procedure...

Author:  air_force91 [ Wed Jan 14, 2004 4:34 pm ]
Post subject:  procedure...

i wanna make a 3D text effect on my "credit" page but the problem is that im not able to use "procedure" inside an "if" statement...here's my code so far...i need the 3D effect after the "%%%%%%%%%%%%%%%EXIT%%%%%%%%%%%%%%%

code:
var winID : int
        winID := Window.Open ("position:800;350,graphics:800;350")
       
  View.Set ("nocursor")
       


colourback (red)
cls

%Import computer picture
var comppic : int := Pic.FileNew ("computerback.bmp")
Pic.Draw (comppic, maxx div 2 - (Pic.Width (comppic) div 2), maxy div 2 - Pic.Height (comppic) div 2, picMerge)
var fontID : int := Font.New ("Franklin Gothic Medium:16:bold")
Font.Draw ("Welcome To", 300, 300, fontID, green)
Font.Draw ("...", 350, 275, fontID, yellow)

%3D effect for "The Ultimate MB!!"

var size : int := 40
var text : string
var text1 := "The Ultimate MB!!"
var ch : string (1)

var afontID : array 1 .. size of int

for i : size div 2 .. size
    afontID (i) := Font.New ("Tahoma:" + intstr (i))
end for


procedure Text3D (text : string)
    for t : 1 .. length (text)
        for i : size div 2 .. size
            Font.Draw (text (t), t * size, 170, afontID (i), 20 + floor
                (i / size * 15))
        end for
    end for
end Text3D

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% You have to insert the picture before the text, so that                   %
%  the text will overlap the picture                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Text3D (text1)

%ball animation

%"enter any key"
var bfontID : int := Font.New ("Arial:10:bold")
Font.Draw ("Press any key to continue...", 597, 25, bfontID, blue)
getch (ch)

cls

%%%%%%%%%%%%%%%%%%%%%%%%%%%%second page%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

colourback (3)
cls


var sizea : int
var text2 : string
sizea := 15
var text3 := "The Ultimate MB!!"

var cfontID : array 1 .. sizea of int

for i : sizea div 2 .. sizea
    cfontID (i) := Font.New ("Tahoma:" + intstr (i))

end for

procedure Text3D1 (text2 : string)


    for t : 1 .. length (text2)

        for i : sizea div 2 .. sizea
            Font.Draw (text2 (t), t * sizea, 315, cfontID (i), 20 + floor
                (i / size * 50))

        end for
    end for


end Text3D1
Text3D1 (text3)

%%Import computer picture

var comppic1 : int := Pic.FileNew ("comp3.bmp")
Pic.Draw (comppic1, 50 div 2, 20 div 2, 0)


%%%%%%%%%%%%%%%%%%%%%%buttons

%3rd button

Draw.FillBox (550, 40, 667, 90, 5)
Draw.Box (550, 40, 667, 90, 1)

var dfontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Exit", 590, 60, dfontID, black)

%2nd button

Draw.FillBox (550, 140, 667, 190, 5)
Draw.Box (550, 140, 667, 190, 1)

var efontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Start Game", 562, 160, efontID, black)

%1st button

Draw.FillBox (550, 240, 667, 290, 5)
Draw.Box (550, 240, 667, 290, 1)

var ffontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Instructions", 562, 260, ffontID, black)

%%%mouse detect--*click*

loop

    var x, y, btn : int
    Mouse.Where (x, y, btn)

    if x >= 550 and x <= 667 and y >= 240 and y <= 290 and btn = 1 then
        cls
        colourback (blue)
        cls

        %%%%%%%%%%%%%%%%%instructions page%%%%%%%%%%%%%%%%%%%%%%%%%%%
        var ifontID : int :=Font.New ("Arial Narrow:10:bold")
       
        var gfontID : int := Font.New ("Tahoma:15:bold")

        var hfontID : int := Font.New ("Arial:12:bold")
       
      Font.Draw ("Click on screen to go back to main screen...", 530, 25, ifontID, yellow) 

        Font.Draw ("Instructions!!", 5, 325, gfontID, yellow)

        delay (800)

        Font.Draw ("1) After clicking 'Start Game', you are led to a screen with an empty motherboard and several ", 50, 260, hfontID, yellow)
        Font.Draw ("motherboard parts on the side.", 67, 240, hfontID, yellow)

        delay (800)

        Font.Draw ("2) The object of the game is to drag and place the parts in their correct place on the ", 50, 180, hfontID, yellow)
        Font.Draw ("motherboard.", 67, 160, hfontID, yellow)

        delay (800)

        Font.Draw ("3) For each correct placement, you receive one point and LEDs perform an effect on the", 50, 100, hfontID, yellow)
        Font.Draw ("posterboard included. If placement is incorrect, part next to lighted LED illustrates", 67, 80, hfontID, yellow)
        Font.Draw ("correct placement.", 67, 60, hfontID, yellow)

        delay (100)

        Font.Draw ("Good Luck!", 340, 35, hfontID, yellow)
       

    elsif x >= 550 and x <= 667 and y >= 140 and y <= 190 and btn = 1 then

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%Start Game Page%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        cls
        colourback (5)
        cls

   elsif x >= 550 and x <= 667 and y >= 40 and y <= 90 and btn = 1 then

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EXIT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      var ifontID : int :=Font.New ("Comic Sans MS : 10 : italics")
     
        Font.Draw ("Thank you for Playing...",
        Window.Close (winID)
       Window.Hide (winID)



    end if


end loop

Author:  Tony [ Wed Jan 14, 2004 6:57 pm ]
Post subject: 

you can't declear the procedure inside your code. Porcedures must be decleared on the top and then be called upon. Such as
code:

procedure text
...
end text
...
loop
...%main program here
...
if blah then
     text <-call procedue by using it's identifier
end if
...


: