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

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




PostPosted: Mon Nov 29, 2004 5:56 pm   Post subject: moving a proc

Is there a way to move a proc to a seperate location without changing the codes in the proc. This is a small (non artistic) version of a man i am making for a game.

I want him to move to the center screen without changing any coordinates.

Also is there away to make him almost walk to the center screen without putting a counting loop INSIDE the procedure?

thanks

code:

proc man
    drawfillbox (30, 30, 40, 80, red)
    drawfilloval (35, 85, 10, 10, 37)
    drawline (30, 65, 1, 100, black)
    drawline (40, 65, 60, 100, black)
end man


man
Sponsor
Sponsor
Sponsor
sponsor
Neo




PostPosted: Mon Nov 29, 2004 6:02 pm   Post subject: (No subject)

You would have to change the coordinates, otherwise how would the computer know where to draw the circles or lines or boxes?
Cervantes




PostPosted: Mon Nov 29, 2004 6:24 pm   Post subject: (No subject)

msimard8 wrote:
Is there a way to move a proc to a seperate location without changing the codes in the proc. This is a small (non artistic) version of a man i am making for a game.

Yes. Use parameters for your procedure.
code:

proc man (x, y : int)
    drawfillbox (30 + x, 30 + y, 40 + x, 80 + y, red)
    drawfilloval (35 + x, 85 + y, 10, 10, 37)
    drawline (30 + x, 65 + y, 1 + x, 100 + y, black)
    drawline (40 + x, 65 + y, 60 + x, 100 + y, black)
end man

man (50, 50)
man (300, 100)

Noticce that you don't want to add x and y to the 3rd and 4th parameter of drawfilloval, because those parameters are for radius. Adding to radius is not what you want Wink

msimard8 wrote:
Also is there away to make him almost walk to the center screen without putting a counting loop INSIDE the procedure?

What do you mean, "a countring loop"? a for loop? Or a loop that has a counter variable that changes each time through the loop?
And what do you mean walk? Are you talking about animation? or just simply moving his picture. If your talking about the second one, try doing things like this:
code:

setscreen ("offscreenonly")
proc man (x, y : int)
    drawfillbox (30 + x, 30 + y, 40 + x, 80 + y, red)
    drawfilloval (35 + x, 85 + y, 10, 10, 37)
    drawline (30 + x, 65 + y, 1 + x, 100 + y, black)
    drawline (40 + x, 65 + y, 60 + x, 100 + y, black)
end man

man (50, 50)
for i : 50 .. 200
    cls
    man (i, i)
    View.Update
    delay (10)
end for

Of course, that won't get him directly to the centre of the screen. Play around with the idea a bit.
msimard8




PostPosted: Mon Nov 29, 2004 6:30 pm   Post subject: thanks

Thanks so much

You answered both of my questions...i just wanted to move the object and I meant for loop. my teacher just calls them counting loops.

sry

thanks
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  [ 4 Posts ]
Jump to:   


Style:  
Search: