Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Diagonal animation
Author Message
legends31

Posted: Tue Dec 24, 2002 12:14 am   Post subject: Diagonal animation

I need Help making an animation move diagonaly. I can easily make it work back and forth, up and down but how to i make to move across the x axis and the y axis at the same time?
this is what i have

 code: process ball for y : 0 .. 400 by 10     drawfilloval (50, y + 50, 6, 6, 7)     delay (50)     drawfilloval (50, y + 50, 6, 6, 0) end for end ball

thanks
Andrew

cutecotton

Posted: Tue Dec 24, 2002 3:53 pm   Post subject: (No subject)

wouldn't it be like this:

procedure ball
for y : 0 .. 400 by 10
drawfilloval (50+y, y + 50, 6, 6, 7)
delay (50)
drawfilloval (50+y, y + 50, 6, 6, 0)
end for
end ball
ball

i just changed the process ot a procedure cuz i dont know how to use processes lol. but eitherway it moves upwards diagonally. I just made the x and y increase at teh same time.
Tony

Posted: Tue Dec 24, 2002 3:57 pm   Post subject: (No subject)

well basically you add the counter of the loop to both X and Y of the object. If you want to move it at a diagnal other then 45degree, then you just multiply one of the axis by a decimal, such as
 code: drawfilloval(i, round(i*0.5),5,5,blue)

this will move the ball at 22.5degrees

here's the actual code for moving the ball:

 code: process ball for i:1..200      drawfilloval(i,i,5,5,red) end for end ball

Edit: well it seems like cutecotton got to post before me... oh well, I showed how to move at angles other then 45
Tony's programming blog. DWITE - a programming contest.
cutecotton

Posted: Tue Dec 24, 2002 4:43 pm   Post subject: (No subject)

hmm, i know this is kinda off the topic, but it's just q uick question and i didn't watn to make a whoel new thread for it. But can someone explaint o me the difference between procedures and prcoesses and when u'd use one or the other? lol ^^;;
Tony

Posted: Tue Dec 24, 2002 6:16 pm   Post subject: (No subject)

procedure is a sub program that can be executed at call
process is a procedure that can be executed parallel to other procedures. So you can have more then 1 thing running at same time. Useful for background music and animation of multiple things separatly
function is a procedure that returns a value
Tony's programming blog. DWITE - a programming contest.
cutecotton

Posted: Tue Dec 24, 2002 6:20 pm   Post subject: (No subject)

oo i c (tks to tony) so i'd use a process when i have to use a fork, so i can say have bg music and have my program run at teh same time. But processes can't be called at any time? they jsut run in that spot and tha'ts it?
Tony

Posted: Tue Dec 24, 2002 6:24 pm   Post subject: (No subject)

processes usually run in an endless loop and are called at the beginning of the program just once. Though that depends on the structure of the program. Such as for the background music you'll have

 code: process bMusic loop play music here end loop end bMusic fork bMusic %<- Just once loop actual program here end loop

Though if its something like animation or anything that needs an exit from loop, you'd have to call it up again inside main program.
Tony's programming blog. DWITE - a programming contest.
cutecotton

Posted: Tue Dec 24, 2002 6:28 pm   Post subject: (No subject)

oo okay i see ^^ ur so hlepful lol (i'm such a newbie ) i'll need to use processes then in my program late ron..and array's as well...

why didn't our teacher teach us all this?! damn her for being away that day that she was suppose to teach us everything *sigh*

O.o*cutecotton*o.O

Albrecd

Posted: Thu Nov 10, 2005 9:28 am   Post subject: (No subject)

Quote:
here's the actual code for moving the ball:

Code:

process ball

for i:1..200
drawfilloval(i,i,5,5,red)
end for

end ball

You should put a delay, otherwise it looks like Draw.ThickLine
codemage

Posted: Thu Nov 10, 2005 9:52 am   Post subject: (No subject)

Don't make posts to topics that are older than a couple of weeks old AT MOST. This is called necro posting, because you're responding to a topic that is considered DEAD.

If you must, you can PM a person in the thread if you have something to add, or a related question.
Cervantes

Posted: Thu Nov 10, 2005 3:47 pm   Post subject: (No subject)

Well put.

codemage wrote:
If you must, you can PM a person in the thread if you have something to add, or a related question.

Although, just to drive the point home, even this would not have any affect, as the thread starter is long gone.

And I'm locking this one. Perhaps you'd like to try to justify using many variables as opposed to an array, so I'll leave the other one open for some fun.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 11 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: