um… maybe im slow at pickin up on stuff… but ive looked through tutorials… and i see that a lot of them deal with choosing a new x and y value and then moving the object to it… for example the random motion tutorial… it chooses a random point on the stage(using Math.random() which im also not totally sure about… but thats later)… so anyway… gets a point… then somehow it moves toward it… i see calculations such as (from the random motion thing)
-thanks to anyone who helps-
speed = Math.random()4+2;
targx = Math.random()(movie_width-_width);
targy = Math.random()*(movie_height-_height);
dist = _root.getdistance(_x, _y, targx, targy);
norm = speed/dist;
diffx = (targx-_x)*norm;
diffy = (targy-_y)*norm;
ok… you get a speed (from 0 to 4 im assuming… then add 2 making the range 2 to 6 if im not mistaken)… then you get a target x and a target y… which are anywhere on the stage… not sure why you do the “-_width” or
“-_height”… but anyway… then get distance… i got that… its just a simple slope formula… but ok… the last 3 lines… i dont really get…
norm = speed/dist;
diffx = (targx-_x)*norm;
diffy = (targy-_y)*norm;
what is norm used to hold?.. i think im correct in assuming the diffx and diffy are the new coordinates to where we move the object… but i dont understand how u got that using “(targx-_x)*norm;” (same for y)… what does this do?..
can anyone clarify this stuff for me? i think it could be really useful for me if i could understand what it does…
just to recap in case i overdid it with what im lookin to figure out…
-
Math.random() works how?
-
how you get the targx and targy (why you subtract _width from movie_width (etc. for height)
-
what norm does… (maybe specify what its use is)
-
why its used in calculating the diffx and diffy
and finally…
- am i correct in assuming that diffx and diffy are used for the new coordinates of the object in question
once again, any help would be greatly appreciated… and thank you in advance to anyone who can take the time to teach me these few things…
-scott