Date: Fri, 14 Mar 1997 14:22:02 -0600 (CST) From: Andrew Deren To: Deltaman cc: djgpp AT delorie DOT com Subject: Re: How can I do this? In-Reply-To: <33299450.3AB1@swipnet.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I think that it would be easier and faster to use integers as a direction, then for comparison you do not have to compare strings,here is a sample program that I came up just now. I did not test it so I do not know if that would work: #include #define DIR_RIGHT 1 #define DIR_LEFT 2 void walk(int dir) { if (dir == DIR_RIGHT) { if (frame_number == RIGHT_1) frame_number = RIGHT_2; else frame_number = RIGHT_1; } else if (dir == DIR_LEFT) { if (frame_number == LEFT_1) frame_number = LEFT_2; else frame_number = LEFT_1; } draw_sprite((BITMAP*)data[frame_number].dat, screen, x_loc, y_loc); } main() { //do all your initialization and loading ... while (1==1) { if (key[KEY_RIGHT]) walk(DIR_RIGHT); else if (key[KEY_LEFT]) walk(DIR_LEFT); else if (key[KEY_ESC]) break; } } On Fri, 14 Mar 1997, Deltaman wrote: > Hi! > > I'm quite new to c programming and I have the following problem. > > In my main function I pass a string that contains a direction to > the function 'walk(direction)' > In this function I also give a value to 'int frame_number' > > The sprite is defined named like RIGHT_1, RIGHT_2, LEFT_1 and so on > > How can I use draw_sprite (in Allegro) to draw the right frame if > I have the right direction and frame_number? > ------------------------------------------------------------------------ > mailto:deltaman AT swipnet DOT se > > Please visit my homepage at http://www.geocities.com/TimesSquare/8240 > ------------------------------------------------------------------------ > ______ _______ _______ _______ _______ _______ __ _ > | \ |______ | | |_____| | | | |_____| | \ | > |_____/ |______ |_____ | | | | | | | | | \_| > >