Program1031.comTM
Game Programming Help for Beginners!
Home Questions and Answers Physical and Digital Books

Question:
How do I Make a Negative Number Positive in Game Maker?


Answer:

In an earlier question, we talked about how to make positive numbers negative. Well how do you make a negative number positive? Do the same thing as before!

Let's say we want to make a variable positive. Our variable is called myDirection and it equals -5:

myDirection=-5;

Any number multiplied by 1 gives you the same number, and multiplying a negative number by a negative number gives you a positive number! So here's the code:

myDirection=myDirection*-1;

This code multiplies the value of myDirection by -1, and then puts the answer back in the myDirection variable. Now myDirection is positive! Nice!

Page updated: March 23rd, 2015 @ 6:21 AM Eastern Time

Game Maker: Studio
Help, References, and Tutorials
RPG Maker Fes
Help, References, and Tutorials
smileBASIC
Help, References, and Tutorials

Physical and Digital Books
Search Physical and Digital Books at Program1031.com

Home Questions and Answers Email Newsletter
Watch our YouTube channel
Content and Design © 2012-2025 Program1031.com. All Rights Reserved. | Privacy Policy | Terms of Service
All Copyrights and Trademarks of mentioned products are copyrights and trademarks of their respective owners.

As an Amazon Associate and ChristianBook.com Affiliate, Breakthrough Gaming LLC earns a commission on qualifying purchases from Amazon.com and ChristianBook.com through our website. Thank you for your purchases!