How hot does it get? Is it painful? Pretty much all devices will warm up significantly when running a processor-intensive app like that. If it's getting painful to touch, then it's probably time to stop--and most devices will have some emergency cool-off function anyway that detects dangerously high temps.
If you have a case on the phone, that might worsen overheating, since the phone has more trouble dissipating the heat.