Jump to content
  • Advertisement
Sign in to follow this  
razorsese

Projectile Motion

This topic is 2497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a hard time solving this problem

Untitled.png

It suppose to create a quadratic motion(like that in Worms or Pocket Tank) and the space between the points should be equal
but i cant manage to get it right.

void quadratic(int angle,int vel)
{
float theta=3.14*angle/180;//angle to radians
ux=vel*cos(theta);//X coord init value
uy=vel*sin(theta);//Y coord init value
t=((vel*vel)*(2*(sin(theta)*cos(theta))))/9.8;//maximum range that projectile can reach
for(i=1;i<=t*2;i++)//nr of projectile (i=time) (t=distance to travel)
{
x=ux*i;//X coord value
y=uy+(i*i*-9.8*0.5);//Y coord value
glVertex2f(x/50,y/50);
}
}

void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-20.0f, 0.0f, -50.0f);
glPushMatrix();
glBegin(GL_POINTS);
quadratic(45,15);
glEnd();
glPopMatrix();

glutSwapBuffers();
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!