Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to check in a variable is even or odd

This was asked in the genera help forum, so i figured other might want to know how to check if a variable is even or odd.

You may have figured it out, but here it is in the complete form.

Store your number to be checked for even or odd in Variable 0019
(or whatever, but we will use 0019 for demonstration)

use control vairables>mod>constant [2]

http://img215.imageshack.us/img215/5324/thingieob2.png[/img]

Then use a conditional branch.
If variable 0019 is equal to 0, then the number is even
Else, the number is odd.

http://img146.imageshack.us/img146/4118/thingiekh4.png[/img]

So your finished event will look like this!
http://img63.imageshack.us/img63/2314/thingieep5.png[/IMG]

Now store that in a common event and call it whenever you need to find if a variable is even or odd!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top