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

#1 2011-05-20 20:35:47

IglBado
New Scratcher
Registered: 2011-05-20
Posts: 8

Rotation with curve movement

Hi all!
     I'm Mano-Otz,but I lost my password (and email address) so I re-sign upped, now as Igl Bado. I'm working in "Matarratón v2.0", the 2nd version of Matarratón (have a look on it. It's quite poor, but it'll give you an idea of what I'm working on and my works' quality, although v1.0 is more than 2 years old).
              Once made the introduction, I go to the subject:
In Matarratón v2.0, you're a rat (yes, a rat!) with a heavy plasma gun, and you have to fight against a mouse (really, a mouse!) equipped with a light machine gun. I designed the bullet from the rat's gun to come from the rat (gun and rat are in the same sprite), but it came from the center of the sprite. As a solution, I created an "indicator sprite", a dot in the extreme of the gun of 3px X 3px so that the bullet came from the "hole" (sorry, I don't know th word in English).
    I also designed the rat to rotate 15 degrees clockwisely when pushing W + A or anti clockwisely when pushing Q + A. Since the rat & gun sprite is larger than the "indicator", both sprites rotate with the image center as pivot point: obviously, the little olive green dot gets not camouflaged anymore

I hope that you understood me (I hope), therefore I ask:
         How can I make the little dot move in a curved trajectory
     Thanks everybody.  smile

Offline

 

#2 2011-05-20 21:05:34

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

Re: Rotation with curve movement

The easiest way would be to change the center of the little dot's costume. To do that, open the costume in the costume editor and click the "+" button next to "Set costume center". You can then adjust the costume's center point to the center point of the rat's costume. Then just have the dot point in the same direction as the rat. It should stay in the right place now!


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

Offline

 

#3 2011-05-20 21:08:47

IglBado
New Scratcher
Registered: 2011-05-20
Posts: 8

Re: Rotation with curve movement

Indeed, you're a genius.  tongue  Thanks a lot.
     I will keep researching. Thanks again.  smile

Offline

 

#4 2011-05-20 21:14:26

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

Re: Rotation with curve movement

There's also an easy way of doing it like this:
http://i55.tinypic.com/1izmo9.gif
Now, the values for the turn block and move block are probably not correct (because I don't know exactly where the dot should be) but change them around until you find the right numbers.

Note:  If you use this method, then in the Scratch editor when you are not in presentation mode it will flash.  When shared online it will not flash, and when viewed in presentation mode it will not flash.


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-05-20 23:47:12

IglBado
New Scratcher
Registered: 2011-05-20
Posts: 8

Re: Rotation with curve movement

Thanks, I will check.

Offline

 

#6 2011-05-21 00:19:43

Reverberated3
Scratcher
Registered: 2011-02-24
Posts: 100+

Re: Rotation with curve movement

Another way to do it that is more complex uses trig:

Goto: X=xpositon(sin(direction of rat+15))+yposition(cos(direction of rat+15))
         Y=xposition(cos(direction of rat+15))+yposition(sin(direction of rat+15))

Where xposition is the x on the gun barrel/hole relative to the rat and same with the y.

If you want the sprite to move with it, just add the x position of the rat and the y position of the rat to these values.  With this equation, you can also just have the bullet go to this location instead of going to the sprite, which eliminates the sprite.


http://i53.tinypic.com/2zs0bah.jpghttp://i51.tinypic.com/30jtrbl.jpg

Offline

 

#7 2011-05-25 14:17:00

IglBado
New Scratcher
Registered: 2011-05-20
Posts: 8

Re: Rotation with curve movement

↑Didn't help.  sad
Anyway, I already quited the indicator.
  However, thank you. I still have (or must?) read that book: "Trigonometry and Scratch".  wink

Offline

 

Board footer