Discuss Scratch

nickwasp
Scratcher
100+ posts

point to X Y

Is there a script that will make a sprite point to an X Y position on the play field? If there is please help. Thanks!
Spontaneous08
Scratcher
100+ posts

point to X Y

You could have a small, invisible sprite go to where you want it to point, and have it point to that sprite. Use this block.
point towards [ spritex]

If any further explanation is needed, tell me.

Last edited by Spontaneous08 (April 19, 2016 00:22:28)

asivi
Scratcher
1000+ posts

point to X Y

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382
gor-dee
Scratcher
1000+ posts

point to X Y

point in direction (([atan v] of ((((x position) - (X)) / (((y position) - (Y))0))9)) v)
nickwasp
Scratcher
100+ posts

point to X Y

asivi wrote:

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382

Thank you his is exactly what i needed! Could you tell me what atan meens and also maybe why you need the
((180) * <(y position) > (y::custom) >)

Last edited by nickwasp (April 19, 2016 15:43:45)

BKFighter
Scratcher
1000+ posts

point to X Y

nickwasp wrote:

asivi wrote:

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382

Thank you his is exactly what i needed! Could you tell me what atan meens and also maybe why you need the
((180) * <(y position) > (y::custom) >)
Yes.
1) atan is just shorthand for inverse tangent
2) Normally thats used in an if statement to switch between two different equations but they have shortened it too one equation. That still returns true false, but here it is a 1 or 0, which can be used in the equation.
asivi
Scratcher
1000+ posts

point to X Y

Hi, i'm going to share a link to a web where it is explained a lot of better i'm able to do it.
Inverse Sine, Cosine, Tangent

To see by yourself that script in your second question does i have added a variable “atan”
define apuntar hacia (x)  (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))
set [atan v] to ([atan v] of (((x) - (x position)) / ((y) - (y position))))
this other
<(y position) > (y::custom)>
maybe true or false, when true it adds 180 to the calculated atan in order to correct the quadrants for the direction.
If you don't understand that, excuse me, it is my fault.
Greets.
CornW1
Scratcher
23 posts

point to X Y

Here's A Project I Made: https://scratch.mit.edu/projects/313328698/

Here Is The Code That the project uses:
when green flag clicked
forever
Point Towards (0) (0)
define Point Towards (X) (Y)
point in direction ( (((180) * <<(y position) > (Y)> or <((y position) + (90)) = (Y)>>) + ([atan v] of (((x position) - (X)) / ((y position) - (Y))))))

PLEASE GIVE CREDIT!!!

Last edited by CornW1 (Dec. 29, 2019 22:40:12)

cchen-tcsyl
Scratcher
72 posts

point to X Y

here is a thing you can view the code in the project https://scratch.mit.edu/projects/396382957/
define 
point torwards(x(y))
balmerazTSC
Scratcher
26 posts

point to X Y

hmm…
I was thinking the same thing.
the script doesn't seem to be working, It there another way!?
when green flag clicked
wait until <(Omg i cant figure this out) = [true]>
go to [Forum v]
Hope that there is a way without trig to do this
A block like this would be great:
point towards x: [ ] y: []
Cutie_Pooge
Scratcher
500+ posts

point to X Y

balmerazTSC wrote:

hmm…
I was thinking the same thing.
the script doesn't seem to be working, It there another way!?
when green flag clicked
wait until <(Omg i cant figure this out) = [true]>
go to [Forum v]
Hope that there is a way without trig to do this
A block like this would be great:
point towards x: [ ] y: []
Please make your own topic. For the answer, there is no way to calculate direction without trigonometry but scratch's
point towards [ v]
block does it for you. If you want you can make some global variables containing positions of where you want to look, broadcast a message to tell another sprite to go there and then use that block.
balmerazTSC
Scratcher
26 posts

point to X Y

(((((???)))))
Is there a way to do it without trig?
IguanaLover
Scratcher
100+ posts

point to X Y

asivi wrote:

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382

Sweet, this worked perfectly!
deck26
Scratcher
1000+ posts

point to X Y

IguanaLover wrote:

asivi wrote:

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382

Sweet, this worked perfectly!
No need to necropost to say that though.
OrbiterYT
Scratcher
100+ posts

point to X Y

balmerazTSC wrote:

(((((???)))))
Is there a way to do it without trig?
Not really, not without a script
HedwigsHat
Scratcher
1000+ posts

point to X Y

when green flag clicked
forever
go to x: (pick random (-272) to (272)) y: (pick random (-214) to (215))
point in direction (x position)
wait (pick random (1) to (10)) secs
point in direction (y position)
hunterfabby
Scratcher
24 posts

point to X Y

asivi wrote:

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382
this worked thank you
ScratchCat1038
Scratcher
1000+ posts

point to X Y

Make 2 sprites, one should be invisible. Also, make 2 variables, x and y.

Type this in the first sprite:
when green flag clicked
point towards x: (some number) y: (some number) :: custom

define point towards x: (x) y: (y)
set [x v] to (x)
set [y v] to (y)
broadcast [some broadcast v] and wait
point towards [your 2nd sprite v]

Type this in your 2nd sprite:
when I receive [some broadcast v]
go to x: (x) y: (y)
27182818284590
Scratcher
70 posts

point to X Y

asivi wrote:

Hi nickwasp, yes it exists
define apuntar hacia (x) (y)
point in direction (([atan v] of (((x) - (x position)) / ((y) - (y position)))) + ((180) * <(y position) > (y)>))

https://scratch.mit.edu/projects/96662382
It worked thank you

Powered by DjangoBB