Making a formula that finds the horizontal and vertical distance between two points t

Apr 2019
Sydney, Australia
I am making a Scratch 3.0 game. The shooter sprite is holding a gun slightly off-centre (see images), and I need the bullet to go to the end of the barrel of the gun before travelling forward (as so it would appear the bullet it leaving the gun). The issue is, to do this, I need to find the X and Y distance of the end of the barrel from the centre of the shooter sprite (Scratch doesn't let you use diagonal distances 😡). The X and Y distances change as the sprite rotates.

I know if the shooter sprite is facing 90º (right angle), the X distance to the gun is 105 pixels, and the Y distance is 45 pixels.

The computer always knows what direction the shooter sprite is facing.

What about the distances for all the other angles the shooter sprite is facing? Do I need a special formula?Background (2).png Background (1).png

Aug 2012
Your images need to be online somewhere that can be linked. They're not showing up here.
  • Like
Reactions: 1 person


Forum Staff
Dec 2006
In general, forums don't support hot-linking to images hosted on other forums, but there are forum-friendly image hosting sites that can easily be found.

To upload an image here, try using the Go Advanced button and then the attachments (paperclip) icon. There's a size limit for such attached images.