Question



In this project you will implement a very simple TTY game. In this game, the user has a catapult that can launch projectiles. In each round of the game, the computer places a wall in front of the user. The user aims their catapult by setting the launch angle and speed. The computer then computes whether the projectile makes it over the wall and informs the user. The user gets points for clearing the wall and loses points for hitting the wall. The game continues through successive rounds until the user quits. The following graphic illustrates the game. Note however that youtwill not be implementing any graphics in this project. This is a TTY game. speed height angle distance
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here's the code for game in C++ :

#include <bits/stdc++.h>

using namespace std;

int main()
{
int choice,plus_points=5,minus_points=2,total_points=0;
do{
double d,h,v,theta,t,g=9.81,d1,h1,t1;
cout<<"\nEnter distance (in meters) from the wall: ";
cin>>d;
cout<<"\nEnter height (in meters) of the wall: ";
cin>>h;
cout<<"\nEnter speed (in meters per second) of the projectile: ";
cin>>v;
cout<<"\nEnter angle (in radians) of the projectile: ";
cin>>theta;
t=2*v*sin(theta)/g;
d1=v*cos(theta)*t;
t1=d/(v*cos(theta));
h1=v*sin(theta)*t1-g*t1*t1/2;
if(d>=d1&&h>=h1){
total_points+=plus_points;
cout<<"\nYayy! Successfully crossed the wall!";
}
else{
total_points-=minus_points;
cout<<"\nSorry! Failed to cross the wall!";
}
cout<<"\nTotal Score is: "<<total_points<<endl;
  
cout<<"\nPress 1 to play more...Press 0 to exit...";
cin>>choice;
  
}while(choice);
return 0;
}

Add a comment
Know the answer?
Add Answer to:
In this project you will implement a very simple TTY game. In this game, the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT