Sorry if this answer is a bit too general, but to be more specific I would have to know whether this takes place in 2 or 3 dimensions, whether the world is flat, etc.
For any projectile motion calculation, it is easiest if we analyse each axis (dimension/component) separately. The two equations used here are:
d=u*td = u * t
(for no acceleration)
d=u*t + 1/2 * a * t^2d = u * t + 1/2 * a * t^2
(for the vertical component, where gravity is acting)
I will also use 'u' to represent the initial velocity, 'a' to represent acceleration and 'g' to represent acceleration due to gravity (approximately 9.8 ms^(-2)meters per second squared).
Hopefully you have some basic understanding of vectors and kinematics, if not, let me know and I'll fill you in on what you need to know.
From here forth, I will assume that you have two horizontal axes and one vertical axis.
Given that there is no acceleration occurring in the horizontal axes (other than friction, but in the context of a game, it becomes computationally very expensive to calculate this), the initial velocities along each axis are given by:
u = d/tu = d/t
where d is the distance traveled along that axis and t is the time taken to travel this distance.
In the vertical axis, the initial velocity is given by:
u = d/t + gt/2u = d/t + gt/2
where d is the vertical offset of the final position from the initial position.
Since you specifically asked to find the angle at which the projectile should be shot, the workings are provided below:
horizontal component distance = sqrt(ux^2 + uy^2)sqrt(ux^2 + uy^2)
where ux and uy are the initial velocities in each axis (assuming z is vertical).
angle from horizontal = arctan( uz / (sqrt(ux^2 + uy^2)) )arctan( uz / (sqrt(ux^2 + uy^2)) )
If your terrain is flat, then [uz = gt/2]uz = gt/2
, and you can ignore vertical displacement.
If your game is side-scrolling, then there will be only one horizontal axis.
If your game takes place on another planet, uses non-realistic velocities or the shell seems to travel strangely, try using a value other than 9.8 for g.
Hopefully this helps you out, and if you have any further questions, just leave a comment on this answer.
EDIT: Added code formatting for legibility