Sign in to follow this  

need help with a game m developing

This topic is 2024 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

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.

Share this post


Link to post
Share on other sites
Thanks for responding.... Ahh I've got into this bad habit.
I'll work on it....
Its quite a large code
I'm not sure which part should I post here.
I'll post something soon probably by tomorrow, as I'm online through mobile at the moment

Share this post


Link to post
Share on other sites
Thanks for responding.... Ahh I've got into this bad habit.
I'll work on it....
Its quite a large code
I'm not sure which part should I post here.
I'll post something soon probably by tomorrow, as I'm online through mobile at the moment

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
// 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

Share this post


Link to post
Share on other sites
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 .. [img]http://public.gamedev.net//public/style_emoticons/default/dry.png[/img]

Share this post


Link to post
Share on other sites
this is the screen shot ...
im thinking of putting in a skybox for the 3d world effect .... but first i need to solve this movement issue.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


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