1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sidana [21]
3 years ago
9

Create a while loop to try making a video game turn based battle.

Computers and Technology
1 answer:
elena-14-01-66 [18.8K]3 years ago
5 0

import random

monster_health = 20

player_health = 20

while player_health >0 and monster_health>0:

   player_choice = input("Do you wish to attack, heal, or do magic? (type attack, heal, or magic) ")

   if player_choice == "attack":

       damage = random.randint(1,6)

       monster_health -= damage

       print("You attack the monster for",damage,"points of health. The monster has",monster_health,"points of health")

   elif player_choice == "heal":

       heal = random.randint(1,6)

       player_health += heal

       if player_health>20:

           player_health = 20

       print("You heal for",heal,"points of health. Your health is now at",player_health)

   elif player_choice == "magic":

       total = 0

       for x in range(2):

           total += random.randint(1,6)

       monster_health -= total

       print("You attack the monster for",total,"points of health. The monster has",monster_health,"points of health")

   if player_health < 1 or monster_health <1:

       break

   monster_damage = random.randint(1,6)

   player_health -= monster_damage

   print("The monster attacks your for",monster_damage,"points of health. You have",player_health,"points of health remaining.")

if player_health < 1:

   print("You died! Better luck next time!")

elif monster_health < 1:

   print("You defeated the monster! Great job!")

I wrote my code in python 3.8. Best of luck.

You might be interested in
Icon view, list view, and details view are all common views provided by which kind of program?
RideAnS [48]
The standard program that uses common views such as the icon view, list view, and details view would be the program known as "File Explorer" (Windows) or "Finder" (Mac). This program uses all the views to make selecting and tracking down certain files a much more painless and easier process to complete.

Hope this helps and good luck! :)
6 0
4 years ago
Read 2 more answers
Have you ever been presented to someone else's home page of a given website?​
worty [1.4K]

Answer: No, is this the question?

Explanation: Have a stupendous day! <3

6 0
3 years ago
What are the five elements of video production
goldenfox [79]
Answer: sight, color, emotion, sound, motion
3 0
3 years ago
Read 2 more answers
Why is derek miller's social media post different than most?
fgiga [73]
In the scenario in which Derek Miller's social media post is different than most since Miller had his family and friends write a post after he died with the letter he wrote. Hope this is the answer and would be of help.
5 0
4 years ago
Software created according to user choice​ true or false
solniwko [45]

Answer:

True

Explanation: so that everything we want is available that is why we can customize our interface.

3 0
3 years ago
Other questions:
  • How does the use of modules provide flexibility in a structured programming design?
    14·2 answers
  • Which BI tool or technique would be most useful in predicting the likelihood of a fire in a building? a. Data mining b. Dashboar
    9·1 answer
  • 60 POINTS!
    13·1 answer
  • Routers do not forward broadcast packets.A. TrueB. False
    7·1 answer
  • "You have installed a point-to-point connection using wireless bridges and Omni directional antennas between two buildings. The
    8·1 answer
  • Write a java program to print the following series: <br>1 5 9 13 17...n terms​
    13·2 answers
  • What are the paparazzi?
    8·1 answer
  • EASY What does the Backspace key do?
    6·1 answer
  • Write a Boolean expression that tests if the value stored in the variable num1 is equal to the value stored in the variable num2
    10·1 answer
  • Which of the following actions taken by the Fed will increase the nation’s money supply? (Select all that apply.)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!