コード例 #1
0
ファイル: cannon.cpp プロジェクト: paraggupta1993/Cannon
void display(void){



	adjustCamera();
	glClear(GL_COLOR_BUFFER_BIT);
	giveTexture();
	glPushMatrix();
	glTranslatef(demonX,demonY,0);
	giveTextureDemon();
	glPopMatrix();


	glPushMatrix();
	{
		//translating to the left-bottom corner of our boundary
		if(jumped){
			moveCannon();
		}
		glTranslatef(cannonBaseX ,cannonBaseY,0);
		glColor3f(BLACK);
		drawObstacles();
		//tranlating to the cannon's bottom
		glRotatef(rot_angle , 0 , 0 , 1);
		drawCannon();
		drawPiston();
		//draw Cannon Ball
		curBall->drawUnreleased();
	}
	glPopMatrix();
	displayScoreboard();
	updateDemon();
	//drawDemon();
	manageTurtles();

	//for every released ball...
	for(int i=0;i<balls.size();i++){
		balls[i]->drawReleased();
		//cout << balls[i]->ballX << " " << balls[i]->ballY << " " << balls[i]->ballVelX << " " << balls[i]->ballVelY << endl;
		if(balls[i]->stoped()){
			removeBall(i);
		}
	}
	ballTurtle();
	ballDemon();
	turtleCannon();
	glFlush();
	glutSwapBuffers();
}
コード例 #2
0
// This function runs every frame
void renderScene()
{
	// Clear the color buffer and the depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Clear the screen to white
	glClearColor(0.0, 0.0, 0.0, 1.0);

	// Tell OpenGL to use the shader program you've created.
	glUseProgram(0);

	// Draw the Gameobjects
	glLineWidth(2.5);
	glColor3f(0.2, 0.2, 0.8);
	glBegin(GL_QUADS);
	
	//Big container
	glVertex2fv((float *) &big.bottomLeft);
	glVertex2fv((float *)&big.bottomRight);
	glVertex2fv((float *)&big.topRight);
	glVertex2fv((float *)&big.topLeft);
	
	//small container
	glVertex2fv((float *)&small.bottomLeft);
	glVertex2fv((float *)&small.bottomRight);
	glVertex2fv((float *)&small.topRight);
	glVertex2fv((float *)&small.topLeft);

	//Tube joining the two containers
	glVertex2f(big.bottomRight.x, big.bottomRight.y);
	glVertex2f(small.bottomLeft.x, small.bottomLeft.y);
	glVertex2f(small.bottomLeft.x, small.bottomLeft.y + 0.02f);
	glVertex2f(big.bottomRight.x, big.bottomRight.y + 0.02f);

	glEnd();

	//The draw piston function draws the piston over the larger side. 
	//This is mainly done for representational purposes i.e. to make the example more obvious.
	drawPiston();
}