Re: [AL] How to do it?

dear allegro,I am being swamped with = mail from=20 canvas link allegro.PLEASE .UNSUBSCRIBE ALLEGRO in the body of the = message.I=20 have not requested it and I do not require it.am an old infirm person = and can do=20 without all this hassle.
------=_NextPart_000_000F_01C1D186.BA58F720--
 Re: [AL] How to do it? From: Daniel Lucio - 2002-03-23 04:29:37 Thanks everybody for the help! Suppose you have a game where you need to shot a bullet right after mouse click. The bullet needs to move from your gun to where the mouse was when you clicked mouse button! //on mouse click! if (mouse_b & 1) { tempPOSX = mouse_x; tempPOSY = mouse_y; } Now move your bullet from a fixed (A) position, to the new position (B = tempPOSX, tempPOSY) How to calculate BULLET X,Y position by position util it reachs (B) ???????? Looks like Redboshi's solution is almost what I want, but I didn't understood it very well coz, tempFloat= DISTANCETOMOVE/ tempFloat ?????? Isn't DISTANCETOMOVE = sqrt(diffX^2 + diffY^2) ? Thanks a lot Daniel ----- Original Message ----- From: To: Sent: Friday, March 22, 2002 7:34 PM Subject: Re: [AL] How to do it? > In a message dated 3/22/02 1:41:06 PM Pacific Standard Time, > w_labbett@... writes: > > > you've got a sprite somewhere on the screen, and you want to be able to > > point the mouse cursor somewhere and then draw the sprite there instead of > > where it was. > > Is that right? > > I thought Daniel was saying that an image needs to move a set distance > towards the cursor. The math for this would be something along the lines of > psuedocode: > > a is the start (image's location) > b is the destination (mouse's location) > > diffX= b.x- a.x > diffY= b.y- a.y > tempFloat= sqrt(diffX^2 + diffY^2) > tempFloat= DISTANCETOMOVE/ tempFloat > a.x+= diffX* tempFloat > b.x+= diffY* tempFloat > > right? That may not be fully correct but it's something like that. However, I > don't see how the mouse being a variable point should make anything more > difficult (except maintaining a constant velocity), or understand exactly > what all that talk of lines was about. Please rephrase the question. > > -Ben >