Umair Qureshi

09-25-2010, 02:20 AM

Need help from u all

am a newbie here!!!

making a 2D project, snap link is given below

http://i238.photobucket.com/albums/ff224/umairqureshi_6/back.png

here i have to blast the ship which is moving downward on x-axis

with a cannon ball ,on the mountain

the function i am using for projectile trajectory is

----------------------------------------------------

void ball(int xx,int yy)

{

glRasterPos2i(xx,yy);

pix[7].mDraw();

glutSwapBuffers();

}

void ballMove(void)

{

calculateY(xx);

}

void calculateY(int xx)

{

yy= (xx*tan(angle*3.14/180))-(g*pow((float)xx, 2))/(2*(pow(u, 2))*(pow(cos(angle*3.14/180), 2)));

glRasterPos2i(xx+50,yy+520);

pix[7].mDraw();

if(xx>PosX-90 && xx<PosX+90 && yy>PosY-80 && yy<PosY+80)

{

glRasterPos2i(xx+50,yy+520);

pix[10].mDraw();

position=true;

}

glutSwapBuffers();

glutTimerFunc(10, calculateY , xx+5);

}

void pressKey(unsigned char key, int abc, int xyz)

{

switch(key)

{

case 'a':

{

if (state==1)

{

u=40;

angle=85;

ballMove();

break;

}.....

------------------------------

when i press 'a', ball starts to follow projectile trajectory and hit the ship

i am new to programming,

kindly help me out

Problems are :

1) i dont want to use glutSwapBuffers(); other than display function

it is possible?

2)if i keep the angle about 80, speed of ball is fast,but if i changed the angle to 30,speed of ball is too much slow

3) which equation should i use to calculate projectile ??

waiting for positive response

am a newbie here!!!

making a 2D project, snap link is given below

http://i238.photobucket.com/albums/ff224/umairqureshi_6/back.png

here i have to blast the ship which is moving downward on x-axis

with a cannon ball ,on the mountain

the function i am using for projectile trajectory is

----------------------------------------------------

void ball(int xx,int yy)

{

glRasterPos2i(xx,yy);

pix[7].mDraw();

glutSwapBuffers();

}

void ballMove(void)

{

calculateY(xx);

}

void calculateY(int xx)

{

yy= (xx*tan(angle*3.14/180))-(g*pow((float)xx, 2))/(2*(pow(u, 2))*(pow(cos(angle*3.14/180), 2)));

glRasterPos2i(xx+50,yy+520);

pix[7].mDraw();

if(xx>PosX-90 && xx<PosX+90 && yy>PosY-80 && yy<PosY+80)

{

glRasterPos2i(xx+50,yy+520);

pix[10].mDraw();

position=true;

}

glutSwapBuffers();

glutTimerFunc(10, calculateY , xx+5);

}

void pressKey(unsigned char key, int abc, int xyz)

{

switch(key)

{

case 'a':

{

if (state==1)

{

u=40;

angle=85;

ballMove();

break;

}.....

------------------------------

when i press 'a', ball starts to follow projectile trajectory and hit the ship

i am new to programming,

kindly help me out

Problems are :

1) i dont want to use glutSwapBuffers(); other than display function

it is possible?

2)if i keep the angle about 80, speed of ball is fast,but if i changed the angle to 30,speed of ball is too much slow

3) which equation should i use to calculate projectile ??

waiting for positive response