Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!cuae2!ihnp4!inuxc!pur-ee!j.cc.purdue.edu!i.cc.purdue.edu!aig From: aig@i.cc.purdue.edu (Doug Crabill) Newsgroups: comp.sys.cbm Subject: C-Power bug ??? Message-ID: <1688@i.cc.purdue.edu> Date: Sun, 7-Dec-86 21:03:30 EST Article-I.D.: i.1688 Posted: Sun Dec 7 21:03:30 1986 Date-Received: Mon, 8-Dec-86 05:39:07 EST Distribution: net Organization: Unidue Purversity Lines: 53 Keywords: C-Power, bug I am writing a game in C-Power (please hold all applause until the end of the article) and have run into a bit of a problem. I can't be sure if it is a problem with the way I have the code set up or if it is a problem with C-Power. I figured I would post what I have in hopes that some kind soul out there could spot a problem. I know there are other ways to write this bit of code, but I really want to know why it doesn't work as it is. --------------------------------This is it------------------------------------- /* This program checks joyport 1 and updates a sprite on the screen according to the direction of the joystick. Real simple right? */ #include main() { struct tank { char *x; /* x coordinate */ char *y; /* y coordinate */ float a; /* doesn't matter here */ char *sp; /* sprite image pointer */ }; char *joy1; /* joyport location */ char j; /* temporary copy of *joy1 */ char *enable; /* sprite enable location */ struct tank *pl1; /* the sprite used in this program */ pl1->x = 53248; *pl1->x = 30; pl1->y = 53249; *pl1->y = 100; pl1->a = 0.0; pl1->sp = 2040; *pl1->sp = 192; /* set the sprite pointer */ joy1 = 56320; /* set joyport location */ enable = 53269; /* set sprite enable location */ *enable = 1; /* enable sprite 1 */ /* set up an infinite game loop */ for (;;) { /* what happens here is that the sprite will not move unless the joystick is pushed up (the first case) and when this happens, ALL of the ifs below are executed, so the sprite goes up, down, left, right (sounds like aerobics eh?) I've printed out j as I go and it is as it should be. */ j = 15 - (*joy & 15); if ((j&1 == 1) && ((*pl1->y) > 50)) (*pl1->y)--; /* up */ if ((j&2 == 2) && ((*pl1->y) < 226)) (*pl1->y)++; /* down */ if ((j&4 == 4) && ((*pl1->x) > 24)) (*pl1->x)--; /* left */ if ((j&8 == 8) && ((*pl1->x) < 250)) (*pl1->x)++; /* right */ } }