But what if you decided to shoot your photon torpedo gun (aka, your flashlight, or your torch if you're in England or Australia) under the same conditions? Intuitively, you'd think the speed of the light leaving the flashlight would equal its speed relative to the flashlight plus the speed of the train train relative to the ground, except you'd be wrong.
At the end of the 19th century, and especially thanks to the work of James Clerk Maxwell, there was plenty of evidence to conclude that the speed of light is constant, no matter how fast or in what direction you move relative to it, but no one could understand how this could possibly be so... until Albert Einstein developed his special theory of relativity with an intuition would that would forever revolutionize our understanding of physics: while the speed of light is constant, time and space are relative.
One of the weird consequences of that idea has come to be known as the twin paradox, about which you get to learn in the following funny animation:
Actually, GPS is one of the few applications that combines both special and general relativity in order to work because the Earth's gravitational pull also messes with the curvature of space-time.