Scratch for Kids

A Watch the course on Frontend Masters

Finding Direction With Velocity

This is pretty easy if we’re just running left and right.

if <(x velocity) > [0]> then
	point in direction (90)
else
	point in direction (-90)
end

Okay, this involves a little bit of trigonometry, but let’s just pretend like we know what that is.

if <(y velocity) = [0]> then
	if <(x velocity) < [0]> then
		point in direction (90)
	else
		point in direction (-90)
	end
else
	if <(y velocity) < [0]> then
		point in direction ((180) + ([atan v] of ((x velocity) / (y velocity))))
	else
		point in direction ([atan v] of ((x velocity) / (y velocity)))
	end
end

If this stresses you out, you can copy the code from here.