Discuss Scratch

DordusRising
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

I want to make it where Sonic increases speed when the arrow keys/directional buttons for mobile are pressed to make him go forward. Can someone give me a script for it? Thanks in advance.
jdmdigital
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

Do you have a speed variable?

Im not familiar with the mobile arrow keys. Id made a sprite for arrow buttons then code them to work off a speed varible. Are you familiar that?
shantipepsi
Scratcher
20 posts

How to make the Sonic Speed Mechanic

DordusRising wrote:

I want to make it where Sonic increases speed when the arrow keys/directional buttons for mobile are pressed to make him go forward. Can someone give me a script for it? Thanks in advance.

hello, I think I have a solution to your speed problem:
forever
if <key [ right v] pressed?> then
change [speed x v] by (1,45)
set x to (speed x)
end
endwhen green flag clicked
The_Imaginarium
Scratcher
1000+ posts

How to make the Sonic Speed Mechanic

You can simulate acceleration like so:
define move (speed) (friction)
if <key [right v] pressed?> then
change [P_X SPEED v] by (speed) // I recommend 2 or 3 in this input
end
if <key [left v] pressed?> then
change [P_X SPEED v] by ((speed)*(-1)) // see above
end
set [P_X SPEED v] to ((P_X SPEED)*(friction)) // I recommend 0.8 in this input
change x by (P_X SPEED)
DordusRising
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

jdmdigital wrote:

Do you have a speed variable?

Im not familiar with the mobile arrow keys. Id made a sprite for arrow buttons then code them to work off a speed varible. Are you familiar that?
I know how to code mobile controls (I just set whatever direction it is to true when the sprite is touching the pointer), but I just need the speed mechanic from the classic Sonic games. As to how they work off of a speed variable themselves, I don’t know ho that would work. Can you show me?
DordusRising
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

The_Imaginarium wrote:

You can simulate acceleration like so:
define move (speed) (friction)
if <key [right v] pressed?> then
change [P_X SPEED v] by (speed) // I recommend 2 or 3 in this input
end
if <key [left v] pressed?> then
change [P_X SPEED v] by ((speed)*(-1)) // see above
end
set [P_X SPEED v] to ((P_X SPEED)*(friction)) // I recommend 0.8 in this input
change x by (P_X SPEED)
Thank you! I’ll try that.
jdmdigital
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

DordusRising,

I see your reply and I see The_Imaginarium has provided a solution. HOpe it works out for you. I'll monitor in case other issues pop up. I look forward to your getting this one done so I can learn the mobile stufff from it.
DordusRising
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

jdmdigital wrote:

DordusRising,

I see your reply and I see The_Imaginarium has provided a solution. HOpe it works out for you. I'll monitor in case other issues pop up. I look forward to your getting this one done so I can learn the mobile stufff from it.
You can learn mobile controls with my tutorial (I will provide a link soon)
DordusRising
Scratcher
100+ posts

How to make the Sonic Speed Mechanic

Powered by DjangoBB