0

Interacting Classes (for basic video game)

I'm trying to make a Zork type game with a few stats that cause damage to the other player/CPU opponent. For some reason I'm doing it on Java. Basically I have a formula that makes a double named damage. If I make a class GetHurt, how can I make the damage a character produces decrease another characters health? In other words, how can I use a class to affect another classes information? I don't know how to put the file on my computer onto this otherwise I would.. If you can tell me how to do that I will

2nd Jul 2018, 5:43 PM
Noah Shrewsbery
Noah Shrewsbery - avatar
1 Resposta
+ 2
In the below code, Player p2 hurts Player p1. The damagePlayer( ) method is called to call the getHurt( ) method of another player. And finally, getHurt( ) method decreases some health of that player. https://code.sololearn.com/c63gx84gULv1/?ref=app
2nd Jul 2018, 5:58 PM
777
777 - avatar