Question: Here is the code which draws soccer field i want to add in this code 2 plaerys and a ball with 2d animation can any

Here is the code which draws soccer field i want to add in this code 2 plaerys and a ball with 2d animation can any one help me how i need mouse click, keyboard and idle function to create animation in this game?

#include

void Draw() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.33, 1.0, 0.50); glBegin(GL_QUAD_STRIP); glVertex3f(0.1, 0.1, 0.0); glVertex3f(0.1, 0.9, 0.0); glVertex3f(0.9, 0.1, 0.0); //GreenYard Vertex glVertex3f(0.9, 0.9, 0.0); glEnd(); glFlush();

glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.5, 0.1, 0.0); //Mid Line ( Ground Divider ) glVertex3f(0.5, 0.9, 0.0); glEnd(); glFlush();

// left side of the Ground

glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.25, 0.25, 0.0); // Goal keeper Front line glVertex3f(0.25, 0.75, 0.0);

glEnd(); glFlush();

glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.1, 0.75, 0.0); //Goal Keeper left Line glVertex3f(0.25, 0.75, 0.0);

glEnd(); glFlush();

glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.1, 0.25, 0.0); //Goal Keeper Right Line glVertex3f(0.25, 0.25, 0.0);

glEnd(); glFlush();

glBegin(GL_QUAD_STRIP); glColor3f(1, 1, 1); glVertex3f(0.1, 0.35, 0.0); glVertex3f(0.1, 0.65, 0.0); //Inner White Quad glVertex3f(0.17, 0.35, 0.0); glVertex3f(0.17, 0.65, 0.0); glEnd(); glFlush();

// Right Side of the Ground glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.75, 0.25, 0.0); //Goal Keeper front line glVertex3f(0.75, 0.75, 0.0);

glEnd(); glFlush();

glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.75, 0.25, 0.0); //Goal Keeper Left Line glVertex3f(0.9, 0.25, 0.0);

glEnd(); glFlush();

glBegin(GL_LINES); glColor3f(0.0, 0.0, 0.0); glVertex3f(0.75, 0.75, 0.0); //Goal Keeper ki Right wali line glVertex3f(0.9, 0.75, 0.0);

glEnd(); glFlush();

glBegin(GL_QUAD_STRIP); glColor3f(1, 1, 1); glVertex3f(0.9, 0.35, 0.0); glVertex3f(0.9, 0.65, 0.0); glVertex3f(0.83, 0.35, 0.0); //Inner White Quad glVertex3f(0.83, 0.65, 0.0); glEnd(); glFlush();

}

void Initialize() { glClearColor(0.60, 0.40, 0.12, 0.20); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); }

int main(int iArgc, char** cppArgv) { glutInit(&iArgc, cppArgv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(900, 450); glutInitWindowPosition(200, 200); glutCreateWindow("Football Ground OpenGL"); Initialize(); glutDisplayFunc(Draw); glutMainLoop(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!