0

I have a problem whilst writing some code on python

There is choices and u have to either kill the enemy or defend. My problem is that when I take the health off the enemy or my character, it takes it from the starting health every time instead of the current health before. I’m not sure if that makes sense but hopefully I can get some help.

6th Sep 2019, 10:49 PM
Matthew
6 Antworten
0
I'm new so keep that in mind How are you using the variable that keeps track of the health as it changes through the battle? Is it in a Function?
6th Sep 2019, 11:00 PM
DataBass
DataBass - avatar
0
im keeping the variable the same as enemy_health but i think i need to change it each time so the value of the health gets taken off
6th Sep 2019, 11:07 PM
Matthew
0
im not sure how i do it tho
6th Sep 2019, 11:08 PM
Matthew
0
You might be going above your programming level. I was doing that the other day trying to make a game to interact with items and place them in a bag. I had to go a more simple route just to finish the project. Best not to get too fancy in beginning... Or so I hear because I'm still in the beginning. I'm guessing it's something like... You have a variable that has the value of the damage the player does. player_atk, for instance. Then make enemy_health = enemy_health - player_atk. If you make a function for this, you either have to put "global enemy_health" at the beginning of the function, or pass enemy_health as a parameter into the function. def function_name(put_paramater_here) I don't totally understand how passing parameters work but i made it work the other day lol. I find googling or YouTubing helps. Just don' be specific in your search but more general. Look for something like "change variable using function". Then try to interpret your finding to fit your exact situation.
6th Sep 2019, 11:50 PM
DataBass
DataBass - avatar
0
okay thank you, i will try it tomorrow when i go onto my pc. Hopefully this should work as i was trying to use a def function but i wasnt quite sure what to put as the parameter
6th Sep 2019, 11:52 PM
Matthew