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

#1 2012-12-22 20:35:22

Usmanproductions
Scratcher
Registered: 2009-11-26
Posts: 11

Mouse Pointer

Hey everyone!

So I'm trying to make a game where you use your mouse to guide a little dot to the end and the dot follows your mouse. Right now, it follows directly wherever my mouse goes and I don't really want that. I want it so that when you move your mouse, the dot slowly approaches it. If your mouse is very far away from the dot, then the dot will go to it quickly and slow down when it comes near to it. I've tried making variables to like reduce the speed but it just doesn't work.

Also, I want to put a little pen tool on the dot. It's pretty simple. It has to last for 2 seconds of the mouse moving and the closer the pen marks are to the dot, the brighter they are (red). Can someone please help me out? Thanks.

Offline

 

#2 2012-12-22 20:43:23

Blayer98
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: Mouse Pointer

I doubt this would work sorry.


http://i50.tinypic.com/16lwmlj.png
The first Collab to have it's very own Cloud Variables! Coming Soon!

Offline

 

#3 2012-12-22 21:34:25

Usmanproductions
Scratcher
Registered: 2009-11-26
Posts: 11

Re: Mouse Pointer

How come?  sad

Offline

 

#4 2012-12-22 21:45:50

Secretmapper
New Scratcher
Registered: 2012-12-10
Posts: 27

Re: Mouse Pointer

Actually , this would work. The effect you're searching for is called "easing" i am using a mobile phone right now so I cant provide explicit details, but please go ahead and look at the project I made. It contains such effect. Just download it.

Also be nice if you can comment on it(the project I mean)

Offline

 

#5 2012-12-22 22:14:21

Usmanproductions
Scratcher
Registered: 2009-11-26
Posts: 11

Re: Mouse Pointer

Thanks so much Secretmapper!!!

Now all I need is the pen thing, but I don't think it's that important.

Offline

 

#6 2012-12-23 03:41:13

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Mouse Pointer

You can try this

when gf clicked
forever
repeat until <touching [mouse pointer v]?>
point towards [mouse pointer v]
move [1] steps//you can replace the 1 with a bigger number to make it go faster.
end


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

#7 2012-12-23 04:52:33

Secretmapper
New Scratcher
Registered: 2012-12-10
Posts: 27

Re: Mouse Pointer

He wants to ease it, not simply have the dot follow the mouse, Ideas

Offline

 

#8 2012-12-23 04:56:53

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Mouse Pointer

Velocities, you mean? So the nearer the dot is to the mouse, it goes slower?


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#9 2012-12-23 08:59:26

Smice
Scratcher
Registered: 2012-12-12
Posts: 24

Re: Mouse Pointer

This sounds kinda interesting I'll try doing this  big_smile
I'll tell you what results I got from this

Offline

 

#10 2012-12-23 09:06:13

Secretmapper
New Scratcher
Registered: 2012-12-10
Posts: 27

Re: Mouse Pointer

Can someone tell a mod to close this or do we leave threads like this open here? The OP had already managed to achieve what he was planning to do (of course, there's that pen, but still...)

Offline

 

#11 2012-12-23 09:35:03

Smice
Scratcher
Registered: 2012-12-12
Posts: 24

Re: Mouse Pointer

Okay.
First thing first.
The dot thing is relatively simple.

When gf clicked
forever
 glide (0.5) secs to x: (mouse x) y: (mouse y) //You can set how fast it detects the new coords by tweeking the secs
wait (0.2) secs //If you want a slight pause between the detection
end
Please forgive me if the code doesn't show up D:
First time using scratch blocks.

The speed up/slow down thing can be solved by velocity.
forever
 if <(distance) < 30> // If the distance is under 30 then you'll speed up
   set <velocity v> to (3)
 else
   set <velocity v> to (1)
I have no idea how to use the pen tool. So I can't help you in that aspect D:
Sorry

Last edited by Paddle2See (2012-12-23 09:52:02)

Offline

 

#12 2012-12-23 11:34:13

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: Mouse Pointer

Okay, so for the dot following the mouse like you described:

when gf clicked
forever
point towards [mouse-pointer v]
move ((distance to [mouse-pointer v]) / (any amount)) steps
You can replace the (any amount) variable with any number. The larger the number, the slower it goes near to the mouse-pointer.

Also, you want the pen to happen just for 2 seconds? Okay... Stick this segment whenever you want that to happen:
set pen color to [#FF0000]
reset timer
pen down
repeat until <(timer) = (2)>
set pen shade to ((200) - (distance to [mouse-pointer v]))
end
pen up
Hope this helps with your project!  big_smile

Last edited by powerpoint56 (2012-12-23 11:35:27)


http://i48.tinypic.com/2072ctw.gif

Offline

 

#13 2012-12-27 04:35:17

Aditya007
Scratcher
Registered: 2012-11-27
Posts: 63

Re: Mouse Pointer

Aditya007 wrote:

You can do this

when gf clicked
forever
   point towards [mouse pointer]
   move (distance) steps
   if <(distance to [mouse pointer v]) > [30]>
        set (distance) to 5  
   else
        set (distance) to 2
   end


Wolf_OS!!!  smile  Check My Stuff  tongue  Need Help?  Currently, I am http://blocks.scratchr.org/API.php?user=Aditya007&amp;action=onlineStatus&amp;type=square
http://i49.tinypic.com/15gy1j6.jpg

Offline

 

#14 2012-12-27 10:00:26

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Mouse Pointer

Ideas wrote:

You can try this

when gf clicked
forever
repeat until <touching [mouse pointer v]?>
point towards [mouse pointer v]
move [1] steps//you can replace the 1 with a bigger number to make it go faster.
end

This is the best solution posted so far. Could be improved a little checking the distance to the mouse pointer - otherwise it might jerk when touching the mouse:

when gf clicked
set [speed v] to [5]
forever
 if <(distance to [mouse pointer v]) > [10]>
 point towards [mouse pointer v]
 move (speed) steps
 end
end


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#15 2012-12-27 10:07:55

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

Re: Mouse Pointer

I know you've already been helped, but I can't help but throw in my spin on the coding,   which would look something like:
http://i49.tinypic.com/35mjz9z.gif

The advantages of this one aside from powerpoint's (which would also work very well) is that you can use your direction value for something else at the same time.  Maybe make the dot spin as a cosmetic effect?  I don't know.

Changing the .2 in each of the blocks with those to a smaller number, like .1, would slow down the motion, while making it larger would increase the motion.

Last edited by Kileymeister_test (2012-12-27 10:10:14)


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

Offline

 

#16 2012-12-31 11:30:54

minecraftpe123
Scratcher
Registered: 2012-11-18
Posts: 100

Re: Mouse Pointer

Usmanproductions wrote:

Hey everyone!

So I'm trying to make a game where you use your mouse to guide a little dot to the end and the dot follows your mouse. Right now, it follows directly wherever my mouse goes and I don't really want that. I want it so that when you move your mouse, the dot slowly approaches it. If your mouse is very far away from the dot, then the dot will go to it quickly and slow down when it comes near to it. I've tried making variables to like reduce the speed but it just doesn't work.

Also, I want to put a little pen tool on the dot. It's pretty simple. It has to last for 2 seconds of the mouse moving and the closer the pen marks are to the dot, the brighter they are (red). Can someone please help me out? Thanks.

Make it so the sprite points in the direction of the mouse pointer then make it move at a slow speed.

Hope this helped,
                         MINECARFTPE123

Offline

 

#17 2012-12-31 15:21:23

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

Re: Mouse Pointer

I made a project Here which solves your problems


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&amp;user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

Board footer