J
James
Hi there,
I'm a beginner level programmer and am wondering how to achieve a Simple
Cannon Ball trajectory with c#.
See, i know how to work out the initial horizontal and vertical velocity of
the cannon ball:
double gravity = 9.8;
double initialVelocity = 45;
double angle = 45;
xVel = initialVelocity * Math.sin(angle);
yVel = initialVelocity * Math.cos(angle);
after this stage i don't know what to do to see an animation. I know i need
a loop and i need to change the x and y positions of the ball but i do not
know where to place them and how they should be calculated.
I also thought of a do/while loop such a:
int i = 1;
do{
x = x + xVel;
y = y + yVel;
i++;
}while (i < 100);
but this just creates all sorts of undesireable effects.
Any help will be highly appreciated.
Thanks
James
I'm a beginner level programmer and am wondering how to achieve a Simple
Cannon Ball trajectory with c#.
See, i know how to work out the initial horizontal and vertical velocity of
the cannon ball:
double gravity = 9.8;
double initialVelocity = 45;
double angle = 45;
xVel = initialVelocity * Math.sin(angle);
yVel = initialVelocity * Math.cos(angle);
after this stage i don't know what to do to see an animation. I know i need
a loop and i need to change the x and y positions of the ball but i do not
know where to place them and how they should be calculated.
I also thought of a do/while loop such a:
int i = 1;
do{
x = x + xVel;
y = y + yVel;
i++;
}while (i < 100);
but this just creates all sorts of undesireable effects.
Any help will be highly appreciated.
Thanks
James