Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes

I wanted to put an enemy's HP bar on screen as part of my final project. Should I update it once per while loop like in the dragon game or should I only update it at certain times? I'm comparing it to the health feature from the dragon game, but I'm not sure how actually similar it is.

asked in CSC201 Spring 2021 by (1 point)

3 Answers

+3 votes

I'd guess you'd want to update it every time the enemy's health would change (every time you hit it/if it heals). From the dragon game, I've noticed that the fewer times you call functions, the less laggy your program will be.

answered by (1 point)
+3 votes

I would recommend it gets updated every time the users HP either decreases or increases so it updates every time there is a change to the health.

answered by (1 point)
0 votes

I would suggest every time the item got hit or you got hit, then it call back because if try to check it every second might make the program laggy

answered by (1 point)