Street Fighter Game (End)

In my previous post, I animated the player’s running, jumping, attacking, and hitting motions. Now I animate it when it is dead. The last thing we must animate is when it is dead. In the update() function, use the if-elif statement to check if the fighter’s health is less than or equal 0. Let the fighter’s health is 0, self.alive = false, self.update_action is 6. Like last post, 0 is standing, 1 is running, 2 is jumping, 3 and 4 are attacked, 5 is when it gets hit, and 6 is when it is dead.

Like you see in the video above, when the fighter’s health bar is 0, it will run its death animation but just as with the attack and hit animations. It gets stuck in the loop and does not stop. To make the animation end when the fighter is dead, check if self.alive is false, so the self.frame_index is the length of the animation list minus 1. After run the code, the fighter ends the animation when it is dead.

To add control for the other fighter. We just add one more argument of the Fighter class, and set its control is left, right, and up. The attack we use for the second fighter is number 1 and 2. And just call it in the “main.py” file.

Now all the fighters have their animation and they can move.

But the fighter can move and attack when it is already dead. You can see it below.

In the in-elif statement that is checking the self.attacking is false, we just add one more thing to make it check, if the fighter is still alive, so it can do its animation.

In the “main.py” file, creating the intro count is 3 and checking if the intro count does not equal 0, the fighters cannot move until the intro count is 0.

Draw Intro Count

Next to draw the intro count into the screen game, go to the Coding With Russ’s Github to download the “turok.ttf”, which is the font we use for the game. And create the draw_text() function to draw the intro count or the fighter’s score by using the blit() method. And just call it when the intro count does not equal 0.

After run the code, the intro count is in the middle of the screen.

Draw Victory

To draw the Victory into the screen, go to the Github and download the “victory.png” and we load the image. Create the score list [0, 0], which is [fighter 1’s score, fighter 2’s score]. And write an if-elif statement to check if the round is not over, and check if the fighter 1 is not alive, so the score[1], which is the score of fighter 2 plus 1, and round over is true. And check the fighter 2 then add a point for the fighter 1. And if the round over is true, so use the blit() method to draw the Victory image into the screen game.

Draw Score

We just call the draw_text() function to draw the score of the fighter.

Next is to make the game start again when the round is over. If the pygame.time.get_ticks() minus round_over_time is larger than ROUND_OVER_COOLDOWN. The round over is false and the intro count is 3.

To make sure all the fighters are not move when the round is over. We add an argument to the move() function, to check if the round_over is false, so the fighters can move.

The final thing we have to do is just delete the red and the green box. Just delete the pygame.draw.rect() in the draw() and attack() function. And also delete the surface in the attack() function.

The Street Fighter Game is complete. Now you can play this game with your friends.

Tags:

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *