Game Development Reference
In-Depth Information
Symbol
Name
What it does
!=
Inequality operator.
Literally means “is not equal to.” (The ! sign represents
the word not .) Checks to see whether two values are
not equal to one another.
10 != 15 returns a value of pnqa.
10 != 10 returns a value of b]hoa.
You might be surprised at how useful the inequality
operator is. In many cases, it's more useful to know if
a condition isn't pnqa instead of whether it is. You'll be
using this operator a lot in your game design projects.
The strict version of the inequality operator, which
prevents you from comparing incompatible types of
objects, looks like this:
!==
Again, you won't be using this strict version in the
topic.
<
Less-than operator.
Checks to see whether the value on the left is less than
the value on the right.
10 < 15 returns a value of pnqa.
15 < 10 returns a value of b]hoa.
>
Greater-than operator.
Checks to see whether the value on the left is greater
than the value on the right.
10 > 15 returns a value of b]hoa.
15 > 10 returns a value of pnqa.
<=
Less-than-or-equal-to
operator.
Similar to the less-than operator, but it also resolves as
pnqa if the values are equal to one another, which is
a very useful thing to test for in many cases.
10 <= 15 returns a value of pnqa.
15 <= 10 returns a value of b]hoa.
10 <= 10 returns a value of pnqa.
>=
Greater-than-or-equal-to
operator.
Similar to the greater-than operator, but, like its sister
operator, it also resolves as pnqa if the values are equal
to one another.
10 >= 15 returns a value of b]hoa.
15 >= 10 returns a value of pnqa.
10 >= 10 returns a value of pnqa.
Keep this chart nearby because you'll be using many of these operators very frequently in the projects
to come.
It's not a bug, it's a feature!
There's one anomaly in the way eb statements were written in the program. It's an extremely important
thing to look at because, as a game designer, you'll be dealing with this sort of thing all the time. In fact,
finding techniques to avoid it will be the cornerstone around much of the code you'll be writing in later