Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with movement along path using Move () Steps
- uniprotbot2022
-
New Scratcher
6 posts
Help with movement along path using Move () Steps
Hello,
I'm making a game in which the sprite starts moving across the screen as soon as the game starts using “move () steps”, and the player can increase or decrease the variable speed using toggle buttons (toggling between states).
In one of the levels the sprite moves across a rugged mountain terrain and I can't seem to work out a way to move the sprite across the constantly changing (in regards to X and y) terrain while keeping to the speed and moving. I was thinking something like the glide block but with move so: move (speed) steps to x: (0) y: (0)
I've tried various custom blocks and tutorials but I can't seem to get it to work. I'd appreciate any help you can give me.
Here is a very simplified version of the game with the bit of code I'm having problems with - the purple line sprite represents the mountain: https://scratch.mit.edu/projects/802629423
Thanks in advance
I'm making a game in which the sprite starts moving across the screen as soon as the game starts using “move () steps”, and the player can increase or decrease the variable speed using toggle buttons (toggling between states).
In one of the levels the sprite moves across a rugged mountain terrain and I can't seem to work out a way to move the sprite across the constantly changing (in regards to X and y) terrain while keeping to the speed and moving. I was thinking something like the glide block but with move so: move (speed) steps to x: (0) y: (0)
I've tried various custom blocks and tutorials but I can't seem to get it to work. I'd appreciate any help you can give me.
Here is a very simplified version of the game with the bit of code I'm having problems with - the purple line sprite represents the mountain: https://scratch.mit.edu/projects/802629423
Thanks in advance
- medians
-
Scratcher
1000+ posts
Help with movement along path using Move () Steps
Is it supposed to rotate?
- ItBeJC
-
Scratcher
1000+ posts
Help with movement along path using Move () Steps
Is it supposed to rotate?Yes
- medians
-
Scratcher
1000+ posts
Help with movement along path using Move () Steps
Then probably find some way to indicate the bumps so when the sprite touches it, then it moves up.Is it supposed to rotate?Yes
- Axelsaurio2011
-
Scratcher
23 posts
Help with movement along path using Move () Steps
Maybe instead of using an move () steps blocks, you can try using a custom block that detects if scratch is NOT touching the path, it will go back, turn counter-clockwise and move 10 steps again until it IS touching it (and also not going backwards), something like this:
define MoveBe aware that this custom block can have problems with paths that go up or to the left, so be careful.
move (10) steps
if <not <touching [path v] ?>> then
repeat until <<touching [path v] ?> and <(direction) > [0]>>
move (-10) steps
turn ccw (1) degrees
move (10) steps
end
end
- uniprotbot2022
-
New Scratcher
6 posts
Help with movement along path using Move () Steps
Hello, thank you to everyone for your help and suggestions, and thank you ItBeJc for trying to fix the game.
I should have clarified that the sprite doesn't rotate because it's supposed to be a take on the mechanical horse racing games you get in carnivals where they're attached to a rod and constantly moves forward across the playing area from left to right. So in each level the sprite moves from left to right keeping it's rotation at 90 but or course moving up and down in the mountain level
I should have clarified that the sprite doesn't rotate because it's supposed to be a take on the mechanical horse racing games you get in carnivals where they're attached to a rod and constantly moves forward across the playing area from left to right. So in each level the sprite moves from left to right keeping it's rotation at 90 but or course moving up and down in the mountain level
- ItBeJC
-
Scratcher
1000+ posts
Help with movement along path using Move () Steps
Hello, thank you to everyone for your help and suggestions, and thank you ItBeJc for trying to fix the game.Oh, I think I get it. There's a rod sticking out from under the character, and you want the character to go up and down on the rod, but not rotate. So it would be sort of like a merry go round?
I should have clarified that the sprite doesn't rotate because it's supposed to be a take on the mechanical horse racing games you get in carnivals where they're attached to a rod and constantly moves forward across the playing area from left to right. So in each level the sprite moves from left to right keeping it's rotation at 90 but or course moving up and down in the mountain level
- uniprotbot2022
-
New Scratcher
6 posts
Help with movement along path using Move () Steps
Sort of, in some levels they move left to right without changing the y axis but in the mountain level they do go up and down while moving left to right.
I think I've managed to work out how to use glide block but with the speed variable thanks to this discussion (https://scratch.mit.edu/discuss/topic/562641/).
I've updated the game (https://scratch.mit.edu/projects/802629423) and it moves along the mountain path at the initial set speed, but if I try to boost the speed it doesn't increase the speed variable. I'm not sure why this might be?
I think I've managed to work out how to use glide block but with the speed variable thanks to this discussion (https://scratch.mit.edu/discuss/topic/562641/).
I've updated the game (https://scratch.mit.edu/projects/802629423) and it moves along the mountain path at the initial set speed, but if I try to boost the speed it doesn't increase the speed variable. I'm not sure why this might be?
- Discussion Forums
- » Help with Scripts
-
» Help with movement along path using Move () Steps



