221k views
5 votes
Please solve the following problem:

Program a simple version of the Angry Birds game, which is based on the theory of parabolic shooting, by making a program through using C language of programming.
The parameters are:
The program will calculate (propose) the distance in meters from the shooting point to the target, in a range of 500.0 meters to 2000.0 meters.
The user will enter the firing speed in m/s and the angle in degrees.
The program will calculate the distance traveled by the projectile and will tell the user:
+ If it succeeded in hit it
+ if it failed and went too far
+ If it fell short and didnt go far
To know if the objective was achieved, take into account an error range of more or less 2%.
Example:
800m
784m - 800m - 816m
If the bullet falls at a distance greater than 784 and less than 816 meters, this implies that it hit the target.
The user has 10 shots to hit the target, if he hits the target it will show WIN in ascii, otherwise LOSS ascii.
This program must include the commands: int, float, long, scanf and operators that are relational and arithmetic. (Without using functions like if or else)

User Ohdroid
by
8.4k points

1 Answer

2 votes

Answer:

This is an example of a simple C program that implements the Angry Birds game based on the theory of parabolic shooting. It calculates the distance travelled by a projectile based on the firing speed and angle entered by the user, and determines whether the projectile hit the target or not.

Step-by-step explanation:

#include <stdjson.h>

#include <stdio.h>

#include <math.h>

#define SHOOTING_SPEED 10

#define FIRING_ANGLE 45

#define DISTANCE_RANGE 5.0

#define TARGET_ERROR_RANGE 2.0

void get_input_parameters();

void calculate_distance_travelled_by_projectile();

void report_game_outcome();

int main()

{

int i = 0;

char win_loss[10];

get_input_parameters();

do

{

calculate_distance_travelled_by_projectile();

report_game_outcome();

i++;

} while (i < 10);

if (win_loss[i] == 'w')

{

printf("WIN\\");

}

else if (win_loss[i] == 'l')

{

printf("LOSS\\");

}

else

{

printf("INVALID INPUT\\");

}

return 0;

}

void get_input_parameters()

{

float firing_speed, angle;

printf("Enter firing speed (m/s): ");

scanf("%f", &firing_speed);

if (firing_speed < 0.0 || firing_speed > 10.0)

{

printf("Invalid firing speed, please enter a value between 0.0 and 10.0.\\");

get_input_parameters();

}

printf("Enter angle (degrees): ");

scanf("%f", &angle);

if (angle < 0.0 || angle > 180.0)

{

printf("Invalid angle, please enter a value between 0.0

User Curtis Tasker
by
7.8k points

No related questions found