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

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




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
cutecotton




PostPosted: 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




PostPosted: 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 Wink


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 Twisted Evil
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
cutecotton




PostPosted: 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? Embarassed lol ^^;;
Tony




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
cutecotton




PostPosted: 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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
cutecotton




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

Very Happy oo okay i see ^^ ur so hlepful lol (i'm such a newbie Confused ) 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
Sponsor
Sponsor
Sponsor
sponsor
Albrecd




PostPosted: 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




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

Check the rules, please.

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.

Ie, nobody has cared about this thread for almost 3 years now.

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




PostPosted: 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. Smile
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  [ 11 Posts ]
Jump to:   


Style:  
Search: