Discuss Scratch

cheesytoasties
Scratcher
80 posts

Sprite Movement Cycle

Hi, It's me again…

I'm wondering how to make a basic movement cycle for my sprite! Now that I've gotten it to appear I need it to move a certain way.
I want my sprite to move from the top right side to the top left side, then turn and go the other way. Over and over again! I've gotten the first part down with the costumes and going from right to left but going back is the tricky part… See now when it gets to the left side I've placed a sprite out of sight so that when it touches that sprite it changes costume and starts moving back. But the old script moving it the opposite way is still running and it's not moving…

Hoping that made sense,
~Jamie

Me in a nutshell?

Pfft, I don't think I'd fit…
Plus I'm allergic.

Wait, that's not what you meant?
Oh okay,
mstone326
Scratcher
1000+ posts

Sprite Movement Cycle

Share the project so we can see what is going on. Otherwise all we can do is guess.

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
Sinaboo
Scratcher
100+ posts

Sprite Movement Cycle

Share your project? If I could see what your movement sprites looked liked I could help.

Wow that timing.

Last edited by Sinaboo (Nov. 9, 2018 19:10:33)

cheesytoasties
Scratcher
80 posts

Sprite Movement Cycle

Here it is!

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

Me in a nutshell?

Pfft, I don't think I'd fit…
Plus I'm allergic.

Wait, that's not what you meant?
Oh okay,
imfh
Scratcher
1000+ posts

Sprite Movement Cycle

Try using this with only one forever loop.

forever
move (2) steps
if on edge, bounce

Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
cheesytoasties
Scratcher
80 posts

Sprite Movement Cycle

Don't think that'll work. I'm needing it to go to the left then turn around and go to the right. The problems stopping the first script without stopping the rest of it

Me in a nutshell?

Pfft, I don't think I'd fit…
Plus I'm allergic.

Wait, that's not what you meant?
Oh okay,
cheesytoasties
Scratcher
80 posts

Sprite Movement Cycle

anything???

Me in a nutshell?

Pfft, I don't think I'd fit…
Plus I'm allergic.

Wait, that's not what you meant?
Oh okay,
mstone326
Scratcher
1000+ posts

Sprite Movement Cycle

I will look now. I looked quickly earlier after my class left the lab. I tried a dozen times to get past the clouds but couldn't and didn't have any more time.

Instead of change x for left and right movement. Use the point in direction block with a move block. Just remember under the green flag to put a set rotation style to left-right so your helicopter doesn't flip over.

Last edited by mstone326 (Nov. 9, 2018 23:36:14)


High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
Sinaboo
Scratcher
100+ posts

Sprite Movement Cycle

Instead of using switch costume to bee2 and move 2 steps you could set the rotation style to left-right and replace the switch costume with point in direction -90 and keep the move 2 steps.
imfh
Scratcher
1000+ posts

Sprite Movement Cycle

cheesytoasties wrote:

Don't think that'll work. I'm needing it to go to the left then turn around and go to the right. The problems stopping the first script without stopping the rest of it

I just tested it and it does work. The bounce block makes the bee point in a different direction so the move block moves in a different direction. Make sure to move forwards though, or else bounce won't work.

This script does what everyone has been saying up above.

when green flag clicked // This works, I tested it.
point in direction (90 v) // Start out pointing straight
go to x: (194) y: (151) // Go to the starting position
set rotation style [left-right v] // Flip the costume when rotating
switch costume to [bee2 v] // Bee facing to the right
show // Show the sprite
forever // Repeat forever
move (2) steps // Move in the direction the sprite is pointing
if on edge, bounce // Change direction if the sprite hits the edge
end

Last edited by imfh (Nov. 10, 2018 01:28:38)


Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
cheesytoasties
Scratcher
80 posts

Sprite Movement Cycle

Thank You!!! Got it finally working!

Me in a nutshell?

Pfft, I don't think I'd fit…
Plus I'm allergic.

Wait, that's not what you meant?
Oh okay,
Navy147
Scratcher
24 posts

Sprite Movement Cycle

its easy, this is how you make your sprite move (including the switching costume everytime you go the other way):
when [left] key pressed
forever
if <key [left] pressed?> then
move (-5) steps
switch costume to [the costume you want]
end


in the left block you have to dulplicate the costume you are using and flip it hortnizlly


when [right] key pressed
forever
if <key [right] pressed?> then
move (5) steps
switch costume to [switch it back to the original costume]
end


i hope it helps

Last edited by Navy147 (March 24, 2021 19:30:25)

Powered by DjangoBB