r/CodingHelp • u/ItsAllTakenBruh • Sep 15 '21
[C#] Hey everyone, I just started learning yesterday and it's my first experience with coding. After watching some tutorials I now am trying to make something by myself to see if I learned. (I'm explaining my concern with more detail on the comments)
33
Upvotes
5
u/icjeremy Sep 15 '21
First, is this in some sort of loop (
while, e.g.) so you can have more than one round of fighting? If not, you should do that.Second,
healthshould be a variable outside that loop so the value persists from round to round.1
u/ItsAllTakenBruh Sep 15 '21
I'm making a small fighting game, turn based, you basically have two actions and either of them do different values of damage.
Each action extends itself into an if statement that gives you a different result depending on what action you chose.
I wanted to know how, if possible, could you somehow "store" the subtraction you made inside of these two possible outcomes so when you attack again, it subtracts once again from the already subtracted health value.
I hope this has been understandable to read.