# making the player shoot

This topic is 2391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm having multiple problems atm.
1. player shooting animation not playing
2. arms dont appear when looking left

Here is where i set the clips
 // facing right for( int i = 0; i < 3; i++ ) { pistolClips = new SDL_Rect; pistolClips->x = 0; pistolClips->y = 16 * i; pistolClips->h = 16; pistolClips->w = 36; } //facing left for( int i = 3; i < 6; i++ ) { pistolClips = new SDL_Rect; pistolClips->x = 36; pistolClips->y = 16 * i; pistolClips->h = 16; pistolClips->w = 36; } 

Here is what should draw the arms
 // loop firing animation if( player->pistolFrame == 3 ) { player->shoot = false; player->pistolFrame = 1; } // draw if( player->direction == RIGHT ) { if( player->shoot ) { graphics->ApplySurface( player->handgun.xPos, player->handgun.yPos, player->pistol, graphics->screen, player->pistolClips[player->pistolFrame] ); player->pistolFrame++; } else { graphics->ApplySurface( player->handgun.xPos, player->handgun.yPos, player->pistol, graphics->screen, player->pistolClips[0] ); } } else if( player->direction == LEFT ) { if( player->shoot ) { graphics->ApplySurface( player->handgun.xPos, player->handgun.yPos, player->pistol, graphics->screen, player->pistolClips[player->pistolFrame + 3] ); player->pistolFrame++; } else { player->handgun.xPos -= 15; graphics->ApplySurface( player->handgun.xPos, player->handgun.yPos, player->pistol, graphics->screen, player->pistolClips[3] ); } } 

and here is what should set player->shoot to true;
 if( keystate[ SDLK_SPACE ] ) { shoot = true; } 

##### Share on other sites
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express

Step Two: Move your code into the new IDE.

Step Three: Run you code in debug mode, with a break-point set at 'shoot = true;' or some other reasonable place.

This is a problem that with a debugger you can track down very quickly, and learning to use one will help you tremendously in the future.

(if you already have msvc or a good debugger say so and we can go from there)

##### Share on other sites
I am using msvc 2010, but i cannot do step three because the program only gets to 'shoot = true;' if space is pressed. using the debuger is moves the program one frame at a time. I would have to press play, rush to the other side of the screen, click it, then press space.

##### Share on other sites
Now I could be wrong, but I'm pretty sure msvc express comes with the same debugging capabilities as the normal version.

In which case, just set the configuration to debug build and click the green arrow or w/e and it will run normally until it hits a break point.
Just add the break-point somewhere sensible.

Then you can step through the program to ensure its working properly.

##### Share on other sites

Now I could be wrong, but I'm pretty sure msvc express comes with the same debugging capabilities as the normal version.

In which case, just set the configuration to debug build and click the green arrow or w/e and it will run normally until it hits a break point.
Just add the break-point somewhere sensible.

Then you can step through the program to ensure its working properly.

It does.

All nano has to do is place a breakpoint after he's handeled the right keycode, aka. "Space". And then place a breakpoint on all the significant logical statements.

As someone said in one of your previous posts. "You should learn debuging because that's going to fix moste of your problems". It's really easy and it fixes your problems quickly.