Discuss Scratch

Haydonni
Scratcher
4 posts

Making a Number an Opposite

I've been trying to get a number an opposite for a scrolling platformer level but I don't know how to. Pls Help

Last edited by Haydonni (Aug. 24, 2019 00:06:03)

UnconstructivePoster
New Scratcher
100+ posts

Making a Number an Opposite

Are you trying to get the opposite of a number? In that case:

-numbernumber*-1

Last edited by UnconstructivePoster (Aug. 24, 2019 00:18:30)

hedgehog_blue
Scratcher
1000+ posts

Making a Number an Opposite

You can get the opposite of a number by subtracting it from 0

It looks like this in scratch blocks:
0-number

Why this works:
0 - number= -number ; if the number is positive it will be made negative, and if it is negative the two negatives will reduce to a positive. In both cases it is made the opposite.



Here are other ways of doing the same thing:
-1*numbermultiplying by 1 gives you the same number, so multiplying by negative 1 gives you the opposite
number/-1dividing by 1 gives you the same number, so dividing by negative 1 gives you the opposite
Haydonni
Scratcher
4 posts

Making a Number an Opposite

Thanks!
HyperEel
Scratcher
48 posts

Making a Number an Opposite

WOW! Thanks
deck26
Scratcher
1000+ posts

Making a Number an Opposite

HyperEel wrote:

WOW! Thanks
Please don't necropost just to say thanks.
catlover976
Scratcher
3 posts

Making a Number an Opposite

Thanks! (This can also help you with multiplayer scrolling platformer).
deck26
Scratcher
1000+ posts

Making a Number an Opposite

catlover976 wrote:

Thanks! (This can also help you with multiplayer scrolling platformer).
See post above yours. Please don't necropost!
Michael_Studios
Scratcher
3 posts

Making a Number an Opposite

very helpful thank you

Last edited by Michael_Studios (Sept. 7, 2022 21:02:47)

Spentine
Scratcher
1000+ posts

Making a Number an Opposite

Michael_Studios wrote:

very helpful thank you
See post above yours. Please don't necropost!

Powered by DjangoBB