Program1031.comTM
Game Programming Help for Beginners!
Home Need Help? Start here!
Questions and Answers
Get Exclusive Stuff!
Email Newsletter

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


Answer:

Want to make a positive number negative? Here's how!

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

myDirection=5;

How do we make this negative? Remember, any number multiplied by 1 gives you the same number, and multiplying by any negative number gives you a negative number answer. So with that in mind, to make it negative, just multiply it by a negative 1. So just insert this 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 negative! Sweet! Try it in your own projects!

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

Game Making Tutorials
Find tutorials about your favorite game creation software! Use the navigation below!

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

Download Books
Search Downloadable Books from Program1031.com

Home Questions and Answers Email Newsletter
Watch our YouTube channel Read our Twitter feed
Content and Design © 2012-2023 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!

Our other websites: