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

#1 2010-07-16 17:29:00

happyman2234
New Scratcher
Registered: 2010-07-16
Posts: 4

Moving sight

My sprite follows the mouse, but also at the same time it would be moving. if you've ever played call of duty and you've used a sniper, you'll know that the sniper scope always move around. so is there any way to make my cursor move all over, possibly in a path. around the mouse, but also still follow the mouse

Offline

 

#2 2010-07-16 17:45:40

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Moving sight

Offline

 

#3 2010-07-16 18:07:06

happyman2234
New Scratcher
Registered: 2010-07-16
Posts: 4

Re: Moving sight

that helps yes...but i'm not sure how to make it for a one dot? one big dot....

Offline

 

#4 2010-07-16 20:49:27

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Moving sight

set mouseX to the mouse's X position, mouseY to the Y
Then set the cursor to MouseX + random -2 to 2 (adjust for amount of wobble)
and obviously set cursor Y to Mouse Y + random -2 to 2

thus you could simulate strong wind blowing the barrel, an explosion nearby shaking the scope like crazy, a heavily wounded soldier having a tendancy to droop the barrel, I dunno, all kinds of stuff. You could also make it so when you moved and then stopped the scope, it bobbles a little before it mostly settles down. Lower level players have shakier scopes.. ok, I'm rambling. Oh yeah, you could make it so that once it has 'wobbled so far away from it's original position, it stops drifting.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#5 2010-07-17 08:12:24

happyman2234
New Scratcher
Registered: 2010-07-16
Posts: 4

Re: Moving sight

thats really good but is there any way to slow it down?

Offline

 

#6 2010-07-17 09:06:21

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Moving sight

I didn't write the script, but I think you could just put a <wait(0.1 )secsc> at the end of the script (at the bottom of the forever block.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#7 2010-07-17 09:07:57

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Moving sight

MoreGamesNow wrote:

I didn't write the script, but I think you could just put a <wait(0.1 )secsc>[/blocks] at the end of the script (at the bottom of the forever block.

I'm not sure that would do anything... If anything, it would slow it down.

Offline

 

#8 2010-07-17 09:25:46

happyman2234
New Scratcher
Registered: 2010-07-16
Posts: 4

Re: Moving sight

i've put on wait 0.1 but basicly it makes it look laggy, it jumps one spot to the other

Offline

 

#9 2010-07-17 12:54:10

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Moving sight

Don't make it jump all the way by go to mouse. Set the direction towards the mouse, save the distance as a variable then only move a percentage of that variable. You may want to encase that move inside an "if distance (from target spot) > than (some small number)"

That number will be how close it has to be before it quits only going part of the distance.
Hope this makes sense, I'm just thinking off the top of my head lol.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#10 2010-07-18 13:38:39

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Moving sight

It depends on how complex you wanted to get. You could make a pretty complicated script that included velocity, movement of the scope based on mouse movement, etc.

For example, based on what some others have said, you could have the scope lag behind the cursor, and then overshoot a bit, and bobble back and forth slower and slower. (Just a thought)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer