Exemplo n.º 1
0
int drawBitMap(char *bmp_name, int **points, int *counter, Parameter *params)
{

    int curheight = 0;
    int curwidth = 0;
    int pixel_buffer[params->width][params->height];
    FILE *fp = NULL;
    if((fp = fopen(bmp_name, "wb")) == NULL)
    {
        //Could not write file
        printf(MSG_WRITE);
        return 3;

    }
    BitMap *bmap;
    if((bmap = (BitMap*) calloc(1, sizeof(BitMap))) == NULL)
    {
        printf(MSG_OOM);
        return 2;
    }
    createHeader(params, bmap);
    fwrite(bmap, 1, sizeof(BitMap), fp);
    free(bmap);
    drawBackground(0x60D0FF, params, pixel_buffer);
    drawCannon(params, pixel_buffer);
    drawLine(points, *counter, 0, 0xFF0000, params, pixel_buffer);

    for(curheight = 0; curheight < params->height; curheight++)
        for(curwidth = 0; curwidth < params->width; curwidth++)
            fwrite( &pixel_buffer[curwidth][curheight], 3, 1, fp);
    fclose(fp);
    return 0;
}
Exemplo n.º 2
0
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();
}