How can I take off in a straight line if the runway isn't visible ahead? In a C152, flying VFR, if you point your nose up you wouldn't be able to see the runway, thus it would be difficult to keep yourself aligned to it.

So once you take off with a C152, do you climb in a fixed climb rate or do you level off at a certain altitude whilst over the runway, and start your climb again once you've reached the threshold of the runway?
Thats what the compass is for.   Continue to fly runway heading according to the compass &amp; heading indicator.

While you may not be able to see the runway, you may have other markers.   Even a good cloud in front of the airplane can serve as a VFR reference point.

Or look out the side to the left-and-right of the plane.  You should be able to tell if you're going straight or turning by what you see going past the sides of your plane.