Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Sonic Galaxy! (Help with Scripts) Plz
- MinecraftParty77
-
100+ posts
Sonic Galaxy! (Help with Scripts) Plz
Hey guys. So im trying to make a sonic game, but im having trouble with making sonic run and jump at the same time Perfectly like in the game.
Here is what i have to far, maybe you can help?
http://scratch.mit.edu/projects/10183421/ <– Sonic Running Test 3
Here is what i have to far, maybe you can help?
http://scratch.mit.edu/projects/10183421/ <– Sonic Running Test 3

- ErnieParke
-
1000+ posts
Sonic Galaxy! (Help with Scripts) Plz
The reason why Sonic couldn't jump and move left/right at the same time was because your jump script involved two repeats, which “blocked” your code from letting Sonic move left/right. If you separate the movement script into two like this, then everything should be good.
I hope that this helps!
With regards,
ErnieParke
when gf clickedJust to say, after you do this, you might want to work on Sonic's jumping animation when he's also moving left/right.
if <key [right arrow v] pressed?>
change x by (4)
end
if <key [left arrow v] pressed?>
change x by (-4)
end
when gf clicked
Every other script…
I hope that this helps!
With regards,
ErnieParke
- andre_rifaut
-
100+ posts
Sonic Galaxy! (Help with Scripts) Plz
You a have list of tests.
But some tests are true before others.
For instance, you test the “one key” case (either left, right, up) before two simultaneous keys. So you catch always one key before two keys.
You should do it the other way: test two simultaneous keys before one key.
This is the general problem of tests.
However this will not solve your problem of keys because it seems that scratch does not allow to test for two simultaneous keys.
So there is a recent question about this problem and there is a solution in How Do You Jump And Move At The Same Time??? At the bottom there is a reference to a project (not mine).
See the red house code in http://scratch.mit.edu/projects/10175226
This is an application of the idea presented in http://scratch.mit.edu/projects/10170032/
But some tests are true before others.
For instance, you test the “one key” case (either left, right, up) before two simultaneous keys. So you catch always one key before two keys.
You should do it the other way: test two simultaneous keys before one key.
This is the general problem of tests.
However this will not solve your problem of keys because it seems that scratch does not allow to test for two simultaneous keys.
So there is a recent question about this problem and there is a solution in How Do You Jump And Move At The Same Time??? At the bottom there is a reference to a project (not mine).
See the red house code in http://scratch.mit.edu/projects/10175226
This is an application of the idea presented in http://scratch.mit.edu/projects/10170032/
Last edited by andre_rifaut (May 12, 2013 19:54:47)
- MinecraftParty77
-
100+ posts
Sonic Galaxy! (Help with Scripts) Plz
The reason why Sonic couldn't jump and move left/right at the same time was because your jump script involved two repeats, which “blocked” your code from letting Sonic move left/right. If you separate the movement script into two like this, then everything should be good.when gf clickedJust to say, after you do this, you might want to work on Sonic's jumping animation when he's also moving left/right.
if <key [right arrow v] pressed?>
change x by (4)
end
if <key [left arrow v] pressed?>
change x by (-4)
end
when gf clicked
Every other script…
I hope that this helps!
With regards,
ErnieParke
Alright ill try it!

Last edited by MinecraftParty77 (May 12, 2013 22:33:37)
- MinecraftParty77
-
100+ posts
Sonic Galaxy! (Help with Scripts) Plz
The reason why Sonic couldn't jump and move left/right at the same time was because your jump script involved two repeats, which “blocked” your code from letting Sonic move left/right. If you separate the movement script into two like this, then everything should be good.when gf clickedJust to say, after you do this, you might want to work on Sonic's jumping animation when he's also moving left/right.
if <key [right arrow v] pressed?>
change x by (4)
end
if <key [left arrow v] pressed?>
change x by (-4)
end
when gf clicked
Every other script…
I hope that this helps!
With regards,
ErnieParke
OH MY GOD THANK YOU SO MUCH!




- ErnieParke
-
1000+ posts
Sonic Galaxy! (Help with Scripts) Plz
Well, it's nothing.The reason why Sonic couldn't jump and move left/right at the same time was because your jump script involved two repeats, which “blocked” your code from letting Sonic move left/right. If you separate the movement script into two like this, then everything should be good.when gf clickedJust to say, after you do this, you might want to work on Sonic's jumping animation when he's also moving left/right.
if <key [right arrow v] pressed?>
change x by (4)
end
if <key [left arrow v] pressed?>
change x by (-4)
end
when gf clicked
Every other script…
I hope that this helps!
With regards,
ErnieParke
OH MY GOD THANK YOU SO MUCH!![]()
![]()
![]()

By the way, good luck with your project!
With regards,
ErnieParke
- MinecraftParty77
-
100+ posts
Sonic Galaxy! (Help with Scripts) Plz
Well, it's nothing.The reason why Sonic couldn't jump and move left/right at the same time was because your jump script involved two repeats, which “blocked” your code from letting Sonic move left/right. If you separate the movement script into two like this, then everything should be good.when gf clickedJust to say, after you do this, you might want to work on Sonic's jumping animation when he's also moving left/right.
if <key [right arrow v] pressed?>
change x by (4)
end
if <key [left arrow v] pressed?>
change x by (-4)
end
when gf clicked
Every other script…
I hope that this helps!
With regards,
ErnieParke
OH MY GOD THANK YOU SO MUCH!![]()
![]()
![]()
By the way, good luck with your project!
With regards,
ErnieParke
Its beyond better. Check it out. (now im having problems with the boss >_<)
- Great_Games123
-
6 posts
Sonic Galaxy! (Help with Scripts) Plz
__________________________________________________________________________________________________
if this was helpful consider checking out my projects
- Discussion Forums
- » Help with Scripts
-
» Sonic Galaxy! (Help with Scripts) Plz