Mail Archives: djgpp/1997/07/25/14:36:30
Isaac Waldron <waldroni AT lr DOT net> wrote in article <33D36DA3 DOT 7EB2 AT lr DOT net>...
> I am working on an RPG computer game, and I was wondering if it is
> possible to do the following:
Yes it's possible, and you're almost there. Your problem is a common one:
confusion of logical AND/OR (&&/||) operators with bitwise AND/OR (&/|).
Make these changes to your program:
[snip]
> int has_item(int a, int b)
> {
> if (a & b) // Changed '&&' to '&'
[snip]
> a = a | WEAPON_SWORD_1; // Changed '||' to '|'
> b = b | WEAPON_SWORD_2; // Changed '||' to '|'
That should do it.
--
John Bodfish
bodfish AT als DOT ameritech DOT com
- Raw text -