Discuss Scratch

Lewis_loves_cars
Scratcher
42 posts

How do I make a 2d car go fluently?

I am trying to update a racing game called “Scratch Kart”. In that update,I want the car to go more fluently. For example, it won't let me turn and go at the same time. Like how the car moves in SuperKart. If you help me with this, I WILL thank you in the notes and credits.

If you don't know exactly what I mean, see that project with the link below:

https://scratch.mit.edu/projects/64263996
—————————————————————————————————-
If that dosen't work, then search in the scratch search box “Scratch Kart” or go to my account and find it under shared projects.



Sincerely, Lewis_loves_cars

Last edited by Lewis_loves_cars (June 10, 2015 01:31:38)

Dylanica
Scratcher
54 posts

How do I make a 2d car go fluently?

Using the setup you have currently is usually bad practice.
It is better to do something like this:
when green flag clicked
forever

if <key [Up Arrow v] pressed?> then

move (5) steps
end

end

when green flag clicked
forever

if <key [Right Arrow v] pressed?> then

turn cw (5) degrees
end

end

when green flag clicked
forever

if <key [Left Arrow v] pressed?> then

turn ccw (5) degrees
end

If you wanted to know about how to make it move even more smoothly then look at this: https://scratch.mit.edu/projects/32304890/
Dylanica
Scratcher
54 posts

How do I make a 2d car go fluently?

Also tip:
The center of rotation for your cars are outside of the sprites, which makes it rotate strangely:
(Image) http://i.imgur.com/3Vsb6p6.png

To fix this, click the “cross” icon it the top right corner of the screen:

(Image) http://i.imgur.com/5f76kU9.png

Then click the center of your car.
Lewis_loves_cars
Scratcher
42 posts

How do I make a 2d car go fluently?

Thanks, Dylanica. I will try to use that in the car game. If it works, I will thank you in the notes and credits. I will also send you a message if it works. (message in this topic)



Thanks a lot. You are really helpful.
Lewis_loves_cars
Scratcher
42 posts

How do I make a 2d car go fluently?


Dear Dylanica, You have helped me a lot. When I tested the game, I have seen many improvements in my game. Thanks. I have added you in the notes and credits.

Here's the link to my game:

https://scratch.mit.edu/projects/64263996
-Scratcher-
Scratcher
100+ posts

How do I make a 2d car go fluently?

Make sure to center the costumes, so the turning point is correct.

You can also use variables to simulate real motion (I recommend to make the sprites a bit smaller for that or maybe you can make a scroller out of it):
when green flag clicked
set [velocity v] to [0]
set [turning v] to [0]
go to x: (0) y: (0)
point in direction (0 v)
forever
if <key [up arrow v] pressed?> then
if <(velocity) < [40]> then //maximum speed
change [velocity v] by (1) //acceleration
end
else
if <key [down arrow v] pressed?> then
if <(velocity) > [0]> then
change [velocity v] by (-4) //breaks strength
else
if <(velocity) > [-10]> then //maximum speed for backwards driving
change [velocity v] by (-2) //backwards acceleration
end
end
else
change [velocity v] by (-0.2) //neutral slowdown
end
end
if <key [left arrow v] pressed?> then
change [turning v] by (-5)
end
if <key [right arrow v] pressed?> then
change [turning v] by (5)
end
if <<(velocity) > [0]> and <(turning) > (velocity)>> then
set [turning v] to (velocity)
end
if <<(velocity) < [0]> and <(turning) < (velocity)>> then
set [turning v] to (velocity)
end
turn cw (turning) degrees
move (velocity) steps
end

I'm not sure the turning thing works correctly, but you can play around a bit with the script
Lewis_loves_cars
Scratcher
42 posts

How do I make a 2d car go fluently?

No thanks. I had enough to edit my racing game. Now its time to work on my grocery cart race project.

By the way, did you view my racing game?
-Scratcher-
Scratcher
100+ posts

How do I make a 2d car go fluently?

Lewis_loves_cars wrote:

When I tested the game, I have seen many improvements in my game.
That's what you said, sounded like you're not done with it. I just wanted to help
But if you want to show your project, please use the Show and Tell Forums instead.
FlareIceStudios
New Scratcher
1 post

How do I make a 2d car go fluently?

when green flag clicked
if <> then

end

Last edited by FlareIceStudios (June 20, 2017 01:12:33)

gtoal
Scratcher
1000+ posts

How do I make a 2d car go fluently?

Dylanica wrote:

Also tip:
The center of rotation for your cars are outside of the sprites, which makes it rotate strangely:

Unless you're making a Tokyo Drift style game, in which case you should make the sprite origin be the center of the front axle, so that the back of the vehicle swings round to match.

Example: https://scratch.mit.edu/projects/92539698/

Last edited by gtoal (June 20, 2017 01:33:45)

St26O_KI886
New Scratcher
5 posts

How do I make a 2d car go fluently?

when i do this my car does donuts
theanonymousweirdo
Scratcher
500+ posts

How do I make a 2d car go fluently?

Please don't necropost
NASCAR_RACING
Scratcher
5 posts

How do I make a 2d car go fluently?

I do not know

Powered by DjangoBB