void ZMapDesc::DrawMapDesc() { DrawSmoke(); }
int DrawGLScene(GLvoid) { int t; float dist; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Posisi kamera if(var.cameratype==0) { dist=sqrt( (car.x-var.Iox)*(car.x-var.Iox)+(car.z-var.Ioz)*(car.z-var.Ioz) ); if(dist>150) { srand(rand()); t=(rand()%45-rand()%45); var.Iox=car.x+50*cos((car.any+90+t)*3.141/180); var.Ioy=(float)(1+rand()%10); var.Ioz=car.z-50*sin((car.any+90+t)*3.141/180); } gluLookAt(var.Iox,var.Ioy,var.Ioz,car.x,1.0f,car.z,0.0f,1.0f,0.0f); } if(var.cameratype==1) { var.xc=car.x+30*cos(var.anc*3.141/180); var.yc=8; var.zc=car.z+30*sin(var.anc*3.141/180); gluLookAt(var.xc,var.yc,var.zc,car.x,0.0f,car.z,0.0f,1.0f,0.0f); var.anc+=0.5; } // Random untuk mobil balik if(var.gira==false) { if(rand()%100==1) { car.anruote=(float)(rand()%30-rand()%30); var.gira=true; } } // Random perubahan kecepatan if(var.vel==0) { if(rand()%100==1) { car.vf=10+(float)(rand()%30); car.dvf=(car.vf-car.velocita)/100; var.vel=100; } } else { car.velocita+=car.dvf; var.vel--; } DrawBuf(); // membuat terrain //Sudut mobil dan velg car.any+=car.dany; car.dany=car.anruote/30; car.anruote/=1.01; if(fabs(car.anruote)<2) { var.gira=false; car.anruote=0; } // mengubah arah mobil car.x+=car.velocita*cos((car.any+90)*3.141/180)/30; car.z+=-car.velocita*sin((car.any+90)*3.141/180)/30; // Clipping if( car.x<-400 ) car.x=400; if( car.x>400 ) car.x=-400; if( car.z<-400 ) car.z=400; if( car.z>400 ) car.z=-400; // membuat bayangan glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_DST_COLOR); glPushMatrix(); glTranslatef(car.x+sin(car.any*3.141/180),0,car.z+sin(car.any*3.141/180)); glRotatef(car.any,0,1,0); glColor3f(0.1,0.1,0.1); glBegin(GL_QUADS); glVertex3f(-2.5,0.01,-6); glVertex3f(2.5,0.01,-6); glVertex3f(2.5,0.01,6); glVertex3f(-2.5,0.01,6); glEnd(); glPopMatrix(); glDisable(GL_BLEND); // membuat mobil glColor3f(1,1,1); glEnable(GL_LIGHTING); glPushMatrix(); glTranslatef(car.x,car.y,car.z); glRotatef(car.any,0,1,0); Auto->draw(); // membuat velg for(t=0;t<4;t++) { glPushMatrix(); glTranslatef(car.xruote[t],car.yruote[t]+(float)(rand()%10)/100,car.zruote[t]); if(t==0 || t==1) glRotatef(car.anruote,0,1,0); if(t==1 || t==3) { glRotatef(180,0,1,0); glRotatef(-car.gira,1,0,0); } if(t==0 || t==2) glRotatef(car.gira,1,0,0); Ruota->draw(); glPopMatrix(); car.gira-=car.velocita/3; } glPopMatrix(); glDisable(GL_LIGHTING); DrawSmoke(); // membuat asap velg var.frame++; return TRUE; }