Hi all,
I’m just interested to know if there’s a reason for this. I note the way we’re being guided to construct the body of ClimbLadder(). In Pseudocode:
If Not (Player Touching ladder)
{
Put stuff back to non-ladder behaviour
return out of this function
}
Do the ladder climbing behaviour stuff - animation, physics
To me this seems a little bit turned-on-its-head. Firstly the use of the ‘not player touching’ - sort of a double negative, but - and what would help avoid that: refraining from using if / else. This seems to me to be a much more logical construct to use:
if (Player touching ladder)
{
Do the ladder climbing behaviour stuff - animation, physics
}
else
{
Put stuff back to non-ladder behaviour
}
If / Else is such a widely used construct that I automatically put it in when doing the challenge, even though this course is my first brush with C#. I guess this is just a stylistic choice, but to me it would have seemed to be a really good opportunity to introduce if/else for anyone who hasn’t seen the construct before.
This is not a criticism! I’m really enjoying the Tilevania lectures. I’m just wondering if there’s a reason to avoid if/else that I can’t see yet.