FirstRanker Logo

FirstRanker.com - FirstRanker's Choice is a hub of Question Papers & Study Materials for B-Tech, B.E, M-Tech, MCA, M.Sc, MBBS, BDS, MBA, B.Sc, Degree, B.Sc Nursing, B-Pharmacy, D-Pharmacy, MD, Medical, Dental, Engineering students. All services of FirstRanker.com are FREE

📱

Get the MBBS Question Bank Android App

Access previous years' papers, solved question papers, notes, and more on the go!

Install From Play Store

Download OU BE (B-Tech) CSE Mini Projects Code Create a simple walk through program using even

Download OU (Osmania University)BE (B-Tech) (Bachelor of Engineering) CSE Best Practicle Programs And Code Create a simple walk through program using even

This post was last modified on 27 January 2020

OU BE/B.Tech CSE Important Programs And Code (Mini Projects) || Osmania University


/* Create a simple walk through program using event handling mechanism */

#include<GL/glut.h>

int a=2,b=0,ww=600,wh=600,movd;

--- Content provided by⁠ FirstRanker.com ---

void polygon()

{

glColor3f(1.0,0.0,0.0);//red polygon

glBegin(GL_POLYGON);

glVertex2f(a-45,b);

--- Content provided by‌ FirstRanker.com ---

glVertex2f(a-15,b);

glVertex2f(a-15,b+30);

glVertex2f(a-45,b+30);

glEnd();

}

--- Content provided by‍ FirstRanker.com ---

void drawRoad()

{

glBegin(GL_QUADS);

glColor3f(0.5,0.5,0.5);

glVertex2f(-60, -600);

--- Content provided by⁠ FirstRanker.com ---

glVertex2f(60, -600);

glVertex2f(60, 600);

glVertex2f(-60, 600);

glEnd();

}

--- Content provided by‍ FirstRanker.com ---

void drawDivider()//white patch drawn in middle of road

{

glLoadIdentity();

glTranslatef(0, movd, 0);

for(int i = -600; i <= 600; i++)

--- Content provided by‍ FirstRanker.com ---

{

glColor3f(1, 1, 1);

glBegin(GL_QUADS);

glVertex2f(-8, 10 * 15 * i + 20);

glVertex2f(-8, 10 * 15 * i - 20);

--- Content provided by‍ FirstRanker.com ---

glVertex2f(8, 10 * 15 * i - 20);

glVertex2f(8, 10 * 15 * i + 20);

glEnd();

}

glLoadIdentity();

--- Content provided by‍ FirstRanker.com ---

}

void display()

{

glClearColor(0.0,1.0,0.3,1.0);

glClear(GL_COLOR_BUFFER_BIT);

--- Content provided by​ FirstRanker.com ---

drawRoad(); //for road

drawDivider(); //for divider

polygon(); //for object

glutSwapBuffers();

}

--- Content provided by‌ FirstRanker.com ---

void keyboard(unsigned char button, int x, int y)

{

a=2;

if(button==GLUT_KEY_LEFT)

if(button==GLUT_KEY_RIGHT)

--- Content provided by FirstRanker.com ---

a=60;

if(button==GLUT_KEY_DOWN)

movd=movd+20;

if(button==GLUT_KEY_UP)

movd=movd-20;

--- Content provided by⁠ FirstRanker.com ---

}

glutPostRedisplay();

}

void reshape (int w, int h)

{

--- Content provided by​ FirstRanker.com ---

glViewport(0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluOrtho2D(-ww,ww,-wh,wh);

glMatrixMode(GL_MODELVIEW);

--- Content provided by FirstRanker.com ---

glLoadIdentity();

}

int main(int argc, char **argv)

{

glutInit(&argc, argv);

--- Content provided by⁠ FirstRanker.com ---

glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_DOUBLE);

glutInitWindowSize(ww,wh);

glutInitWindowPosition(100,100);

glutCreateWindow("Walk Game");

glutSpecialFunc(keyboard);

--- Content provided by⁠ FirstRanker.com ---

glutDisplayFunc(display);

glutReshapeFunc(reshape);

glutMainLoop();

}

Output Screen

--- Content provided by‌ FirstRanker.com ---

FirstRanker.com



This download link is referred from the post: OU BE/B.Tech CSE Important Programs And Code (Mini Projects) || Osmania University

--- Content provided by​ FirstRanker.com ---