Błagam pomóżcie mój program nie działa tak jak trzeba :( zamierzam zrobić Grę 3D rzecz jasna z movmentem ale właśnie z nim mam problem ponieważ gdy naciskam w postać nie idzie do przodu a gdzy s nie idzie do tyłu błagam pomóżcie ;( KOD :
#include <math.h>
#include <iostream>
#include <Windows.h>
#include <glut.h>
using namespace std;
int X = 0;
int Y = 0;
int Z = 0;
void D ()
{
glPushMatrix();
glClearColor(1.0,1.0,1.0,1.0);
glClear (GL_COLOR_BUFFER_BIT);
glTranslatef(X,Y,Z);
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.5,0.5);
glVertex3f(0.5,-0.5,0.5);
glVertex3f(-0.5,-0.5,0.5);
glVertex3f(-0.5,0.5,0.5);
glEnd();
glPopMatrix();
glFlush();
glLoadIdentity();
glutSwapBuffers();
}
void Reshape ()
{
D();
}
void KeyBoard(unsigned char key,int x,int y)
{
switch (key)
{
case 'w':
Z++;
break;
case 's':
Z--;
break;
case ';':
exit (0);
break;
}
}
void Mouse (int btn, int state , int x,int y)
{
}
int main( int argc, char * argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(800,600);
glutCreateWindow("LOL");
glutKeyboardFunc(KeyBoard);
glutMouseFunc(Mouse);
glutDisplayFunc(D);
glutMainLoop();
}
#include <math.h>
#include <iostream>
#include <Windows.h>
#include <glut.h>
using namespace std;
int X = 0;
int Y = 0;
int Z = 0;
void D ()
{
glPushMatrix();
glClearColor(1.0,1.0,1.0,1.0);
glClear (GL_COLOR_BUFFER_BIT);
glTranslatef(X,Y,Z);
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,0.5,0.5);
glVertex3f(0.5,-0.5,0.5);
glVertex3f(-0.5,-0.5,0.5);
glVertex3f(-0.5,0.5,0.5);
glEnd();
glPopMatrix();
glFlush();
glLoadIdentity();
glutSwapBuffers();
}
void Reshape ()
{
D();
}
void KeyBoard(unsigned char key,int x,int y)
{
switch (key)
{
case 'w':
Z++;
break;
case 's':
Z--;
break;
case ';':
exit (0);
break;
}
}
void Mouse (int btn, int state , int x,int y)
{
}
int main( int argc, char * argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(800,600);
glutCreateWindow("LOL");
glutKeyboardFunc(KeyBoard);
glutMouseFunc(Mouse);
glutDisplayFunc(D);
glutMainLoop();
}