Mail Archives: djgpp/1997/07/21/10:10:29
I am working on an RPG computer game, and I was wondering if it is
possible to do the following:
#include <iostream.h>
const int WEAPON_SWORD_1 = 1;
const int WEAPON_SWORD_2 = 2;
int has_item(int a, int b)
{
if (a && b)
{
return 1;
}
else
{
return 0;
};
};
int main()
{
int a, b, c, d;
a = a || WEAPON_SWORD_1;
b = b || WEAPON_SWORD_2;
c = has_item(b, WEAPON_SWORD_1);
d = has_item(a, WEAPON_SWORD_2);
cout << d << " " << c;
return 0;
};
What I want has_item to do is see if the bit that is set in b is also
set in a. That way, I could use one variable to determine equipment on
the character. I also replaced all the int's with float's, but that
didn't work.
Any help is appreciated,
--
-Begin Signature-
Isaac Waldron <waldroni AT lr DOT net> N1YZI
http://www.geocities.com/SiliconValley/Lakes/5703/home.html
-End Signature-
- Raw text -