Q.4. Create an application in C sharp that will place different objects at random locations over the form and they are moving with random speed and would be killed by some other object. Application must be able to count the score that has been produced by the player.
Added by Kayla A.
Step 1
Create a new Windows Forms Application project in Visual Studio. Show more…
Show all steps
Your feedback will help us improve your experience
Haricharan Gupta and 81 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
struct Object { std::string name; int strength{ 0 }; int health{ 0 }; }; Game play: a. Loop until the player is dead, or all monsters are dead i. Display player's name and health, along with each monster's name and health (regular for loop) ii. Ask if you want to attack or heal iii. Heal iv. Attack: choose a monster to attack and subtract your strength from that monster's health. v. For monster attack, use a ranged-based for loop Create an object called player a. Give it a fun name. b. Random health (normal distribution with mean of 30 and stdev of 5) c. Random strength (normal distribution with mean of 5 and stdev of 1) d. Make sure health and strength are at least 1 Create a vector of Objects called monsters a. Random number of monsters (uniform between 1 and 3) b. Monster c. Health & strength same way as player. Loop and use a Bernoulli distribution to give the monster a 75% chance to attack. Attacking subtracts the monster's strength from the player's health. Game Over. a. Display appropriate message depending on if the player died, the monsters died, or both.
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD