Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Pictures in Motion
Author Message
TheZsterBunny

Posted: Fri Feb 27, 2004 6:06 am   Post subject: Pictures in Motion

Currently we are learning arrays in class.

Boring, so I'm working on an array project of my own.

My problem now is this: How can I have a picture move from offscreen (easy) to a clicked point at a fixed speed. AsianS's asteroid-spaceship tutorial was a help, but I couldn't quite figure it out.

This isn't important, but any help would be appreciated.

-bunny

Tony

Posted: Fri Feb 27, 2004 9:11 am   Post subject: (No subject)

Vector components
Quote:

|\
y | \ constant velocity
|__\
x

find the vector between your current location and the destanation point. The solve for it's components. Now make a ratio between X/Y components and the hypotenuse.

You know what your hypotenuse has to be - thats the magnitude of your "constant velocity". Use the ratios you jsut calculated to construct a velocity vector that will move the object in a straight line to the destanation, while maintaining your velocity
Tony's programming blog. DWITE - a programming contest.
Delos

Posted: Sat Feb 28, 2004 4:56 pm   Post subject: (No subject)

Ohh boy...components.

Remember those sine and cosine laws from gr 11 maths? Well, fish 'em out again, you'll need them. Or at least SOH-CAH-TOA.

Components are most useful for a bunch of anims...namely particles!
AsianSensation

Posted: Sat Feb 28, 2004 5:28 pm   Post subject: (No subject)

if you don't know trig, there is another similar way. You first calculate the distance between the starting and ending point, I'm sure you've learned the distance formula. Then split the distance into several segment, and increase the each the x and y by that segments each time in a for loop. It's the components idea, except without all the fancy words
shorthair

Posted: Sat Feb 28, 2004 6:23 pm   Post subject: (No subject)

Delos didnt you learn trig in grade 10 , ?
Delos

Posted: Sun Feb 29, 2004 11:34 am   Post subject: (No subject)

Just a bit in gr 10. The good stuff comes in gr 11, then the really good stuff in 12 (Discrete - geometric proofs!! Argh!)
apomb

Posted: Sun Feb 29, 2004 1:04 pm   Post subject: (No subject)

Also, Gr. 11 Pysics uses trig , so theres a big chance that you will run into trig somewhere!
BlAcK TuRtLe

Posted: Sun Feb 29, 2004 3:08 pm   Post subject: (No subject)

Did you want it to stop at the clicked point or keep goin on that vector?

btw- Delos im taking discrete next year and wondering whether or not you found it hard or not.

Maverick

Posted: Sun Feb 29, 2004 3:56 pm   Post subject: (No subject)

This has nothing to do with anything, but...

Quote:
Posted: Fri Feb 27, 2004 6:06 am Post subject: Pictures in Motion

6 am? holy scheisse
TheZsterBunny

Posted: Sun Feb 29, 2004 8:33 pm   Post subject: Re: Everything

Okay. I'm in grade 10 and got my first taste of trig this past week. I don't really have a problem with the easy stuff, but the only thing I know about vectors is from that sega saturn game from years past.

No, AsianS, I don't know the distance formula.

Earlier I tried using a for loop and averaging the distance between the two points (x := (((x1 + x2) div 2) + x2) div 2) but that took much code.

And in reply to Maverick, I wake at ~4 to do my homework, but I usually end up at compsci.ca. Most Posts are at 6 am.

Thanks guys for the input,

-bunny
AsianSensation

Posted: Sun Feb 29, 2004 10:37 pm   Post subject: Re: Everything

TheZsterBunny wrote:
No, AsianS, I don't know the distance formula.

WHAT!?!? You go to Vincent Massey and you don't know math? Thank God the math teachers haven't found you yet! Run for your life while you could! Run I tell you, run!

ok, I'm just surprised that you came from our school, in gr 10 without knowing the distance formula. I thought it was taught in gr 9?

btw distance formula:

(x1 - x2)^2 + (y1 - y2)^2 = d^2

where (x1, y1), (x2, y2) are the points on the Cartesian plane and d is the distance.
Boarder16

Posted: Sun Feb 29, 2004 10:56 pm   Post subject: (No subject)

All of this talk of physics and math makes me wanna kill myself although i did well in both subjects lol
zylum

Posted: Sun Feb 29, 2004 11:10 pm   Post subject: (No subject)

is this what you're looking for???

 code: setscreen ("offscreenonly") var x, y, speed : real var newx, newy, mousedown : int x := -100 y := - -100 speed := 20 loop     mousewhere (newx, newy, mousedown)     exit when mousedown = 1 end loop loop     x -= (x - newx) / speed     y -= (y - newy) / speed     drawfilloval (round (x), round (y), 20, 20, 43)     View.Update     delay (10)     cls end loop

-zylum
Cervantes

Posted: Mon Mar 01, 2004 5:48 pm   Post subject: (No subject)

I've never heard of this distance formula before I came to compsci, but its not hard to understand (not saying that you don't bunny, but someone out there might
The distance formula that azn said is simply the Pythagorean Theorm.

C^2 = A^2 + B^2

D^2 = (x2 - x1)^2 + (y2 - y1)^2

(x2 - x1) gives us a length, A.
(y2 - y1) gives us another length, B.

TheZsterBunny

Posted: Sat Mar 06, 2004 6:42 pm   Post subject: (No subject)

zylum, your help is always appreciated, and the 'slowing down' of the ball as it reached its destination was impressive. However, the goal of this forum was to use pictures rather than shapes -> as in the pictures can point in different directions as they move (face their destination)

Confusing writing, as I've been missing my sleep, but this was just an idea.

-bunny

-------EDIT-------

Disregard please, Zylum, i've found your angle program. Thanks for the help guys.

-bunny
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 18 Posts ]
Goto page 1, 2  Next
 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: