This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-02-12 22:56:47

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Make a sprite revolve around another sprite based on mouse?

How would I go about making a sprite revolve around a different sprite so that the first sprite is closer to the mouse?


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#2 2011-02-13 01:01:10

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: Make a sprite revolve around another sprite based on mouse?

If sprite 1 is revolving around sprite 2, and distance is the distance between them, than do this in sprite 1:

[blocks]
<go to[ sprite2
<point towards( mouse
<move( distance )steps>
[/blocks]

There are more complex formulas, but I don't feel like going into them right now.

Last edited by floppy_gunk (2011-02-13 01:02:04)


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

#3 2011-02-13 11:31:48

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Give me a second; I have a script similar to this, I just need to tweak it.


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#4 2011-02-13 11:59:19

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Well call me the most confused person alive.  I can make a sprite revolve so it goes directly away from the mouse, but not towards.

http://scratch.mit.edu/projects/Kileymeister_test/1594416

When I try to make it go the other way it glitches out and the sprite flies everywhere.

???

EDIT:  Wait, I think I have it.  Gimme another minute, please.

Last edited by Kileymeister (2011-02-13 12:05:22)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#5 2011-02-13 12:05:37

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Whoa, that script is confusing  tongue . Oh well.

I was thinking I could do something with sin and cosin but I always get one as output from them. I guess that's what they're supposed to do, anyways, though.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#6 2011-02-13 12:09:19

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Wait, I have it!  Sorta.

http://scratch.mit.edu/projects/Kileymeister_test/1594435

Only one glitch where when you mouse your mouse under the center sprite that doesn't move, your sprite goes the other way.  The end result is the same but it takes the long route around.

Last edited by Kileymeister (2011-02-13 12:09:25)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#7 2011-02-13 12:15:13

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Kileymeister wrote:

Wait, I have it!  Sorta.

http://scratch.mit.edu/projects/Kileymeister_test/1594435

Only one glitch where when you mouse your mouse under the center sprite that doesn't move, your sprite goes the other way.  The end result is the same but it takes the long route around.

Agh, wish I could understand the script D: . Oh well, thanks  big_smile .


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#8 2011-02-13 12:17:57

Kileymeister_test
Scratcher
Registered: 2010-01-31
Posts: 100+

Re: Make a sprite revolve around another sprite based on mouse?

Sunrise-Moon wrote:

Kileymeister wrote:

Wait, I have it!  Sorta.

http://scratch.mit.edu/projects/Kileymeister_test/1594435

Only one glitch where when you mouse your mouse under the center sprite that doesn't move, your sprite goes the other way.  The end result is the same but it takes the long route around.

Agh, wish I could understand the script D: . Oh well, thanks  big_smile .

Just import it, then you don't need to know!  big_smile   (That came out a little meanly, sorry)
Oh, and wherever it says [x positon] of [Sprite 2], change the [Sprite 2] to the sprite you want it to revolve around.

Last edited by Kileymeister_test (2011-02-13 12:18:32)


Kileymeister's test account.  I upload engines and demos and stuff for public use.
Currently Working on: Grapple Arms!

Offline

 

#9 2011-02-13 12:22:04

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Kileymeister_test wrote:

Sunrise-Moon wrote:

Kileymeister wrote:

Wait, I have it!  Sorta.

http://scratch.mit.edu/projects/Kileymeister_test/1594435

Only one glitch where when you mouse your mouse under the center sprite that doesn't move, your sprite goes the other way.  The end result is the same but it takes the long route around.

Agh, wish I could understand the script D: . Oh well, thanks  big_smile .

Just import it, then you don't need to know!  big_smile   (That came out a little meanly, sorry)
Oh, and wherever it says [x positon] of [Sprite 2], change the [Sprite 2] to the sprite you want it to revolve around.

Alright, thanks  big_smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#10 2011-02-13 13:16:16

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Make a sprite revolve around another sprite based on mouse?

<when green flag clicked>
<forever>
<go to[ Sprite1 ]>
<point towards( Mouse pointer )>
<move( 100 )steps>
<clear>
<stamp>
<end>

Offline

 

#11 2011-02-13 13:19:16

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

colorfusion wrote:

<when green flag clicked>
<forever>
<go to[ Sprite1 ]>
<point towards( Mouse pointer )>
<move( 100 )steps>
<clear>
<stamp>
<end>[/blocks]

Close, but that would make it point, not rotate, right?

Last edited by Kileymeister (2011-02-13 13:19:24)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#12 2011-02-13 16:17:08

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Make a sprite revolve around another sprite based on mouse?

Kileymeister wrote:

colorfusion wrote:

<when green flag clicked>
<forever>
<go to[ Sprite1 ]>
<point towards( Mouse pointer )>
<move( 100 )steps>
<clear>
<stamp>
<end>[/blocks]

Close, but that would make it point, not rotate, right?

It would stay exactly 100 pixels away from the centre sprite closest to the mouse.
Like there's an circle with a radius of 100 around the center sprite that the moving sprite must stay on, but it trys to stay closest to the mouse.

I just realised floppy said this before, but this will make it less flashy.

Last edited by colorfusion (2011-02-13 16:18:13)

Offline

 

#13 2011-02-13 16:22:53

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

colorfusion wrote:

Kileymeister wrote:

colorfusion wrote:

<when green flag clicked>
<forever>
<go to[ Sprite1 ]>
<point towards( Mouse pointer )>
<move( 100 )steps>
<clear>
<stamp>
<end>[/blocks]

Close, but that would make it point, not rotate, right?

It would stay exactly 100 pixels away from the centre sprite closest to the mouse.
Like there's an circle with a radius of 100 around the center sprite that the moving sprite must stay on, but it trys to stay closest to the mouse.

I just realised floppy said this before, but this will make it less flashy.

Yes, but what I'm saying is it won't rotate, it will just immediately be where it needs to be in one frame, instead of slowly moving towards where it should be.


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#14 2011-02-13 17:05:02

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Kileymeister wrote:

colorfusion wrote:

Kileymeister wrote:


Close, but that would make it point, not rotate, right?

It would stay exactly 100 pixels away from the centre sprite closest to the mouse.
Like there's an circle with a radius of 100 around the center sprite that the moving sprite must stay on, but it trys to stay closest to the mouse.

I just realised floppy said this before, but this will make it less flashy.

Yes, but what I'm saying is it won't rotate, it will just immediately be where it needs to be in one frame, instead of slowly moving towards where it should be.

Actually, I described it incorrectly- I meant more of what colorfusion did (sorry). Still, I have one problem with colorfusion's- it clears the stage. What I'm looking to do requires the stage to be stamped and it can't be cleared. Could someone make something that looks exactly like colorfusion's but doesn't use stamp or clear?  smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#15 2011-02-13 17:08:21

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Sunrise-Moon wrote:

Kileymeister wrote:

colorfusion wrote:

It would stay exactly 100 pixels away from the centre sprite closest to the mouse.
Like there's an circle with a radius of 100 around the center sprite that the moving sprite must stay on, but it trys to stay closest to the mouse.

I just realised floppy said this before, but this will make it less flashy.

Yes, but what I'm saying is it won't rotate, it will just immediately be where it needs to be in one frame, instead of slowly moving towards where it should be.

Actually, I described it incorrectly- I meant more of what colorfusion did (sorry). Still, I have one problem with colorfusion's- it clears the stage. What I'm looking to do requires the stage to be stamped and it can't be cleared. Could someone make something that looks exactly like colorfusion's but doesn't use stamp or clear?  smile

Darn.

CURSE YOU, SIMPLICITY MAN!!!! *evil fist-shaking*

Just get rid of the stamp and clear and it should work the same.

Last edited by Kileymeister (2011-02-13 17:08:32)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#16 2011-02-13 17:16:21

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Make a sprite revolve around another sprite based on mouse?

Kileymeister wrote:

Sunrise-Moon wrote:

Kileymeister wrote:


Yes, but what I'm saying is it won't rotate, it will just immediately be where it needs to be in one frame, instead of slowly moving towards where it should be.

Actually, I described it incorrectly- I meant more of what colorfusion did (sorry). Still, I have one problem with colorfusion's- it clears the stage. What I'm looking to do requires the stage to be stamped and it can't be cleared. Could someone make something that looks exactly like colorfusion's but doesn't use stamp or clear?  smile

Darn.

CURSE YOU, SIMPLICITY MAN!!!! *evil fist-shaking*

Just get rid of the stamp and clear and it should work the same.

xD sorry. Works  big_smile . Thanks!  smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

Board footer