Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program street _ fighter.c which allows the user to play a game of Street Fighter. The user should be able to customise

Write a C program street_fighter.c which allows the user to play a game of Street Fighter. The user should be able to customise the attack power and attack key-binding (the assignment of a key on a keyboard to a command) for each fighter.
Each round, the program should prompt each fighter to attack. It should then print out the current health of each fighter, continuing until one of the fighters has no health remaining. At this point it should print which player won the game.
A fighter who is below 50% of their maximum health deals 50% more damage.
You are provided with struct fighter which contains the following fields:
int attack: The attack power of the fighter. A fighter's attack power will come from the user and will be between 1 and 10.
double health: The current health of the fighter. Fighter's begin with a maximum health of 50.
char attack_command: The key binding for the attack command.
examples
./street_fighter
Welcome to Street Fighter!
Enter Fighter 1's attack power (1-10): 7
Enter an ascii character for Fighter 1's attack command: a
Enter Fighter 2's attack power (1-10): 10
Enter an ascii character for Fighter 2's attack command: b
FIGHT!
Fighter 1, press a to attack: a
Fighter 1 attacks!
Fighter 2, press b to attack: b
Fighter 2 attacks!
Fighter 1's health: 40.0
Fighter 2's health: 43.0
Fighter 1, press a to attack: a
Fighter 1 attacks!
Fighter 2, press b to attack: b
Fighter 2 attacks!
Fighter 1's health: 30.0
Fighter 2's health: 36.0
Fighter 1, press a to attack: a
Fighter 1 attacks!
Fighter 2, press b to attack: b
Fighter 2 attacks!
Fighter 1's health: 20.0
Fighter 2's health: 29.0
Fighter 1, press a to attack: a
Fighter 1 attacks!
Fighter 2, press b to attack: b
Fighter 2 attacks!
Fighter 1's health: 5.0
Fighter 2's health: 18.5
Fighter 1, press a to attack: a
Fighter 1 attacks!
Fighter 2, press b to attack: b
Fighter 2 attacks!
Fighter 1's health: -10.0
Fighter 2's health: 8.0
Fighter 2 wins!
GAME OVER

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

Students also viewed these Databases questions

Question

Explain what is meant by organisational jargon

Answered: 1 week ago

Question

EMPLOYEE BENEFITS IFRS19

Answered: 1 week ago