how do you make that if the player
has 100 energy then the enemy attacks
the player has only 70 energy.
why doesn't this work
energy=100
energy = energy - 30
if do that then the players energy is -30!
Help me Please!!!!!
Printable View
how do you make that if the player
has 100 energy then the enemy attacks
the player has only 70 energy.
why doesn't this work
energy=100
energy = energy - 30
if do that then the players energy is -30!
Help me Please!!!!!
try posting this in the games section, they probably have an answer
One problem - not sure since code isn't posted.
Is Energy a Global Variable? If it isn't then energy upon entering another Form will be 0 - hence you will end up with -30.
Just curious. You may want to put something before and after the computation such as:
MsgBox ("Energy = " & energy + vbCRLF & _
"Damage = " & damage)
or you can make damage static... I usually do this to make sure my variables are assigned what I want them to be.
Hope I could've been help.
Rob
you will need a public variable for Energy.
Public Energy as Long
Then in the Subs
Energy = 100
and after damage...
Energy = Energy - 30 ' OK !!!
If the variable is not public then later in your damage sub (or button click or whatever) a new version of energy is created as a variant of value 0 so...
e = e - 30
= -30 ' because e equaled 0 not 100 in this sub
Maybe the Goblin's sword is bigger than you thought and instead of causing 30 damage, it is in fact causing 130 damage. (Hence the -30)
Try giving your barbarian a shield.
:)
------------------
Ishamel
[email protected]
How can I tell you I love you when you are sitting on my face? :p
Maybe you need quotes in there somewhere
Steve