First, if the author of the original work agrees, then no problem.
Second, if you just make it for personal enjoyment, study, or SCIEEEEENNNNCE, it shall be OK. (It usually get into the fair-use/fair-dealing category )
If you release your game publically or even make it commercially, then... you may be in trouble if the copyright owner decides to take action against you.
How big the trouble is...is mostly depending on how much damage the court thinks you have caused to the copyright owner. (Commerical games usually based on sales and download numbers, non-commercial games are mostly based on download/tariff numbers like piracy damage calculation. )
Usually, a fan-game may not cause much "damage", thus, sometimes copyright owners may not bother to take any action at all. But, that does not mean it's OK to do so without permission.