seenubabueducom.files.wordpress.com€¦ · web view#include #include #include #include glfloat...

32
#include<stdafx.h> #include<stdio.h> #include<glut.h> #include<math.h> GLfloat b1=0; int flag=0; int k,i; int key_control=0; float fall=0,x_move=0,y_move=0; int ch=0; GLfloat ya = 0.0; // variables for apple GLfloat xa = 0.0; GLfloat step1 = 0.5; // for 1st bird and others GLfloat step2 = 0.5; // for 2nd bird and others GLfloat yy = 0.0; // variables for 1st bird GLfloat xx = 0.0; GLfloat ay = 0.0; // variables for 2nd bird GLfloat ax = 0.0; GLfloat by = 0.0; // variables for 3rd bird GLfloat bx = 0.0; GLfloat cy = 0.0; // variables for 4th bird GLfloat cx = 0.0; GLfloat dy = 0.0; // variables for 5th bird GLfloat dx = 0.0; void sky() { glBegin(GL_POLYGON); //top half of background glColor3f(1.0,0.6,0.0);//BOTTOM LEFT glVertex2f(0.0,299.0); glColor3f(1.0,0.6,0.0); //BOTTOM RIGHT glVertex2f(1014.0,299.0); glColor3f(1.0,1.0,0.0); //TOP RIGHT glVertex2f(1014.0,699.0); glColor3f(1.0,1.0,0.0); // TOP LEFT glVertex2f(0.0,699.0); glEnd(); } void ground() { glBegin(GL_POLYGON); //bottom half of background glColor3f(0.102,0.255,0.0);//BOTTOM LEFT glVertex2f(0.0,0.0); glColor3f(0.102,0.255,0.0); //BOTTOM RIGHT glVertex2f(1014.0,0.0);

Upload: doliem

Post on 23-Mar-2019

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

#include<stdafx.h>#include<stdio.h>#include<glut.h>#include<math.h>

GLfloat b1=0;int flag=0;int k,i;int key_control=0;float fall=0,x_move=0,y_move=0;int ch=0;GLfloat ya = 0.0; // variables for appleGLfloat xa = 0.0;GLfloat step1 = 0.5; // for 1st bird and othersGLfloat step2 = 0.5; // for 2nd bird and othersGLfloat yy = 0.0; // variables for 1st birdGLfloat xx = 0.0;GLfloat ay = 0.0; // variables for 2nd birdGLfloat ax = 0.0;GLfloat by = 0.0; // variables for 3rd birdGLfloat bx = 0.0;GLfloat cy = 0.0; // variables for 4th birdGLfloat cx = 0.0;GLfloat dy = 0.0; // variables for 5th birdGLfloat dx = 0.0;

void sky(){

glBegin(GL_POLYGON); //top half of backgroundglColor3f(1.0,0.6,0.0);//BOTTOM LEFTglVertex2f(0.0,299.0);glColor3f(1.0,0.6,0.0); //BOTTOM RIGHTglVertex2f(1014.0,299.0);glColor3f(1.0,1.0,0.0); //TOP RIGHTglVertex2f(1014.0,699.0);glColor3f(1.0,1.0,0.0); // TOP LEFTglVertex2f(0.0,699.0);glEnd();

}

void ground(){

glBegin(GL_POLYGON); //bottom half of backgroundglColor3f(0.102,0.255,0.0);//BOTTOM LEFTglVertex2f(0.0,0.0);glColor3f(0.102,0.255,0.0); //BOTTOM RIGHTglVertex2f(1014.0,0.0);glColor3f(0.102,0.255,0.0); //TOP RIGHTglVertex2f(1014.0,299.0);glColor3f(0.102,0.255,0.0); // TOP LEFTglVertex2f(0.0,299.0);glEnd();

glColor3f(0.102,0.153,0.0); //mountainglVertex3f(0.0,0.0,0.0);glBegin(GL_POLYGON);

Page 2: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glColor3f(0.6,0.8,0.1);glVertex3f(50.0,0.0,0.0);

glColor3f(0.6,0.8,0.1);glVertex3f(150.0,0.0,0.0);glColor3f(0.6,0.8,0.1);glVertex3f(250.0,0.0,0.0);for(i=0;i<=250;i++)

glVertex3f(i*5.334,300.0+50.0*sin(i/360.0*2*3.1459),0.0);glColor3f(0.6,0.8,0.1);glVertex3f(640.0,0.0,0.0);glEnd();

glBegin(GL_POLYGON); //big mountain 3glColor3f(0.1,0.8,0.1);glVertex3f(0.0,0.0,0.0);glColor3f(0.1,0.5,0.1);glVertex3f(620.0,50.0,0.0);glColor3f(0.1,0.5,0.1);glVertex3f(622.0,0.0,0.0);glColor3f(0.1,0.5,0.1);glVertex3f(624.0,0.0,0.0);for(i=0;i<=250;i++)

glVertex3f(i*2.56,240.0+50.0*sin(i/360.0*2*3.1459),0.0);glColor3f(0.1,0.5,0.1);glVertex3f(900.0,0.0,0.0);glColor3f(0.1,0.5,0.1);glVertex3f(1.0,0.0,0.0);glEnd();

}// square closed

void sun(){

glPushMatrix();glFlush();glLoadIdentity();glColor3f(1.0,0.6,0.0);glTranslatef(814.0,614.0,0.0);glutSolidSphere(30,58,25);glPopMatrix();glLoadIdentity();

}

void man(){

glPushMatrix(); //faceglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(500.0,250.0,220.0);glutSolidSphere(40,58,58);glPopMatrix();glLoadIdentity(); glPushMatrix();//left eyeglFlush();glLoadIdentity();glColor3f(0.0,0.0,0.0);glTranslatef(487.0,255.0,0.0);

Page 3: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//right eyeglFlush();glLoadIdentity();glColor3f(0.0,0.0,0.0);glTranslatef(513.0,255.0,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();if(y_move<135){ glPushMatrix();//left eyelid

glFlush(); glLoadIdentity(); glColor3f(1.0,0.8,0.6); glTranslatef(487.0,258,0.0); glutSolidSphere(6,25,25); glPopMatrix(); glLoadIdentity(); glPushMatrix();//right eyelid glFlush(); glLoadIdentity(); glColor3f(1.0,0.8,0.6); glTranslatef(513.0,258.0,0.0); glutSolidSphere(6,25,25); glPopMatrix();

glLoadIdentity();}glPushMatrix();//mouthglFlush();glLoadIdentity();glColor3f(0.0,0.0,0.0);glTranslatef(500.0,232.0,0.0);glutSolidSphere(9,25,25);glPopMatrix();glLoadIdentity();if(y_move<490){

glPushMatrix();//mouthglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(500.0,235.0,0.0);glutSolidSphere(9,25,25);glPopMatrix();glLoadIdentity();

}glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(500.0,290.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();

Page 4: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(485.0,288.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(515.0,288.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(528.0,280.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(470.0,280.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0,265.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0,265.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();

glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0,248.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hair

Page 5: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0,248.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0,230.0,0.0);glutSolidSphere(8,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0,230.0,0.0);glutSolidSphere(8,25,25);glPopMatrix();glLoadIdentity();

glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0,217.0,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0,217.0,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //bodyglFlush();glLoadIdentity();glColor3f(0.4,0.5,0.6);glTranslatef(500.0,165.0,-50.0);glutSolidSphere(50,25,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //bodyglFlush();glLoadIdentity();glColor3f(0.4,0.5,0.6);glTranslatef(500.0,155.0,-50.0);glutSolidSphere(50,58,58);glPopMatrix();glLoadIdentity();glColor3f(0.4,0.5,0.6); // handglBegin(GL_POLYGON);

Page 6: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glVertex2f(455,165);glVertex2f(545,165);glVertex2f(545,195);glVertex2f(455,195);glEnd();glPushMatrix(); //left palmglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(480.0,180.0,30.0);glutSolidSphere(15,58,58);glPopMatrix();glLoadIdentity();glPushMatrix(); //left elbowglFlush();glLoadIdentity();glColor3f(0.4,0.5,0.6);glTranslatef(450.0,180.0,30.0);glutSolidSphere(15,58,58);glPopMatrix();glLoadIdentity();glPushMatrix(); //right elbowglFlush();glLoadIdentity();glColor3f(0.4,0.5,0.6);glTranslatef(550.0,180.0,30.0);glutSolidSphere(15,58,58);glPopMatrix();glLoadIdentity();glColor3f(0.8,0.5,0.2); //left legglBegin(GL_POLYGON);glVertex2f(452.5,145);glVertex2f(497.5,145);glVertex2f(490,45);glVertex2f(460,45);glEnd();glColor3f(0.8,0.5,0.2); //right legglBegin(GL_POLYGON);glVertex2f(503.5,145);glVertex2f(547.5,145);glVertex2f(540,45);glVertex2f(509,45);glEnd();glPushMatrix(); //left kneeglFlush();glLoadIdentity();glColor3f(0.8,0.5,0.2);glTranslatef(475.0,145.0,30.0);glutSolidSphere(22.5,58,58);glPopMatrix();glLoadIdentity();glPushMatrix(); //right kneeglFlush();glLoadIdentity();glColor3f(0.8,0.5,0.2);glTranslatef(525.0,145.0,30.0);glutSolidSphere(22.5,58,58);

Page 7: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glPopMatrix();glLoadIdentity();glLoadIdentity(); //left shoeglColor3f(0.0,0.0,0.0);glTranslatef(475.0,45.0,0.0);glRotatef(180.0,1.0,0.0,0.0);glBegin(GL_POLYGON);for(k=0;k<180;k++)

glVertex3f(15*cos(k*3.14159/180.0),15*sin(k*3.14159/180.0),0.0);glEnd();

glFlush();glLoadIdentity(); //right shoeglColor3f(0.0,0.0,0.0);glTranslatef(525.0,45.0,0.0);glRotatef(180.0,1.0,0.0,0.0);glBegin(GL_POLYGON);for(k=0;k<180;k++)

glVertex3f(15*cos(k*3.14159/180.0),15*sin(k*3.14159/180.0),0.0);glEnd();

glFlush();}

void tree(){

glPushMatrix(); //trunkglFlush();glLoadIdentity();glTranslatef(-50.0,92.0,0.0);glColor3f(0.3,0.0,0.0);glBegin(GL_POLYGON);glVertex2f(500,10);glVertex2f(600,10);glVertex2f(600,350);glVertex2f(500,350);glEnd();

glPushMatrix(); //leavesglFlush();glLoadIdentity();glColor3f(0.0,0.153,0.0);glTranslatef(505.0,480.0,0.0);glutSolidSphere(200,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(320.0,430.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(685.0,450.0,0.0);glutSolidSphere(50,58,25);

Page 8: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(330.0,510.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(680.0,520.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(350.0,370.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(660.0,380.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(360.0,580.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(425.0,630.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(495.0,650.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();

Page 9: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(505.0,480.0,0.0);glutSolidSphere(200,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(640.0,600.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(580.0,640.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(410.0,330.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.0,0.3,0.0);glTranslatef(590.0,330.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 1glTranslatef(500.0+x_move,500.0-y_move-fall,100.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 2glTranslatef(370.0,550.0,30.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();

Page 10: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 3glTranslatef(400.0,380.0,30.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 4glTranslatef(630.0,400.0,30.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 5glTranslatef(670.0,550.0,30.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 6glTranslatef(520.0,650.0,30.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();glFlush();glLoadIdentity();glColor3f(0.6,0.0,0.0);//apple 7glTranslatef(325.0,530.0,30.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();

}

void apple_bite(){

glPushMatrix(); //apple_BglFlush();glLoadIdentity();glColor3f(0.8,0.0,0.2);glTranslatef(830.0,330.0,0.0);glutSolidSphere(60,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //apple_S1glFlush();glLoadIdentity();glColor3f(0.8,0.0,0.2);glTranslatef(810,355.0,0.0);

Page 11: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glutSolidSphere(38,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //apple_S2glFlush();glLoadIdentity();glColor3f(0.8,0.0,0.2);glTranslatef(850,355.0,0.0);glutSolidSphere(38,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //bite_TglFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(880.0,350.0,500.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); // bite_BglFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(880.0,320.0,500.0);glutSolidSphere(20,58,25);glPopMatrix();glLoadIdentity();glColor3f(0.3,0.0,0.0); // apple nodeglBegin(GL_TRIANGLES);glVertex2f(830.0,385.0);glVertex2f(823.0,425.0);glVertex2f(837.0,425.0);glEnd();

}

void sleeping(){

GLint p=330.0,q=80.0;glPushMatrix(); //faceglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(500.0+p,250.0+q,220.0);glutSolidSphere(40,58,58);glPopMatrix();glLoadIdentity();glPushMatrix();//left eyeglFlush();glLoadIdentity();glColor3f(0.0,0.0,0.0);glTranslatef(487.0+p,255.0+q,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//right eyeglFlush();glLoadIdentity();

Page 12: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glColor3f(0.0,0.0,0.0);glTranslatef(513.0+p,255.0+q,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//left eyelidglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(487.0+p,258.0+q,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//right eyelidglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(513.0+p,258.0+q,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//mouthglFlush();glLoadIdentity();glColor3f(0.0,0.0,0.0);glTranslatef(500.0+p,232.0+q,0.0);glutSolidSphere(9,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//mouthglFlush();glLoadIdentity();glColor3f(1.0,0.8,0.6);glTranslatef(500.0+p,235.0+q,0.0);glutSolidSphere(9,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(500.0+p,290.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(485.0+p,288.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);

Page 13: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glTranslatef(515.0+p,288.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(528.0+p,280.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(470.0+p,280.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0+p,265.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0+p,265.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();

glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0+p,248.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0+p,248.0+q,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0+p,230.0+q,0.0);

Page 14: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glutSolidSphere(8,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0+p,230.0+q,0.0);glutSolidSphere(8,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(540.0+p,217.0+q,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glPushMatrix();//hairglFlush();glLoadIdentity();glColor3f(0.6,0.6,0.6);glTranslatef(460.0+p,217.0+q,0.0);glutSolidSphere(6,25,25);glPopMatrix();glLoadIdentity();glLineWidth(1.0); //snoringglColor3f(0.0,0.0,0.0);glBegin(GL_LINES);glVertex2f(890.0,340.0);glVertex2f(900.0,340.0);glVertex2f(900.0,340.0);glVertex2f(890.0,330.0);glVertex2f(890.0,330.0);glVertex2f(900.0,330.0);glEnd();glLineWidth(2.0);glColor3f(0.0,0.0,0.0);glBegin(GL_LINES);glVertex2f(910.0,350.0);glVertex2f(925.0,350.0);glVertex2f(925.0,350.0);glVertex2f(910.0,335.0);glVertex2f(910.0,335.0);glVertex2f(925.0,335.0);glEnd();glLineWidth(3.0);glColor3f(0.0,0.0,0.0);glBegin(GL_LINES);glVertex2f(930.0,360.0);glVertex2f(950.0,360.0);glVertex2f(950.0,360.0);glVertex2f(930.0,340.0);glVertex2f(930.0,340.0);glVertex2f(950.0,340.0);glEnd();

Page 15: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

}

void thought(){

if(y_move>500){

glPushMatrix();//cloud1 glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(560.0,258,0.0);glutSolidSphere(8,25,25);glPopMatrix();glLoadIdentity();

}if(y_move>525){

glPushMatrix();//cloud2glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(580.0,275.0,0.0);glutSolidSphere(12,25,25);glPopMatrix();glLoadIdentity();

}if(y_move>550){

// small cloudglPushMatrix(); //1glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(600.0,295.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity(); glPushMatrix();// 2glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(612.0,295.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //3glFlush();glLoadIdentity(); glColor3f(1.0,1.0,1.0);glTranslatef(620.0,300.0,0.0);glutSolidSphere(10,25,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //4glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);

Page 16: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glTranslatef(609.0,307.0,0.0);glutSolidSphere(11,25,25);glPopMatrix();glLoadIdentity();//bigger cloudglPushMatrix(); //centre 1glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(800.0,350.0,0.0);glutSolidSphere(125,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //centre 2glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(860.0,350.0,0.0);glutSolidSphere(125,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();//big1glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(760.0,435.0,0.0);glutSolidSphere(60,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();//big2glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(700.0,390.0,0.0);glutSolidSphere(60,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();//big3glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(860.0,450.0,0.0);glutSolidSphere(60,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();//big4glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(745.0,268.0,0.0);glutSolidSphere(60,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();//big5glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);

Page 17: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glTranslatef(850.0,265.0,0.0);glutSolidSphere(70,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); // s1glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(680.0,320.0,0.0);glutSolidSphere(45,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //s2glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(930.0,260.0,0.0);glutSolidSphere(30,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //s3glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(950.0,325.0,0.0);glutSolidSphere(50,58,25);glPopMatrix();glLoadIdentity();glPushMatrix(); //s4glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(940.0,440.0,0.0);glutSolidSphere(30,58,25);glPopMatrix();glLoadIdentity();glPushMatrix();//s5glFlush();glLoadIdentity();glColor3f(1.0,1.0,1.0);glTranslatef(970.0,390.0,0.0);glutSolidSphere(40,58,25);glPopMatrix();glLoadIdentity();if(ch==1)

apple_bite();if(ch==2)

sleeping();}

}

void tree1(){

glPushMatrix(); glFlush();glLoadIdentity();//very important for translateglTranslatef(-300.0,60.0,0.0);

Page 18: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glColor3f(0.3,0.0,.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}

void tree2(){

glLoadIdentity(); glTranslatef(-250.0,60.0,0.0);glColor3f(0.3,0.0,0.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}

void tree3()

Page 19: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

{glPushMatrix(); glFlush();glLoadIdentity();glTranslatef(-175.0,80.0,0.0);glColor3f(0.3,0.0,.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}

void tree4(){

glPushMatrix(); glFlush();glLoadIdentity();glTranslatef(-125.0,87.0,0.0);glColor3f(0.3,0.0,.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);

Page 20: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}

void tree5(){

glPushMatrix(); glFlush();glLoadIdentity();glTranslatef(-50.0,92.0,0.0);glColor3f(0.3,0.0,.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}

void tree6(){

glPushMatrix(); glFlush();glLoadIdentity();glTranslatef(385.0,90.0,0.0);glColor3f(0.3,0.0,.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);

Page 21: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}

void tree7(){

glPushMatrix(); glFlush();glLoadIdentity();glTranslatef(635.0,52.0,0.0);glColor3f(0.3,0.0,.0);glBegin(GL_POLYGON);glVertex2f(330,247);glVertex2f(340,247);glVertex2f(340,337);glVertex2f(330,337);glEnd();glColor3f(0.1,0.5,0.1);glBegin(GL_POLYGON);glVertex2f(335,337);glVertex2f(290,320);glVertex2f(325,357);glVertex2f(300,337);glVertex2f(330,377);glVertex2f(310,357);glVertex2f(339,407);glVertex2f(370,355);glVertex2f(345,377);glVertex2f(375,335);glVertex2f(345,357);glVertex2f(380,320);glVertex2f(340,337);glEnd();glPopMatrix();

}void trees(){

tree1();tree2();tree3();tree4();tree5();tree6();tree7();

}void bird1(){

glBegin(GL_POLYGON);

Page 22: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glColor3f(0.0,0.0,0.0);glVertex2f(522.0,560.0);glColor3f(0.0 ,0.0,0.0);// blackglVertex2f(548.0,550.0);glColor3f(0.0,0.0,0.0);glVertex2f(535.0,565.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(550.0,550.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(520.0,565.0);glColor3f( 0.0,0.0,0.0);glVertex2f(530.0,547.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(538.0,559.0);glColor3f(1.0,1.0,1.0);glVertex2f(555.0,549.0);glEnd();

}

void bird2(){

glBegin(GL_POLYGON);glColor3f(0.0,0.0,0.0);glVertex2f(422.0,560.0);glColor3f(0.0,0.0,0.0);// blackglVertex2f(448.0,550.0);glColor3f(0.0,0.0,0.0);glVertex2f(435.0,565.0);glColor3f(0.0,0.0,0.0);glVertex2f(450.0,550.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(420.0,565.0);glColor3f( 0.0,0.0,0.0);glVertex2f(430.0,547.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(438.0,559.0);glColor3f(1.0,1.0,1.0);glVertex2f(455.0,549.0);glEnd();

}

void bird3(){

glBegin(GL_POLYGON);glColor3f(0.0,0.0,0.0);glVertex2f(222.0,460.0);glColor3f(0.0 ,0.0,0.0);// blackglVertex2f(248.0,450.0);glColor3f(0.0,0.0,0.0);glVertex2f(235.0,465.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(250.0,450.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(220.0,465.0);glColor3f( 0.0,0.0,0.0);glVertex2f(230.0,447.0);glColor3f(0.0 ,0.0,0.0);

Page 23: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

glVertex2f(238.0,459.0);glColor3f(1.0,1.0,1.0);glVertex2f(255.0,449.0);glEnd();

}

void bird4(){

glBegin(GL_POLYGON);glColor3f(0.0,0.0,0.0);glVertex2f(622.0,560.0);glColor3f(0.0 ,0.0,0.0);// blackglVertex2f(648.0,550.0);glColor3f(0.0,0.0,0.0);glVertex2f(635.0,565.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(650.0,550.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(620.0,565.0);glColor3f( 0.0,0.0,0.0);glVertex2f(630.0,547.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(638.0,559.0);glColor3f(1.0,1.0,1.0);glVertex2f(655.0,549.0);glEnd();

}

void bird5(){

glBegin(GL_POLYGON);glColor3f(0.0,0.0,0.0);glVertex2f(922.0,460.0);glColor3f(0.0 ,0.0,0.0); // blackglVertex2f(948.0,450.0);glColor3f(0.0,0.0,0.0);glVertex2f(935.0,465.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(950.0,450.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(920.0,465.0);glColor3f( 0.0,0.0,0.0);glVertex2f(930.0,447.0);glColor3f(0.0 ,0.0,0.0);glVertex2f(938.0,459.0);glColor3f(1.0,1.0,1.0);glVertex2f(955.0,449.0);glEnd();

}

void move(void){

if(key_control==1) //for apple{

if(fall<85)fall+=5;

else

Page 24: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

if(x_move<45)x_move+=6;

elsex_move+=3;

y_move+=5;}xa+=step1;ya-=step1;if((xa==500.0)&&(ya<185.0)){

xa+=5.0;ya-=5.0;

}yy+=step1; // for bird 1xx-=step1;if((xx>15.0)&&(yy>10.0)){

xx-=10.0;yy-=10.0;

}ay+=step2;// for bird 2ax-=step2;if((ax>10.0)&&(ay>5.0)){

ax-=10.0;ay-=10.0;

}by+=step2; // for 3rd birdbx+=step2;if((bx>10.0)&&(by>5.0)){

bx-=10.0;by-=10.0;

}cy+=step1; // for 4th birdcx+=step1;if((cx>10.0)&&(cy>5.0)){

cx-=10.0;cy-=10.0;

}dy+=step1; // for 5th birddx+=step1;if((dx>10.0)&&(dy>5.0)){

dx-=10.0;dy-=10.0;

}glutPostRedisplay();

}

void menu(int value){

switch(value) {

case 1:ch=1;break;

Page 25: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

case 2:ch=2;break;case 3:flag=1;break;case 4:exit(0);break;

}}

void myinit(){

glPointSize(4.0);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(0.0,1014.0,0.0,699.0,500.0,-600.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();glClearColor(0.0,0.0,0.0,1.0); //background screen colour

}

void keyboard(unsigned char key,int x,int y){

if(key=='f'||key=='F')key_control=1;

}

void msg(int x, int y,char *str){

glRasterPos2d(x,y);for(char* c=str;*c!='\0';c++)

glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,*c);}

void start(){

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );glColor3f(1.0,1.0,1.0);glPointSize(3);msg(130.0,500.0,"NEWTON'S LAW OF GRAVITY");msg(130.0,480.0,"______________________________________________");

glColor3f(0.0,1.0,0.0);msg(200,250,"PROJECT BY");glColor3f(0.0,1.0,0.0);msg(150.0,200.0,"SRINIVASA T K");msg(150.0,150.0,"3GU13CS022");msg(300.0,200.0,"VINAY KUMAR T S");msg(320.0,150.0,"3GU13CSO25");

glutSwapBuffers(); glFlush();

}

void display(void){

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glLoadIdentity();if(flag==1)

start();

Page 26: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;

else if(flag==0){

sky();ground();trees();sun();tree();man();thought();glPopMatrix();glFlush();glTranslatef(xx,yy,0.0); // to move bird 1bird1();glPopMatrix();glFlush();glTranslatef(ax,ay,0.0); // to move bird 2bird2();glPopMatrix();glFlush();glTranslatef(bx,by,0.0); // to move bird 3bird3();glPopMatrix();glFlush();glTranslatef(cx,cy,0.0); // to move bird 4bird4();glPopMatrix();glFlush();glTranslatef(dx,dy,0.0); // to move bird 5bird5();glPopMatrix();glFlush();glutPostRedisplay();glutSwapBuffers(); //USED WITH DOUBLE BUFFER

}}void main(int argc, char ** argv){

glutInit(&argc,argv);glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); // DOUBLE BUFFER

HELPS AVOID FLICKERINGglutInitWindowSize(1366,700);glutInitWindowPosition(0,0);glutCreateWindow("Newton");myinit();glutDisplayFunc(display);glutIdleFunc(move);glEnable(GL_LINE_STIPPLE);glutKeyboardFunc(keyboard);glutCreateMenu(menu);glutAddMenuEntry("HUNGRY NEWTON", 1);glutAddMenuEntry("LAZY NEWTON", 2);glutAddMenuEntry("THE END", 3);glutAddMenuEntry("CLOSE", 4);glutAttachMenu(GLUT_RIGHT_BUTTON);

glutMainLoop();}

Page 27: seenubabueducom.files.wordpress.com€¦ · Web view#include #include #include #include GLfloat b1=0; int flag=0; int k,i;