Im confused how this if statement is working

1
2
3
4
5
if(alive) 
{
    m.killMonster(); //alive variable in monster class is set to false.
    l.addMonster(m.getMPosX(),m.getMPosY());
}


when the program runs, alive is set to true, so doesnt that mean m.killMonster function is also executed and the alive variable is set to false? This is the only place where I am calling this function and it is working but how does it know when to set the variable to false?

There is a lot of code so I cant copy and paste is but if you want to have a look at it then I have uploaded the file here;

https://rapidshare.com/files/2991979459/Text_Game.rar
Maybe you should FIRST get the monster's position, THEN kill him and spawn another one?
Topic archived. No new replies allowed.