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

Username:   Password: 
 RegisterRegister   
 procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gilbamy




PostPosted: Thu Jun 15, 2006 11:58 am   Post subject: procedure

alright i am having trouble getting my stupid imaginary company logo to appear first and yes this the first time i have relly used procedures
code:
%Amy Gilbank
%June 1 2006
%war1.t
%a game of war
var winMain : int := Window.Open ("graphics:800;600")
var font1, font2, font3, checkdeck1 : int
var Randomcard, x1, x2, y1, y2 : int
var p1value, p2value, deckcheck, deck, deckvalue, decktest, cards, cardvalue : array 1 .. 52 of int
procedure logo
    font1 := Font.New ("Allegro BT:25:")
    Font.Draw ("Sabriel", 320, 260, font1, 0)
    for i : 0 .. 800
        drawfillbox (0, 600, 800, 0, 7)
        delay (500)
        drawbox (300, 480, 360, 420, 0)
        delay (500)
        drawline (300, 480, 360, 340, 0)
        delay (500)
        drawline (300, 420, 360, 280, 0)
        delay (500)
        drawline (360, 420, 420, 280, 0)
        delay (500)
        drawline (360, 480, 420, 340, 0)
        delay (500)
        drawbox (360, 340, 420, 280, 0)
        delay (500)
        drawline (420, 240, 340, 140, 0)
        delay (500)
        drawline (420, 240, 540, 240, 0)
        delay (500)
        drawline (540, 240, 500, 140, 0)
        delay (500)
        drawline (340, 140, 500, 140, 0)
        delay (500)
        drawline (420, 240, 340, 140, 0)
        delay (500)
        drawline (500, 140, 420, 280, 0)
        delay (500)
        drawline (420, 240, 420, 280, 0)
        delay (500)
        drawline (340, 140, 420, 280, 0)
        delay (500)
        drawline (540, 240, 420, 280, 0)
        delay (500)
    end for
end logo
procedure war
    drawfillbox (0, 600, 800, 0, 199)
    checkdeck1 := 1
    for p : 1 .. 52
        decktest (p) := 1
    end for
    %Battle area
    drawfillbox (20, 100, 95, 200, 78)
    drawfillbox (120, 100, 195, 200, 78)
    drawfillbox (220, 100, 295, 200, 78)
    drawfillbox (320, 100, 395, 200, 78)
    drawfillbox (420, 100, 495, 200, 78)
    drawfillbox (520, 100, 595, 200, 78)
    drawfillbox (620, 100, 695, 200, 78)
    drawfillbox (720, 100, 795, 200, 78)
    %Deck and cards spot
    drawfillbox (200, 400, 275, 500, 79)
    drawfillbox (500, 400, 575, 500, 80)
    drawfillbox (300, 400, 375, 500, 0)
    drawfillbox (400, 400, 475, 500, 0)
    %Scoreboard and card number spots
    drawfillbox (320, 360, 360, 380, 0)
    drawfillbox (420, 360, 460, 380, 0)
    %Fonts
    font1 := Font.New ("Vineta BT:45: bold,underline")
    Font.Draw ("WAR!", 260, 550, font1, red)
    font2 := Font.New ("New Times Roman :11:")
    Font.Draw ("Player 1", 300, 310, font2, 27)
    Font.Draw ("Player 2", 410, 310, font2, 27)
    Font.Draw ("Deck", 220, 510, font2, 27)
    Font.Draw ("Deck", 520, 510, font2, 27)
    %Cards
    cards (1) := Pic.FileNew ("10C.jpg")
    cards (2) := Pic.FileNew ("10D.jpg")
    cards (3) := Pic.FileNew ("10H.jpg")
    cards (4) := Pic.FileNew ("10S.jpg")
    cards (5) := Pic.FileNew ("2C.jpg")
    cards (6) := Pic.FileNew ("2D.jpg")
    cards (7) := Pic.FileNew ("2H.jpg")
    cards (8) := Pic.FileNew ("2S.jpg")
    cards (9) := Pic.FileNew ("3C.jpg")
    cards (10) := Pic.FileNew ("3D.jpg")
    cards (11) := Pic.FileNew ("3H.jpg")
    cards (12) := Pic.FileNew ("3S.jpg")
    cards (13) := Pic.FileNew ("4C.jpg")
    cards (14) := Pic.FileNew ("4D.jpg")
    cards (15) := Pic.FileNew ("4H.jpg")
    cards (16) := Pic.FileNew ("4S.jpg")
    cards (17) := Pic.FileNew ("5C.jpg")
    cards (18) := Pic.FileNew ("5D.jpg")
    cards (19) := Pic.FileNew ("5H.jpg")
    cards (20) := Pic.FileNew ("5S.jpg")
    cards (21) := Pic.FileNew ("6C.jpg")
    cards (22) := Pic.FileNew ("6D.jpg")
    cards (23) := Pic.FileNew ("6H.jpg")
    cards (24) := Pic.FileNew ("6S.jpg")
    cards (25) := Pic.FileNew ("7C.jpg")
    cards (26) := Pic.FileNew ("7D.jpg")
    cards (27) := Pic.FileNew ("7H.jpg")
    cards (28) := Pic.FileNew ("7S.jpg")
    cards (29) := Pic.FileNew ("8C.jpg")
    cards (30) := Pic.FileNew ("8D.jpg")
    cards (31) := Pic.FileNew ("8H.jpg")
    cards (32) := Pic.FileNew ("8S.jpg")
    cards (33) := Pic.FileNew ("9C.jpg")
    cards (34) := Pic.FileNew ("9D.jpg")
    cards (35) := Pic.FileNew ("9H.jpg")
    cards (36) := Pic.FileNew ("9S.jpg")
    cards (37) := Pic.FileNew ("QC.jpg")
    cards (38) := Pic.FileNew ("QD.jpg")
    cards (39) := Pic.FileNew ("QH.jpg")
    cards (40) := Pic.FileNew ("QS.jpg")
    cards (41) := Pic.FileNew ("AC.jpg")
    cards (42) := Pic.FileNew ("AD.jpg")
    cards (43) := Pic.FileNew ("AH.jpg")
    cards (44) := Pic.FileNew ("AS.jpg")
    cards (45) := Pic.FileNew ("JC.jpg")
    cards (46) := Pic.FileNew ("JD.jpg")
    cards (47) := Pic.FileNew ("JH.jpg")
    cards (48) := Pic.FileNew ("JS.jpg")
    cards (49) := Pic.FileNew ("KC.jpg")
    cards (50) := Pic.FileNew ("KD.jpg")
    cards (51) := Pic.FileNew ("KH.jpg")
    cards (52) := Pic.FileNew ("KS.jpg")
    %Code
    x1 := 300
    y1 := 400
    x2 := 400
    y2 := 400
    for deal : 1 .. 52
        loop
            Randomcard := Rand.Int (1, 52)
            if decktest (Randomcard) = 0 then
                exit
            elsif decktest (Randomcard) = 1 then
                decktest (Randomcard) := 0
                exit
            end if
        end loop
    end for
    Pic.Draw (cards (Randomcard), x1, y1, picMerge)
    Pic.Draw (cards (Randomcard), x2, y2, picMerge)
    %for i : 1 .. 26
    %   Randomcard := Rand.Int (1, 52)
    %  exit when deckcheck (Randomcard) = 0
    % deckcheck (Randomcard) := 1
    %   p1 (i) := deck (Randomcard)
    %  p1value (i) := deckvalue (Randomcard)
    %end for
    cardvalue (1) := 10
    cardvalue (2) := 10
    cardvalue (3) := 10
    cardvalue (4) := 10
    cardvalue (5) := 2
    cardvalue (6) := 2
    cardvalue (7) := 2
    cardvalue (8) := 2
    cardvalue (9) := 3
    cardvalue (10) := 3
    cardvalue (11) := 3
    cardvalue (12) := 3
    cardvalue (13) := 4
    cardvalue (14) := 4
    cardvalue (15) := 4
    cardvalue (16) := 4
    cardvalue (17) := 5
    cardvalue (18) := 5
    cardvalue (19) := 5
    cardvalue (20) := 5
    cardvalue (21) := 6
    cardvalue (22) := 6
    cardvalue (23) := 6
    cardvalue (24) := 6
    cardvalue (25) := 7
    cardvalue (26) := 7
    cardvalue (27) := 7
    cardvalue (28) := 7
    cardvalue (29) := 8
    cardvalue (30) := 8
    cardvalue (31) := 8
    cardvalue (32) := 8
    cardvalue (33) := 9
    cardvalue (34) := 9
    cardvalue (35) := 9
    cardvalue (36) := 9
    cardvalue (37) := 12
    cardvalue (38) := 12
    cardvalue (39) := 12
    cardvalue (40) := 12
    cardvalue (41) := 14
    cardvalue (42) := 14
    cardvalue (43) := 14
    cardvalue (44) := 14
    cardvalue (45) := 11
    cardvalue (46) := 11
    cardvalue (47) := 11
    cardvalue (48) := 11
    cardvalue (49) := 13
    cardvalue (50) := 13
    cardvalue (51) := 13
    cardvalue (52) := 13
end war


i know i need forks though right
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jun 15, 2006 12:24 pm   Post subject: (No subject)

you are not allowed to use forks.

you just call procedures by their name
code:

procedure logo()
   puts "this is my logo"
end logo

puts "here comes the logo!"
logo
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Delos




PostPosted: Thu Jun 15, 2006 3:07 pm   Post subject: (No subject)

There is an error in Tony's code there. However, this is a very constructive error. Locate it, and see if you can figure out how to fix it. As a hint, procedures, functions, and so forth, act just like regular variables. In fact, both procedures and functions are first-class values - they are quite analagous to ints and reals and booleans.
To that effect, they are just as sensitive when it comes to their naming and (possible) inclusion of parameters.
Tony




PostPosted: Thu Jun 15, 2006 4:03 pm   Post subject: (No subject)

you know you've been writing more Ruby than Turing when...

Edit: and I'm not refering to the use of parameters.. though ya, what Delos said.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
gilbamy




PostPosted: Thu Jun 15, 2006 4:57 pm   Post subject: (No subject)

well i got my log to appear except my name of my company won't appear and that its in a constant rotaion how do i fix that
code:
procedure logo
    font3 := Font.New ("Allegro BT:25:")
    for i : 0 .. 800
        Font.Draw ("Sabriel", 320, 260, font3, 0)
        drawfillbox (0, 600, 800, 0, 7)
        delay (500)
        drawbox (300, 480, 360, 420, 0)
        delay (500)
        drawline (300, 480, 360, 340, 0)
        delay (500)
        drawline (300, 420, 360, 280, 0)
        delay (500)
        drawline (360, 420, 420, 280, 0)
        delay (500)
        drawline (360, 480, 420, 340, 0)
        delay (500)
        drawbox (360, 340, 420, 280, 0)
        delay (500)
        drawline (420, 240, 340, 140, 0)
        delay (500)
        drawline (420, 240, 540, 240, 0)
        delay (500)
        drawline (540, 240, 500, 140, 0)
        delay (500)
        drawline (340, 140, 500, 140, 0)
        delay (500)
        drawline (420, 240, 340, 140, 0)
        delay (500)
        drawline (500, 140, 420, 280, 0)
        delay (500)
        drawline (420, 240, 420, 280, 0)
        delay (500)
        drawline (340, 140, 420, 280, 0)
        delay (500)
        drawline (540, 240, 420, 280, 0)
        delay (500)
    end for
end logo
logo
Bored




PostPosted: Thu Jun 15, 2006 5:07 pm   Post subject: (No subject)

code:
Font.Draw ("Sabriel", 320, 260, font3, 0)
drawfillbox (0, 600, 800, 0, 7)

Look at these two lines, think about what they do and you'll figure it out. This is the type of problem you should be learning to figure out on your own. It's very simple, so I won't tell you, though my hint may make it VERY obvious.[/code]
Tony




PostPosted: Thu Jun 15, 2006 5:08 pm   Post subject: (No subject)

you have 8 seconds worth of delays inside a 0..800 loop. So it will take about 2 hours for that procedure to complete.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
gilbamy




PostPosted: Thu Jun 15, 2006 5:31 pm   Post subject: (No subject)

i know Font.Draw puts my name in and drawline draws a bloody line but it would not work outside of my for loop and how to i make its so it well only take a few sec
Sponsor
Sponsor
Sponsor
sponsor
Bored




PostPosted: Thu Jun 15, 2006 5:34 pm   Post subject: (No subject)

Well to make it only take a couple of seconds well
code:
for i : 0..800

well with 8 seconds of delays, 800 loops will take a VERY long time. And yes Font.Draw draws your name but what does the command right after it do, think about it, it's not a drawline now is it?
gilbamy




PostPosted: Thu Jun 15, 2006 5:43 pm   Post subject: (No subject)

oh yeah i forgot about that for loop thing opps i am an idiot thing but my text still won't appear though
gilbamy




PostPosted: Thu Jun 15, 2006 6:26 pm   Post subject: (No subject)

never mind i got now thx for your help everyone
wtd




PostPosted: Thu Jun 15, 2006 6:43 pm   Post subject: (No subject)

Holy lack of loops Batman!

code:
    cardvalue (1) := 10
    cardvalue (2) := 10
    cardvalue (3) := 10
    cardvalue (4) := 10
    cardvalue (5) := 2
    cardvalue (6) := 2
    cardvalue (7) := 2
    cardvalue (8) := 2
    cardvalue (9) := 3
    cardvalue (10) := 3
    cardvalue (11) := 3
    cardvalue (12) := 3
    cardvalue (13) := 4
    cardvalue (14) := 4
    cardvalue (15) := 4
    cardvalue (16) := 4
    cardvalue (17) := 5
    cardvalue (18) := 5
    cardvalue (19) := 5
    cardvalue (20) := 5
    cardvalue (21) := 6
    cardvalue (22) := 6
    cardvalue (23) := 6
    cardvalue (24) := 6
    cardvalue (25) := 7
    cardvalue (26) := 7
    cardvalue (27) := 7
    cardvalue (28) := 7
    cardvalue (29) := 8
    cardvalue (30) := 8
    cardvalue (31) := 8
    cardvalue (32) := 8
    cardvalue (33) := 9
    cardvalue (34) := 9
    cardvalue (35) := 9
    cardvalue (36) := 9
    cardvalue (37) := 12
    cardvalue (38) := 12
    cardvalue (39) := 12
    cardvalue (40) := 12
    cardvalue (41) := 14
    cardvalue (42) := 14
    cardvalue (43) := 14
    cardvalue (44) := 14
    cardvalue (45) := 11
    cardvalue (46) := 11
    cardvalue (47) := 11
    cardvalue (48) := 11
    cardvalue (49) := 13
    cardvalue (50) := 13
    cardvalue (51) := 13
    cardvalue (52) := 13


Sure ya can't figure out any way to automate this a bit more?
Clayton




PostPosted: Thu Jun 15, 2006 9:03 pm   Post subject: (No subject)

use nested for loops and a clever idea to cut that down to about 5 lines, or even better, use TOTG's idea that he posted in ur other thread to cut it down to about 3 lines, optimization is the king Very Happy

@Tony: wow, um i dont know what to say about that lol Very Happy
Tony




PostPosted: Thu Jun 15, 2006 11:05 pm   Post subject: (No subject)

SuperFreak82 wrote:
@Tony: wow, um i dont know what to say about that lol Very Happy

what can I say, I haven't programed with Turing in years. Someone should get me an Intel Mac Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 14 Posts ]
Jump to:   


Style:  
Search: