السلام عليكم ..
هذا كود فكرة زي لعبة تلبيس العرايس ..
اول شيء يطلع الملكان يمشي ويوقف في نقطه معينه بعدين نختار منيو الملابس عن طريق الماوس ..
نواجه مشكلة الملكان يمشي بعد مايوقف تطلع لنا المنيو بس الملابس ماتظهر ..
علما قبل مانضيف الحركة كانت الملابس تطلع ..
هذا الكود ..
#include <windows.h>
#include <GL/glut.h>
//قيمة ابتدائية لمكان تحرك الجسم
float ty=0;
void display (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//background
glColor3ub (111, 111, 111);
glBegin(GL_POLYGON);
glVertex2i (-500,500);
glVertex2i (500,500);
glVertex2i (500,-500);
glVertex2i (-500,-500);
glEnd();
//read carbet
//glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glColor3ub (111, 0, 0);
glVertex2i (0,-400);
glColor3ub (111, 0, 0);
glVertex2i (-300,-400);
glColor3ub (270, 0, 0);
glVertex2i (0,400);
glEnd();
//mothalth aswad
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2i (20,-450);
glVertex2i (0,-400);
glVertex2i (0,400);
glEnd();
//mostateel aswad
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2i (0,-400);
glVertex2i (-300,-400);
glVertex2i (-280,-450);
glVertex2i (20,-450);
glEnd();
//back wall
glColor3ub(111,111,111);
glBegin(GL_POLYGON);
glVertex2i (-500,500);
glVertex2i (500,500);
glVertex2i (500,0);
glVertex2i (-500,0);
glEnd();
// 7dod Lroom
glColor3ub(1,1,1);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2i (100,0);
glVertex2i (-500,0);
glEnd();
glColor3ub(1,1,1);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2i (100,0);
glVertex2i (100,500);
glEnd();
glColor3ub(1,1,1);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2i (100,0);
glVertex2i (500,-500);
glEnd();
glColor3ub(111,111,111);
glBegin(GL_POLYGON);
glVertex2i (-500,500);
glVertex2i (500,500);
glVertex2i (500,0);
glVertex2i (-500,0);
glEnd();
glPushMatrix();
glTranslatef(0,ty,0);
// rass
glColor3ub(255,231,204);
glBegin(GL_POLYGON);
glVertex2i (-100,90);
glVertex2i (-140,90);
glVertex2i (-140,50);
glVertex2i (-100,50);
glEnd();
//3en yamen
glPointSize(6);
glBegin(GL_POINTS);
glColor3f(0, 0, 1);
glVertex2i(-110,80);
glEnd();
//3en yasar
glPointSize(6);
glBegin(GL_POINTS);
glColor3f(0, 0, 1);
glVertex2i(-125,80);
glEnd();
//jasm
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex2f(-120, 50);
glVertex2f(-120, -150);
glEnd();
//regl ysar
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex2f(-120, -150);
glVertex2f(-150, -300);
glEnd();
//regl yamen
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex2f(-120, -150);
glVertex2f(-100, -300);
glEnd();
//yad yamen
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex2f(-120, 0);
glVertex2f(-50, -50);
glEnd();
//yad yasar
glColor3ub(0,0,0);
glBegin(GL_LINES);
glVertex2f(-120, 0);
glVertex2f(-200, -50);
glEnd();
if(ty>=0&ty<=200)
{
ty=ty+1.7;
}
glPopMatrix();
glutSwapBuffers();
}
void tshert(){
glColor3ub (252,189,30);
glBegin(GL_POLYGON);
glVertex2i (-135,10);
glVertex2i (-105,10);
glVertex2i (-105,-155);
glVertex2i (-135,-155);
glEnd();
// kom yasar
glColor3ub (252,189,30);
glBegin(GL_POLYGON);
glVertex2i (-150,0);
glVertex2i (-135,10);
glVertex2i (-130,-20);
glVertex2i (-150,-30);
glEnd();
glColor3ub (252,189,30);
glBegin(GL_POLYGON);
glVertex2i (-105,10);
glVertex2i (-90,0);
glVertex2i (-90,-30);
glVertex2i (-130,-20);
glEnd();
glFlush();
}
void Belt(){
glColor3ub(1,1,1);
glBegin(GL_POLYGON);
glVertex2f(-140, -110);
glVertex2f(-90, -110);
glVertex2f(-80, -120);
glVertex2f(-150,-120);
glEnd();
glFlush();
}
void dress1(){
glColor3ub(23,10,255);
glBegin(GL_POLYGON);
//1
glVertex2f(-160,-200);
//2
glVertex2f(-80,-200);
//3
glVertex2f(-80,20);
//4
glVertex2f(-100,20);
//5
glVertex2f(-120,-10);
//6
glVertex2f(-140,20);
//7
glVertex2f(-160,20);
glEnd();
glPointSize(4);
glBegin(GL_POINTS);
glColor3ub(34,190,135);
glVertex2i(-120, -30);
glEnd();
glPointSize(4);
glBegin(GL_POINTS);
glColor3ub(34,190,135);
glVertex2i(-120, -40);
glEnd();
glPointSize(4);
glBegin(GL_POINTS);
glColor3ub(34,190,135);
glVertex2i(-120, -50);
glEnd();
glPointSize(4);
glBegin(GL_POINTS);
glColor3ub(34,190,135);
glVertex2i(-120, -60);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-80, -80);
glVertex2i(-160, -80);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-80, 20);
glVertex2i(-100, 20);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-140, 20);
glVertex2i(-160, 20);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-140, 20);
glVertex2i(-120, -10);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-100, 20);
glVertex2i(-120, -10);
glEnd();
glColor3ub(23,10,255);
glBegin(GL_POLYGON);
glVertex2f(-55,-55);
glVertex2f(-40,-40);
glVertex2f(-80,20);
glVertex2f(-80,-10);
glEnd();
glColor3ub(23,10,255);
glBegin(GL_POLYGON);
glVertex2f(-185,-55);
glVertex2f(-200,-40);
glVertex2f(-160,20);
glVertex2f(-160,-10);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-55,-55);
glVertex2i(-40, -40);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(34,190,135);
glVertex2i(-185,-55);
glVertex2i(-200,-40);
glEnd();
glFlush();
}
void Necklace(){
glPointSize(2);
glBegin(GL_LINES);
glColor3f(0,0,0);
glVertex2i(-90,20);
glVertex2i(-120,-15);
glEnd();
glPointSize(2);
glBegin(GL_LINES);
glColor3f(0,0,0);
glVertex2i(-150,20);
glVertex2i(-120,-15);
glEnd();
glPointSize(6);
glBegin(GL_POINTS);
glColor3f(0,0,0);
glVertex2i(-120,-15);
glEnd();
glFlush();
}
void Belt2(){
glColor3ub (000, 000, 000);
glBegin(GL_TRIANGLES);
glVertex2i (-90,-80);
glVertex2i (-100,-80);
glVertex2i (-95,-90);
glEnd();
glColor3ub (000, 000, 000);
glBegin(GL_TRIANGLES);
glVertex2i (-100,-80);
glVertex2i (-110,-80);
glVertex2i (-105,-90);
glEnd();
glColor3ub (000, 000, 000);
glBegin(GL_TRIANGLES);
glVertex2i (-110,-80);
glVertex2i (-120,-80);
glVertex2i (-115,-90);
glEnd();
glColor3ub (000, 000, 000);
glBegin(GL_TRIANGLES);
glVertex2i (-120,-80);
glVertex2i (-130,-80);
glVertex2i (-125,-90);
glEnd();
glColor3ub (000, 000, 000);
glBegin(GL_TRIANGLES);
glVertex2i (-130,-80);
glVertex2i (-140,-80);
glVertex2i (-135,-90);
glEnd();
glPointSize(4);
glBegin(GL_LINES);
glColor3f(0,0,0);
glVertex2i(-156, 20);
glVertex2i(-90, -80);
glEnd();
glPointSize(4);
glBegin(GL_LINES);
glColor3f(0,0,0);
glVertex2i(-156,-200);
glVertex2i(-90, -80);
glEnd();
glFlush();
}
void tshirt2(){
glColor3ub(255, 51, 175);
glBegin(GL_POLYGON);
glVertex2f(-120,-50);
//2
glVertex2f(-80,-60);
//3
glVertex2f(-80,10);
//4
glVertex2f(-120,0);
//5
glVertex2f(-160,10);
//6
glVertex2f(-160,-60);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(000,000,000);
glVertex2i(-80,10);
glVertex2i(-120,0);
glEnd();
glPointSize(6);
glBegin(GL_LINES);
glColor3ub(000,000,000);
glVertex2i(-120,0);
glVertex2i(-160,10);
glEnd();
glFlush();
}
void trousers2(){
glColor3ub(000, 000, 000);
glBegin(GL_POLYGON);
//1
glVertex2f(-120,-90);
//2
glVertex2f(-100,-200);
//3
glVertex2f(-70,-200);
//4
glVertex2f(-80,-70);
//5
glVertex2f(-160,-70);
//6
glVertex2f(-170,-200);
//7
glVertex2f(-140,-200);
glEnd();
glPointSize(8);
glBegin(GL_LINES);
glColor3ub(255, 51, 175);
glVertex2i(-80,-70);
glVertex2i(-160,-70);
glEnd();
glFlush();
}
void cap(){
glColor3ub(666,666,111);
glBegin(GL_POLYGON);
glVertex2i (-90,40);
glVertex2i (-70,70);
glVertex2i (-100,90);
glVertex2i (-140,90);
glVertex2i (-170,70);
glVertex2i (-150,40);
glEnd();
glColor3ub(666,666,111);
glBegin(GL_POLYGON);
glVertex2i (-90,60);
glVertex2i (-150,70);
glVertex2i (-150,160);
glVertex2i (-90,160);
glEnd();
glBegin(GL_POLYGON);
glColor3ub(666,111,111);
glVertex2i (-90,80);
glVertex2i (-150,80);
glVertex2i (-150,110);
glVertex2i (-90,110);
glEnd();
glFlush();
}
void dress2 (){
glPointSize(2);
glBegin(GL_LINES);
glColor3ub(000,000,000);
glVertex2i(-83, 5);
glVertex2i(-83, 30);
glEnd();
// kom yasar
glPointSize(2);
glBegin(GL_LINES);
glColor3ub(000,000,000);
glVertex2i(-157, 5);
glVertex2i(-157, 30);
glEnd();
glFlush();
}
void dress3(){
glColor3ub(171,25,21);
glBegin(GL_POLYGON);
//1
glVertex2f(-140,-80);
//2
glVertex2f(-156,-200);
//3
glVertex2f(-80,-200);
//4
glVertex2f(-90,-80);
//5
glVertex2f(-80,20);
//6
glVertex2f(-118,5);
//7
glVertex2f(-156,20);
glEnd();
glFlush();
}
void dress4(){
glColor3ub(222,34,24);
glBegin(GL_POLYGON);
//1
glVertex2f(-140,-110);
//2
glVertex2f(-90,-110);
//3
glVertex2f(-70,20);
//4
glVertex2f(-90,20);
//5
glVertex2f(-120,-10);
//6
glVertex2f(-140,20);
//7
glVertex2f(-160,20);
glEnd();
glColor3ub(22,34,294);
glBegin(GL_POLYGON);
glVertex2f(-140, -110);
glVertex2f(-90, -110);
glVertex2f(-70, -200);
glVertex2f(-160,-200);
glEnd();
glFlush();
}
void trousers(){
glColor3ub (109,83,65);
glBegin(GL_POLYGON);
glVertex2i (-120,-155);
glVertex2i (-105,-155);
glVertex2i (-95,-300);
glVertex2i (-120,-310);
glEnd();
glColor3ub (109,83,65);
glBegin(GL_POLYGON);
glVertex2i (-135,-155);
glVertex2i (-120,-155);
glVertex2i (-145,-300);
glVertex2i (-170,-310);
glEnd();
glFlush();}
void menu(int ms)
{
if (ms==1)
tshert();
if(ms==2)
tshirt2();
if(ms==3)
dress1();
if(ms==4)
dress2();
if(ms==5)
dress3();
if(ms==6)
dress4();
if(ms==7)
trousers();
if(ms==8)
trousers2();
if(ms==9)
cap();
if(ms==10)
Belt();
if(ms==11)
Belt2();
if(ms==12)
Necklace();
}
void set_up_menu(void)
{
glutCreateMenu(menu);
glutAddMenuEntry("T shert",1);
glutAddMenuEntry("T-shirt",2);
glutAddMenuEntry("Dress",3);
glutAddMenuEntry("Dress",4);
glutAddMenuEntry("Dress",5);
glutAddMenuEntry("Dress",6);
glutAddMenuEntry("Trousers",7);
glutAddMenuEntry("Trousers",8);
glutAddMenuEntry("cap",9);
glutAddMenuEntry("Belt",10);
glutAddMenuEntry("Belt",11);
glutAddMenuEntry("Necklace",12);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
void main (int argc, char **argv)
{
glutInit (&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize (1000, 1000);
glutCreateWindow ("Translate always");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glClearColor(1.0,1.0, 1.0, 0.0);
glOrtho(-500.0, 500.0, -500.0, 500.0, 0.0, 1.0);
glutDisplayFunc (display);
glutIdleFunc (display);
glMatrixMode(GL_MODELVIEW);
set_up_menu();
glLoadIdentity();
glutMainLoop();
}بليييز احد يرد علي ضروري ..