It depends on what you consider to be a correct angle.

I was imagining a sun rising on the left, and setting on the right, and the shadow cast toward the bottom of the screen. I was also imagining the ground angled in case the game is drawn at an oblique angle.

So taking into account all of that, I came up with this as the end-point of the shadow relative to the thing that is casting it.

var _xoff = height / (dtan(sun_angle_y)*dcos(sun_angle_x));

var _yoff = dtan(sun_angle_x)*dcos(ground_angle) * height;

First of all, you should notice that since the north-south direction is aligned with the y axis, _yoff is constant... what I mean is it doesn't change with time of day, only with sun inclination, ground angle, and height of the thing casting the shadow. I found this counter-intuitive at first, but then when I thought about it, it made sense.

When the sun first rises, sun_angle_y should have a value of zero. It should have a value of 180 when the sun sets. sun_angle_x is the inclination of the sun, 0 means it passes directly overhead, 90 would mean it circles the horizon. ground_angle would have a value of 0 in a top down game, and some value between 0 and 90 in a game with an oblique projection. height is just how tall the thing casting the shadow is.

If you just need the angle of the shadow, it should just be the angle formed by the vector _xoff,_yoff. you can use point_direction(0,0,_xoff,_yoff), or darctan2(-_yoff,_xoff). But using only the angle of the shadow doesn't take into account the fact that the shadow stretches toward sunrise and sunset.