Ask coding questions

← Back to all posts
can someone help me please
TaylorRichardso (0)

i need to come up with a scenario where you would use a while loop in a shooting game.
Describe the situation using comments.
Tell the user what is happening and what they need to do using a print command# Create a while loop that will allow the user to change/loose points throughout the game.
Explain what is happening in your while loop with a comment.

Answered by LukeWright (114) [earned 5 cycles]
View Answer
Comments
hotnewtop
LukeWright (114)

I guess you can take some inspiration from my target practice game where the draw loop is a while loop that runs continiously and excutes certain functions. to put this into python it would be:

rungame = True
while rungame:
  moveEnemy()
  background(255)
  calibration()
  drawBackground()
  move()
  moveEnemy()
  drawEnemy()
  drawCars()
  aDS()
  gui()
  hit1()
  time()
  rands()
  swapGun()

in the code above, when you change the variable rungame to false, then it will stop looping.
here is the original code for reference.
(note: this was written in p5.js)
https://replit.com/@LukeWright/Target-Practice#sketch.js
click the checkmark next to my comment if this was helpful!

TaylorRichardso (0)

thank you LukeWright