Greetings everyone,
M new here on gamedev.net and also in game development. I got interested around 6 months back, created a game with basics of C++ and this is a new game that m creating uses C++ and OpenGL.
Well m facing problem with texturing and controls, I'll get to texturing the next time.
The game is an aeroplane dog fight, for that I need aeroplane controls.
m really confused how to do it, I tried moving the plane along z-axis but then when i rotate the plane usong keyboard the plane rotates but doesn't move forward.
I know this isnt the right way to do it, i told it so yu all know that i tried.
Please help me, i reaaly wish to finish this game in the coming dew weeks.
Thanks in advance.
need help with a game m developing
Started by max.lavince, Jun 22 2012 12:09 PM
9 replies to this topic
Ad:
#2 Members - Reputation: 1548
Posted 22 June 2012 - 12:29 PM
You're going to have to post some code if you want any help at all.
And,stop using m for I'm.
And,stop using m for I'm.
My Gamedev Journal: 2D Game Making, the Easy Way
---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)
---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)
#5 Members - Reputation: 58
Posted 23 June 2012 - 02:59 PM
Are you moving your plane forward (z axis) using a key on the keyboard? Because if your plane stops moving forward when you press another key (to rotate it), you probably have a very simple logical problem in the code that checks for key states, where one check is overriding another.
If the plane is moving along the z axis by itself, and it stops when you rotate it, there's probably a much more complicated problem, but I'm guessing it's the first scenario, which I described.
If the plane is moving along the z axis by itself, and it stops when you rotate it, there's probably a much more complicated problem, but I'm guessing it's the first scenario, which I described.
#6 Members - Reputation: 113
Posted 27 June 2012 - 09:05 AM
// as the function name suggests this function creates the environment, basically its just the plane and a couple of buildings and a road... simple polygons
void environment(void)
{
// i was just trying something with the rotatef codes , i dont actually plan on using this ... i just wish to rotate my object and not the world.
glRotatef(worldx,1.0,0.0,0.0);
glRotatef(worldy,0.0,1.0,0.0);
glRotatef(worldz,0.0,0.0,1.0);
glColor3f(0.4,0.2,0.2);
glTranslatef(0.0,0.0,-100.0);
//+VE Z-AXIS
drawbuilding(70,-30,15,10,64,10);
genroad();
glBegin(GL_POLYGON);
glColor3f(0.1,0.1,0.0);
glVertex3f(100,-30,250);
glVertex3f(100,-30,0);
glVertex3f(-100,-30,0);
glVertex3f(-100,-30,250);
glEnd();
}
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(eyex,eyey,eyez,lookx,looky,lookz,0.0,1.0,0.0);
environment();
makejetplane();
attributes();
//maketplane();
Sleep(5);
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(90.0, (GLfloat) w/(GLfloat) h, 1.0, 200.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 'q':
exit(0);
break;
case 'w':
movz+=1.0;
glTranslatef(0.0,0.0,movz);
glutPostRedisplay();
break;
case 'a':
zpoz-=5.0;
rolll = 1;
glutPostRedisplay();
break;
case 'd':
zrpoz+=5.0;
rollr = 1;
glutPostRedisplay();
break;
case 't':
//worldx-=0.5;
xpoz += 5.0;
pitchu=1;
glutPostRedisplay();
break;
case 'g':
xrpoz -=5.0;
pitchd=1;
glutPostRedisplay();
break;
case 'f':
yawl=1;
rolll=1;
ypoz+=2.0;
zpoz-=1.0;
if(zpoz<=-45.0)zpoz=-45.0;
glutPostRedisplay();
break;
//rolll=0;
case 'h':
yawr=1;
rollr=1;
yrpoz+=2.0;
zrpoz+=1.0;
if(zrpoz>=90.0)zrpoz=90.0;
glutPostRedisplay();
break;
//rollr=0;
//CAMERA CONTROLS
case 'j':
lookx-=5;
glutPostRedisplay();
break;
case 'l':
lookx+=5;
glutPostRedisplay();
break;
default:
break;
}
}
//ANIMATION
void animate()
{
movz+=0.1;
//movement+=0.1;
eyez+=0.1;
lookz+=0.11;
glutPostRedisplay();
}
oid makejetplane()
{
if(pitchu>0)
{
glTranslatef(movx,movy,movz);
glRotatef(xpoz,1.0,0.0,0.0);
glTranslatef(-movx,-movy,-movz);
} //glRotatef(xpoz,1.0,0.0,0.0);
if(pitchd>0)
{
glTranslatef(movx,movy,movz);
glRotatef(xrpoz,1.0,0.0,0.0);
glTranslatef(-movx,-movy,-movz);
}
// glRotatef(xrpoz,-1.0,0.0,0.0);
if(yawl>0)
{
glTranslatef(movx,movy,movz);
glRotatef(ypoz,0.0,1.0,0.0);
glTranslatef(-movx,-movy,-movz);
}//glRotatef(ypoz,0.0,1.0,0.0);
if(yawr>0)
{
glTranslatef(movx,movy,movz) ;
glRotatef(yrpoz,0.0,-1.0,0.0);
glTranslatef(-movx,-movy,-movz); }
//glRotatef(yrpoz,0.0,-1.0,0.0);
if(rolll>0)
{
glTranslatef(movx,movy,movz) ;
glRotatef(zpoz,0.0,0.0,1.0);
glTranslatef(-movx,-movy,-movz); }
//glRotatef(zpoz,0.0,0.0,1.0);
if(rollr>0)
{
glTranslatef(movx,movy,movz) ;
glRotatef(zrpoz,0.0,0.0,1.0);
glTranslatef(-movx,-movy,-movz); }
//glRotatef(zrpoz,0.0,0.0,1.0);
// BODY
and rest are just the vertex3f codes ...
i've posted everything please guys help me out here.
and apologies for any rookie mistakes as it has just been 3-4 weeks since i've learnt opengl.
Thanks
void environment(void)
{
// i was just trying something with the rotatef codes , i dont actually plan on using this ... i just wish to rotate my object and not the world.
glRotatef(worldx,1.0,0.0,0.0);
glRotatef(worldy,0.0,1.0,0.0);
glRotatef(worldz,0.0,0.0,1.0);
glColor3f(0.4,0.2,0.2);
glTranslatef(0.0,0.0,-100.0);
//+VE Z-AXIS
drawbuilding(70,-30,15,10,64,10);
genroad();
glBegin(GL_POLYGON);
glColor3f(0.1,0.1,0.0);
glVertex3f(100,-30,250);
glVertex3f(100,-30,0);
glVertex3f(-100,-30,0);
glVertex3f(-100,-30,250);
glEnd();
}
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(eyex,eyey,eyez,lookx,looky,lookz,0.0,1.0,0.0);
environment();
makejetplane();
attributes();
//maketplane();
Sleep(5);
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(90.0, (GLfloat) w/(GLfloat) h, 1.0, 200.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 'q':
exit(0);
break;
case 'w':
movz+=1.0;
glTranslatef(0.0,0.0,movz);
glutPostRedisplay();
break;
case 'a':
zpoz-=5.0;
rolll = 1;
glutPostRedisplay();
break;
case 'd':
zrpoz+=5.0;
rollr = 1;
glutPostRedisplay();
break;
case 't':
//worldx-=0.5;
xpoz += 5.0;
pitchu=1;
glutPostRedisplay();
break;
case 'g':
xrpoz -=5.0;
pitchd=1;
glutPostRedisplay();
break;
case 'f':
yawl=1;
rolll=1;
ypoz+=2.0;
zpoz-=1.0;
if(zpoz<=-45.0)zpoz=-45.0;
glutPostRedisplay();
break;
//rolll=0;
case 'h':
yawr=1;
rollr=1;
yrpoz+=2.0;
zrpoz+=1.0;
if(zrpoz>=90.0)zrpoz=90.0;
glutPostRedisplay();
break;
//rollr=0;
//CAMERA CONTROLS
case 'j':
lookx-=5;
glutPostRedisplay();
break;
case 'l':
lookx+=5;
glutPostRedisplay();
break;
default:
break;
}
}
//ANIMATION
void animate()
{
movz+=0.1;
//movement+=0.1;
eyez+=0.1;
lookz+=0.11;
glutPostRedisplay();
}
oid makejetplane()
{
if(pitchu>0)
{
glTranslatef(movx,movy,movz);
glRotatef(xpoz,1.0,0.0,0.0);
glTranslatef(-movx,-movy,-movz);
} //glRotatef(xpoz,1.0,0.0,0.0);
if(pitchd>0)
{
glTranslatef(movx,movy,movz);
glRotatef(xrpoz,1.0,0.0,0.0);
glTranslatef(-movx,-movy,-movz);
}
// glRotatef(xrpoz,-1.0,0.0,0.0);
if(yawl>0)
{
glTranslatef(movx,movy,movz);
glRotatef(ypoz,0.0,1.0,0.0);
glTranslatef(-movx,-movy,-movz);
}//glRotatef(ypoz,0.0,1.0,0.0);
if(yawr>0)
{
glTranslatef(movx,movy,movz) ;
glRotatef(yrpoz,0.0,-1.0,0.0);
glTranslatef(-movx,-movy,-movz); }
//glRotatef(yrpoz,0.0,-1.0,0.0);
if(rolll>0)
{
glTranslatef(movx,movy,movz) ;
glRotatef(zpoz,0.0,0.0,1.0);
glTranslatef(-movx,-movy,-movz); }
//glRotatef(zpoz,0.0,0.0,1.0);
if(rollr>0)
{
glTranslatef(movx,movy,movz) ;
glRotatef(zrpoz,0.0,0.0,1.0);
glTranslatef(-movx,-movy,-movz); }
//glRotatef(zrpoz,0.0,0.0,1.0);
// BODY
and rest are just the vertex3f codes ...
i've posted everything please guys help me out here.
and apologies for any rookie mistakes as it has just been 3-4 weeks since i've learnt opengl.
Thanks
#7 Members - Reputation: 113
Posted 27 June 2012 - 09:51 AM
to antiHUMANDesigns--
thanks for responding ....
the plane is moving on its own n if i press a key i want the plane to rotate.
Now if i rotate the plane without any translations .... the plane kinda moves according to what i desire but not entirely - it does not face the other side ....the tip doesnt rotate rather the object rotates yu know how it is.
n if i translate it then the plane rotates as in the tip rotate but the plane yet moves in the z axis only ....
which looks a little stupid ( lol ).
i was thinking i create an axis and with the help of the axis ... the plane judges which way to rotate and move ... but its just a thought not sure how to go forward in that plan ..
thanks for responding ....
the plane is moving on its own n if i press a key i want the plane to rotate.
Now if i rotate the plane without any translations .... the plane kinda moves according to what i desire but not entirely - it does not face the other side ....the tip doesnt rotate rather the object rotates yu know how it is.
n if i translate it then the plane rotates as in the tip rotate but the plane yet moves in the z axis only ....
which looks a little stupid ( lol ).
i was thinking i create an axis and with the help of the axis ... the plane judges which way to rotate and move ... but its just a thought not sure how to go forward in that plan ..
#9 Members - Reputation: 114
Posted 30 June 2012 - 02:57 AM
I don't completely understand what the problem is and I'm quite new to DirectX as well, but I'll throw this in anyway..
Just in case, check if you are rotating first and then translating. Otherwise the result is quite different to the expected.
Just in case, check if you are rotating first and then translating. Otherwise the result is quite different to the expected.
#10 Members - Reputation: 113
Posted 02 July 2012 - 09:47 AM
theo2005 , this is opengl not directx .... the problem is the movement of the plane ... not the rotation...
the plane is moving on its own .. using the animate funciton
and the rotation is done by the keys , i want the plane to move in the respective direction even after the key pressed rotation
the plane is moving on its own .. using the animate funciton
and the rotation is done by the keys , i want the plane to move in the respective direction even after the key pressed rotation






