Exemple #1
0
void GameMenu(Game *game, int w, int h)
{
    static int si = 0;
    if (si == 0) {
        initialize_fonts();
        si++;
    }
    //Game Menu
    glBegin(GL_LINES);
    Rect r;
    r.bot = h - 10;
    r.left = 10;
    r.center = 0;
    ggprint8b(&r, 16, 0, "");
    ggprint8b(&r, 16, 0, "Toggles - N: Nick, L: Lizandro, C: Charles, R: Roy");
    ggprint8b(&r, 16, 0, "Spacebar - Reload");
    ggprint8b(&r, 16, 0, "Left click - Shoot");
    ggprint8b(&r, 16, 0, "1 - 9mm");
    ggprint8b(&r, 16, 0, "2 - Sniper");
    ggprint8b(&r, 16, 0, "3 - ShotGun");
    ggprint8b(&r, 16, 0, "Nround: %i / %i", game->nbullets, game->maxbullets);
    ggprint8b(&r, 16, 0, "Kills: %i", game->nkills);
    ggprint8b(&r, 16, 0, "Player: %s", game->name);
    // ggprint8b(&r, 16, 0, "Score: Sounds");
    glEnd();
}
Exemple #2
0
void render(void)
{
	Rect r;
	glClear(GL_COLOR_BUFFER_BIT);
	//
	r.bot = yres - 20;
	r.left = 10;
	r.center = 0;
	ggprint8b(&r, 16, 0x00887766, "CS-371 Lab7");
	ggprint8b(&r, 16, 0x008877aa, "3 - simple shapes");
	ggprint8b(&r, 16, 0x008877aa, "4 - animated shapes");
	ggprint8b(&r, 16, 0x008877aa, "5 - animated 3D shapes");
	ggprint8b(&r, 16, 0x008877aa, "6 - rotating lighted cube");
	ggprint8b(&r, 16, 0x008877aa, "7 - basketball on court");
	ggprint8b(&r, 16, 0x008877aa, "8 - rotation on chosen axis");
	ggprint8b(&r, 16, 0x008877aa, "9 - Star Fox Arwing");//
	//Just draw a simple square
	switch(lesson_num) {
		case 0:
		case 1: {
				float wid = 40.0f;
				glColor3ub(30,60,90);
				glPushMatrix();
				glTranslatef(pos[0], pos[1], pos[2]);
				glBegin(GL_QUADS);
					glVertex2i(-wid,-wid);
					glVertex2i(-wid, wid);
					glVertex2i( wid, wid);
					glVertex2i( wid,-wid);
				glEnd();
				glPopMatrix();
			}
			break;
		case 3:
			DrawGLScene3();
			break;
		case 4:
			DrawGLScene4();
			break;
		case 5:
			DrawGLScene5();
			break;
		case 6:
			LightedCube();
			break;
		case 7:
			DrawBasketball();
			break;
		case 8:
			finalExamQuestion();
			break;
        case 9:
            DrawGLScene9();
            break;
	}
}
Exemple #3
0
void render(Game *g)
{
	//float wid;
	Rect r;
	glClear(GL_COLOR_BUFFER_BIT);
	//
	r.bot = yres - 20;
	r.left = 10;
	r.center = 0;
	ggprint8b(&r, 16, 0x00ff0000, "cs335 - Asteroids");
	ggprint8b(&r, 16, 0x00ffff00, "n bullets: %i", g->nbullets);
	ggprint8b(&r, 16, 0x00ffff00, "n asteroids: %i", g->nasteroids);
	//-------------------------------------------------------------------------
	//Draw the ship
	glColor3fv(g->ship.color);
	glPushMatrix();
	glTranslatef(g->ship.pos[0], g->ship.pos[1], g->ship.pos[2]);
	//float angle = atan2(ship.dir[1], ship.dir[0]);
	glRotatef(g->ship.angle, 0.0f, 0.0f, 1.0f);
	glBegin(GL_TRIANGLES);
	//glVertex2f(-10.0f, -10.0f);
	//glVertex2f(  0.0f, 20.0f);
	//glVertex2f( 10.0f, -10.0f);
	glVertex2f(-12.0f, -10.0f);
	glVertex2f(  0.0f, 20.0f);
	glVertex2f(  0.0f, -6.0f);
	glVertex2f(  0.0f, -6.0f);
	glVertex2f(  0.0f, 20.0f);
	glVertex2f( 12.0f, -10.0f);
	glEnd();
	glColor3f(1.0f, 0.0f, 0.0f);
	glBegin(GL_POINTS);
	glVertex2f(0.0f, 0.0f);
	glEnd();
	glPopMatrix();
	if (keys[XK_Up]) {
		int i;
		//draw thrust
		Flt rad = ((g->ship.angle+90.0) / 360.0f) * PI * 2.0;
		//convert angle to a vector
		Flt xdir = cos(rad);
		Flt ydir = sin(rad);
		Flt xs,ys,xe,ye,r;
		glBegin(GL_LINES);
		for (i=0; i<16; i++) {
			xs = -xdir * 11.0f + rnd() * 4.0 - 2.0;
			ys = -ydir * 11.0f + rnd() * 4.0 - 2.0;
			r = rnd()*40.0+40.0;
			xe = -xdir * r + rnd() * 18.0 - 9.0;
			ye = -ydir * r + rnd() * 18.0 - 9.0;
			glColor3f(rnd()*.3+.7, rnd()*.3+.7, 0);
			glVertex2f(g->ship.pos[0]+xs,g->ship.pos[1]+ys);
			glVertex2f(g->ship.pos[0]+xe,g->ship.pos[1]+ye);
		}
		glEnd();
	}
	//-------------------------------------------------------------------------
	//Draw the asteroids
	{
		Asteroid *a = g->ahead;
		while (a) {
			//Log("draw asteroid...\n");
			glColor3fv(a->color);
			glPushMatrix();
			glTranslatef(a->pos[0], a->pos[1], a->pos[2]);
			glRotatef(a->angle, 0.0f, 0.0f, 1.0f);
			glBegin(GL_LINE_LOOP);
			//Log("%i verts\n",a->nverts);
			for (int j=0; j<a->nverts; j++) {
				glVertex2f(a->vert[j][0], a->vert[j][1]);
			}
			glEnd();
			//glBegin(GL_LINES);
			//	glVertex2f(0,   0);
			//	glVertex2f(a->radius, 0);
			//glEnd();
			glPopMatrix();
			glColor3f(1.0f, 0.0f, 0.0f);
			glBegin(GL_POINTS);
			glVertex2f(a->pos[0], a->pos[1]);
			glEnd();
			a = a->next;
		}
	}
	//-------------------------------------------------------------------------
	//Draw the bullets
	{
		Bullet *b = g->bhead;
		while (b) {
			//Log("draw bullet...\n");
			glColor3f(1.0, 1.0, 1.0);
			glBegin(GL_POINTS);
			glVertex2f(b->pos[0],      b->pos[1]);
			glVertex2f(b->pos[0]-1.0f, b->pos[1]);
			glVertex2f(b->pos[0]+1.0f, b->pos[1]);
			glVertex2f(b->pos[0],      b->pos[1]-1.0f);
			glVertex2f(b->pos[0],      b->pos[1]+1.0f);
			glColor3f(0.8, 0.8, 0.8);
			glVertex2f(b->pos[0]-1.0f, b->pos[1]-1.0f);
			glVertex2f(b->pos[0]-1.0f, b->pos[1]+1.0f);
			glVertex2f(b->pos[0]+1.0f, b->pos[1]-1.0f);
			glVertex2f(b->pos[0]+1.0f, b->pos[1]+1.0f);
			glEnd();
			b = b->next;
		}
	}
}
Exemple #4
0
void render(Game *game)
{
	float w, h;
	// clears buffer
	glClear(GL_COLOR_BUFFER_BIT);
	//Draw shapes...
	Shape *s;
	glColor3ub(90,40,190);

	// render the boxes
	for(int i = 0; i < 5; ++i)
	{

		s = &game->box[i];
		glPushMatrix();
		glTranslatef(s->center.x, s->center.y, s->center.z);
		w = s->width;
		h = s->height;

		// draws a box
		glBegin(GL_QUADS);
		glVertex2i(-w,-h);
		glVertex2i(-w, h);
		glVertex2i( w, h);
		glVertex2i( w,-h);
		glEnd();
		glPopMatrix();

	}

	// draw circle
	Shape circle = game->circle;
	glPushMatrix();
	glTranslatef(circle.center.x, circle.center.y, circle.center.z);
	//filled circle
	float x1,y1,x2,y2;// x1, y1 are starting points

	x1 = 0.0,y1=0.0;
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x1,y1);

	double PI = 3.14159265;

	for (float angle=0.0; angle <= 360.0; angle += 1.0)
	{
		// change next point
		x2 = x1 + sin(angle * PI/180)*RADIUS;
		y2 = y1 + cos(angle * PI/180)*RADIUS;
		glVertex2f(x2,y2);
	}

	glEnd();
	glPopMatrix();
	//draw all particles here
	glPushMatrix();
	glColor3ub(150,160,250);

	int randColorWater = 0;
	for(int i = 0; i < game->n; ++i){
		Vec *c = &game->particle[i].s.center;
		w = 2;
		h = 2;
		glBegin(GL_QUADS);
		glVertex2i(c->x-w, c->y-h);
		glVertex2i(c->x-w, c->y+h);
		glVertex2i(c->x+w, c->y+h);
		glVertex2i(c->x+w, c->y-h);
		glEnd();
		glPopMatrix();	 
		randColorWater+= 10; 
	}

	// the text for the waterfall model
	Rect r;
	r.bot = WINDOW_HEIGHT- 65;
	r.left = 60;
	r.center = 0;
	int spacer = 50;
	ggprint8b(&r, spacer, 0x00FFFF00, "Requirements");
	r.left += 70;
	ggprint8b(&r, spacer, 0x00FFFF00, "Design");
	r.left += 50;
	ggprint8b(&r, spacer, 0x00FFFF00, "Coding");
	r.left += 50;
	ggprint8b(&r, spacer, 0x00FFFF00, "Testing");
	r.left += 35;
	ggprint8b(&r, spacer, 0x00FFFF00, "Maintenance");
}
Exemple #5
0
void render(Game *game)
{
	//upper-left and lower-right corners of a rectangle
	Rect rct;
	float w, h;
	glClear(GL_COLOR_BUFFER_BIT);
	//Draw shapes...

	//draw box
	Shape *s;
	glColor3ub(90,140,90);
	for (int i = 0; i < 5; i++) {		
		s = &game->box[i];
		glPushMatrix();
		glTranslatef(s->center.x, s->center.y, s->center.z);
		w = s->width;
		h = s->height;
		glBegin(GL_QUADS);
			glVertex2i(-w,-h);
			glVertex2i(-w, h);
			glVertex2i( w, h);
			glVertex2i( w,-h);
		glEnd();
		glPopMatrix();
	}

	const int n = 60;
	static Vec verts[n];
	static int firsttime = 1;
	float angle = 0.0;
	if (firsttime) {
		float incr = (PI * 2.0) / (float) n;
		for (int i = 0; i < n; i++) {
			verts[i].y = sin(angle) * game->circle.radius;
			verts[i].x = cos(angle) * game->circle.radius;
			angle += incr;
		}
		firsttime = 0;
	}

	//glColor3ub(90, 140, 90);
	//glPushMatric();
	glBegin(GL_TRIANGLE_FAN);
	for (int i = 0; i < n; i++) {
		glVertex2i(game->circle.center.x + verts[i].x,
			game->circle.center.y + verts[i].y);
	}
	glEnd();
	//glPopMatrix();

	//draw all particles here
	//for (int i = 0; i < game->n; i++) { 
		glPushMatrix();
		//glColor3ub(rnd() * 150, rnd() * 160, rnd() * 220);
		for (int i = 0; i < game-> n; i++) {
		    	glColor3ub(rnd() * 150, rnd() * 160, rnd() * 220);
	    		Vec *c = &game->particle[i].s.center;
	    		w = 2;
	    		h = 2;
	    		glBegin(GL_QUADS);
				glVertex2i(c->x-w, c->y-h);
				glVertex2i(c->x-w, c->y+h);
				glVertex2i(c->x+w, c->y+h);
				glVertex2i(c->x+w, c->y-h);
	    		glEnd();
	   		glPopMatrix();
		}
		//glPopMatrix();
	//}		

	//texts/fonts
	glEnable(GL_TEXTURE_2D);
	initialize_fonts();

	rct.bot = 585;
	rct.left = 90;
	ggprint8b (&rct, 16, 0x99CCFF, "Waterfall Model.");

	rct.bot = 570;
	rct.left = 100;
	ggprint8b (&rct, 16, 0x00ffff0, "Press b for bubbler.");

	rct.bot = 490;
	rct.left = 100;
	rct.center = 1;
	ggprint16 (&rct, 16, 0xFF0099, "Requirements.");

	rct.bot = 428;
	rct.left = 150;
	ggprint16 (&rct, 16, 0xFF0099, "Design.");

	rct.bot -= 45;
	rct.left += 70;
	ggprint16 (&rct, 16, 0xFF0099, "Coding.");

	rct.bot -= 45;
	rct.left += 70;
	ggprint16 (&rct, 16, 0xFF0099, "Testing.");

	rct.bot -= 40;
	rct.left += 90;
	ggprint16 (&rct, 16, 0xFF0099, "Maintenance.");

	//if(bubble) {
	    //if (game->n < MAX_PARTICLES) {
		//for (int i = 0; i < 10; i++) {
			//makeParticle(game, 120, 550);
		//}
	    //}
	//}
}
Exemple #6
0
void render(Game *game)
{
    float w, h;
    Rect r;
    glClear(GL_COLOR_BUFFER_BIT);
    unsigned int cref = 0x00FFFFF00;

    //Draw shapes...

    static int firsttime=1;
    static int verts[60][2];
    static int n = 60;
    if (firsttime) {
        float angle = 0.0;
        float inc = (3.14159 * 2.0) / (float)n;
        for (int i=0; i<n; i++) {
            verts[i][0] = cos(angle) * game->circle.radius
                          + game->circle.center.x;
            verts[i][1] = sin(angle) * game->circle.radius
                          + game->circle.center.y;
            angle += inc;
        }
        firsttime = 0;
    }

    glColor3ub(200,250,10);
    glPushMatrix();
    glBegin(GL_TRIANGLE_FAN);
    for (int i=0; i<n; i++) {
        glVertex2i(verts[i][0], verts[i][1]);
    }
    glEnd();
    glPopMatrix();






    //draw box
    Shape *s;
    glColor3ub(0, 0, 0);
    for (int j=0; j<15; j++) {
        s = &game->box[j];
        glPushMatrix();
        glTranslatef(s->center.x, s->center.y, s->center.z);
        w = s->width;
        h = s->height;
        glBegin(GL_QUADS);
        glVertex2i(-w,-h);
        glVertex2i(-w, h);
        glVertex2i( w, h);
        glVertex2i( w,-h);
        glEnd();
        glPopMatrix();
    }
    //draw all particles here
    for (int i=0; i<game->n; i++) {
        glPushMatrix();
        glColor3ub(100,100,250);
        Vec *c = &game->particle[i].s.center;
        w = 1;
        h = 2.5;
        glBegin(GL_QUADS);
        glVertex2i(c->x-w, c->y-h);
        glVertex2i(c->x-w, c->y+h);
        glVertex2i(c->x+w, c->y+h);
        glVertex2i(c->x+w, c->y-h);
        glEnd();
        glPopMatrix();
    }

    //The Text Section
    r.bot = yres + 145;
    r.left = 15;
    r.center = 0;
    ggprint8b(&r, 25, cref, "Requirements");

    r.bot = yres + 75;
    r.left = 100;
    r.center = 0;
    ggprint8b(&r, 25, cref, "Design");

    r.bot = yres -5;
    r.left = 225;
    r.center = 0;
    ggprint8b(&r, 25, cref, "Coding");

    r.bot = yres - 95;
    r.left = 300;
    r.center = 0;
    ggprint8b(&r, 25, cref, "Testing");

    r.bot = yres - 155;
    r.center = 0;
    r.left = 400;
    ggprint8b(&r, 25, cref, "Maintenance");


}
Exemple #7
0
extern void render(Game *g)
{
//GLuint silhouetteTexture;
//GLuint silhouette_player_Texture;
//std::cout<<"multi: " << g->player1.multi << "\n";
        //float wid;
        if (g->nzombies == 0) {
                init(g);
                std::cout<<"here\n";
        }

        Rect r;
        glClear(GL_COLOR_BUFFER_BIT);
        sscreen_background(g->zhead->zTexture, 1.0, 1.0, 1.0, 1.0);

        //draw loot
        Loot *l = new Loot;
        l = g->lhead;
        while (l != NULL) {
                struct timespec bt;
                clock_gettime(CLOCK_REALTIME, &bt);
                double ts = timeDiff(&l->lootTimer, &bt);
                if (ts > 3) {
                        //MAKE IT BLINK!!!!!!!!
                        if (ts < 3.15)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                        else if(ts > 3.30 && ts < 3.45)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                        else if(ts > 3.60 && ts < 3.75)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                        else if(ts > 3.90 && ts < 4.05)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                        else if(ts > 4.20 && ts < 4.35)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                        else if(ts > 4.50 && ts < 4.65)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
 			else if(ts > 4.80 && ts < 5.00)
                                lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                } else if (ts > 5 || l->type == 0) {
                        //time to delete loot
                        deleteLoot(g,l);
                } else {
                        lootDraw(l->lootTex, l ,1.0, 1.0, 1.0, 1.0);
                }
                l = l->next;

        }
        //
        r.bot = yres - 64;
        r.left = 10;
        r.center = 0;
        ggprint16(&r, 32, 0x0011ff11, "PLAYER 1 SCORE: %i", g->player1.score);
        ggprint16(&r, 16, 0x00ff1111, "MULTI         : %.3g", g->player1.multi);

        ggprint8b(&r, 16, 0x00ff1111, "Zone %i, Wave %i", g->zcnt, g->wcnt);
        ggprint8b(&r, 16, 0x00ff1111, "n bullets: %i", g->nbullets);
        ggprint8b(&r, 16, 0x00ff1111, "Zombies left: %i", g->nzombies);
        //-------------------------------------------------------------------------
        //Draw the player1
        glColor3fv(g->player1.color);
        glPushMatrix();
        glTranslatef(g->player1.pos[0], g->player1.pos[1], g->player1.pos[2]);
        //float angle = atan2(player1.dir[1], player1.dir[0]);
        //std::cout<<"angle = " << g->player1.angle << std::endl;
        
	if ( g->player1.bulletType == 2) {
        glBindTexture(GL_TEXTURE_2D, silhouette_player_Texture_2);
        }
        else if ( g->player1.bulletType == 3) {
        glBindTexture(GL_TEXTURE_2D, silhouette_player_Texture_3);
        }
        else {
        glBindTexture(GL_TEXTURE_2D, silhouette_player_Texture);
        }
	
        glRotatef(g->player1.angle, 0.0f, 0.0f, 1.0f);
        glEnable(GL_ALPHA_TEST);
        glAlphaFunc(GL_GREATER, 0.0f);
        glColor4ub(255,255,255,255);
        glBegin(GL_QUADS);
                //float w = g->player1.width;
                float w = 28.0f;
                glTexCoord2f(0.0f, 0.0f); glVertex2f(-w,  w);
                glTexCoord2f(1.0f, 0.0f); glVertex2f( w,  w);
                glTexCoord2f(1.0f, 1.0f); glVertex2f( w, -w);
                glTexCoord2f(0.0f, 1.0f); glVertex2f(-w, -w);
        glEnd();
        glPopMatrix();
        glBindTexture(GL_TEXTURE_2D, 0);
        glDisable(GL_ALPHA_TEST);
        //glRotatef(g->player1.angle, 0.0f, 0.0f, 1.0f);
        //glVertex2f(-10.0f, -10.0f);
        //glVertex2f(  0.0f, 20.0f);
        //glVertex2f( 10.0f, -10.0f);
        glColor3f(1.0f, 0.0f, 0.0f);
        glBegin(GL_POINTS);
        glVertex2f(0.0f, 0.0f);
        glEnd();
        glPopMatrix();
        if (g->player1.invuln) {
                float col[3] = {0.0, 0.0, 0.0};
                glColor3fv(col);
                glPushMatrix();
                glTranslatef(g->player1.pos[0], g->player1.pos[1], g->player1.pos[2]);
                glRotatef(g->player1.angle, 0.0f, 0.0f, 1.0f);
                glBegin(GL_TRIANGLES);
                glVertex2f(-12.0f, -10.0f);
                glVertex2f(  0.0f, 20.0f);
                glVertex2f(  0.0f, -6.0f);
                glVertex2f(  0.0f, -6.0f);
                glVertex2f(  0.0f, 20.0f);
                glVertex2f( 12.0f, -10.0f);
                glEnd();
                glColor3f(1.0f, 0.0f, 0.0f);
                glBegin(GL_POINTS);
                glVertex2f(0.0f, 0.0f);
                glEnd();
                glPopMatrix();
                //std::cout<< "blinking!" << "\n";
        }

        /*if (keys[XK_Up]) {
                int i;
                //draw thrust
                Flt rad = ((g->player1.angle+90.0) / 360.0f) * PI * 2.0;
                //convert angle to a vector
                Flt xdir = cos(rad);
                Flt ydir = sin(rad);
                Flt xs,ys,xe,ye,r;
                glBegin(GL_LINES);
                for (i=0; i<16; i++) {
                        xs = -xdir * 11.0f + rnd() * 4.0 - 2.0;
                        ys = -ydir * 11.0f + rnd() * 4.0 - 2.0;
                        r = rnd()*40.0+40.0;
                        xe = -xdir * r + rnd() * 18.0 - 9.0;
                        ye = -ydir * r + rnd() * 18.0 - 9.0;
                        glColor3f(rnd()*.3+.7, rnd()*.3+.7, 0);
                        glVertex2f(g->player1.pos[0]+xs,g->player1.pos[1]+ys);
                        glVertex2f(g->player1.pos[0]+xe,g->player1.pos[1]+ye);
                }
                glEnd();
        }*/
        //-------------------------------------------------------------------------
        //Draw the zombies
        {
                Zombie *a = g->ahead;
                int count = 1;
                while (a) {
                        //Log("draw asteroid...\n");
                        //glColor3fv(a->color);
			glColor3fv(g->player1.color);
                        glPushMatrix();
                        glTranslatef(a->pos[0], a->pos[1], a->pos[2]);
                        glBindTexture(GL_TEXTURE_2D, silhouetteTexture);
                        glRotatef(a->angle, 0.0f, 0.0f, 1.0f);
                        glEnable(GL_ALPHA_TEST);
                        glAlphaFunc(GL_GREATER, 0.0f);
                        glBegin(GL_QUADS);
                                // float w is zombie size
                                float w = 27.0f;
                                glTexCoord2f(0.0f, 0.0f); glVertex2f(-w,  w);
                                glTexCoord2f(1.0f, 0.0f); glVertex2f( w,  w);
                                glTexCoord2f(1.0f, 1.0f); glVertex2f( w, -w);
                                glTexCoord2f(0.0f, 1.0f); glVertex2f(-w, -w);
                        glEnd();
                        glPopMatrix();
                        glBindTexture(GL_TEXTURE_2D, 0);
                        glDisable(GL_ALPHA_TEST);
                        //glRotatef(a->angle, 0.0f, 0.0f, 1.0f);
                        //Log("%i verts\n",a->nverts);
                        //for (int j=0; j<a->nverts; j++) {
                        //      glVertex2f(a->vert[j][0], a->vert[j][1]);
                        //}

                        //glBegin(GL_LINES);
                        //      glVertex2f(0,   0);
                        //      glVertex2f(a->radius, 0);
                        //glEnd();
                        glColor3f(1.0f, 0.0f, 0.0f);
//                      glBegin(GL_POINTS);
//                      glVertex2f(a->pos[0], a->pos[1]);
                        glBegin(GL_POINTS);
                        glVertex2f(a->pos[0], a->pos[1]);
                        glEnd();
                        //std::cout<<"asteroid angle: " << a->angle << "\n";
                        count++;
                        a = a->next;
                }
        }
        //std::cout<<"player angle: " << g->player1.angle << "\n";
        //-------------------------------------------------------------------------
        //Draw the bullets
                //std::cout<<"player posxy: " << g->player1.pos[0] << ", " << g->player1.pos[1] << ", " << g->player1.pos[2] << "\n";
        bulletDraw(g->bhead, g);
        bulletDraw(g->chead, g);
        bulletDraw(g->dhead, g);
        //Draw Loot
        //sscreen_background(g->zhead->zTexture, 1.0, 1.0, 1.0, 1.0);
}
Exemple #8
0
void render(Game *game)
{
    float w, h;
    Rect r;
    glClear(GL_COLOR_BUFFER_BIT);//Clears the screen

    //Draw shapes...
    //creating text for boxes
    const char *text[5] = {"Requirement", "Design", "Coding", "Testing", "Maintenance"};
    //draw box
    Shape *s;
    for (int j = 0; j < 5; j++) {
        glColor3ub(255,0,255);
        s = &game->box[j];
        glPushMatrix();
        glTranslatef(s->center.x, s->center.y, s->center.z);
        w = s->width;
        h = s->height;
        r.left = s->width - 100 ;
        r.bot = s->height - 20 ;
        glBegin(GL_QUADS);
        glVertex2i(-w,-h);
        glVertex2i(-w, h);
        glVertex2i( w, h);
        glVertex2i( w,-h);
        glEnd();
        ggprint8b(&r, 32, 0xffffffff, text[j]);
        glPopMatrix();
    }

    //draw all particles here
    glPushMatrix();
    for (int i = 0; i < game->n; i++) {
        //Giving different shades of blue to particles
        glColor3ub(0,0,255 - 5*i);
        Vec *c = &game->particle[i].s.center;
        w = 3;
        h = 3;
        glBegin(GL_QUADS);
        glVertex2i(c->x-w, c->y-h);
        glVertex2i(c->x-w, c->y+h);
        glVertex2i(c->x+w, c->y+h);
        glVertex2i(c->x+w, c->y-h);
        glEnd();
        glPopMatrix();
    }

    //draw circle
    for (int k = 0; k < 1; k++) {
        Shape *c;
        c = &game->circle;
        float x, y, radius;
        x = c->center.x;
        y = c->center.y;
        radius = c->radius;
        glPushMatrix();
        glColor3ub(255,0,0);
        int triangleAmount = 90;
        float twicePi = 2.0f * M_PI;
        glBegin(GL_TRIANGLE_FAN);
        glVertex2f(x,y);    //center of circle
        for (int i = 0; i <= triangleAmount; i++) {
            glVertex2f(x + (radius * cos(i * twicePi / triangleAmount)),
                    y + (radius * sin(i * twicePi / triangleAmount)));
        }
        glEnd();
        glPopMatrix();
    }

}
Exemple #9
0
void render(Game *game)
{ 
    
	float w, h;
	glClear(GL_COLOR_BUFFER_BIT);
	//Draw shapes...
	//
	//circle
	static int firsttime=1;
	static int verts[60][2];
	static int n = 60;
	if (firsttime) {

            float angle = 0.0;
	        float inc = (3.14159 * 2.0) / (float)n;
	        for (int i=0; i<n; i++) {
	                verts[i][0] = cos(angle) * game->circle.radius + game->circle.center.x;
	                verts[i][1] = sin(angle) * game->circle.radius + game->circle.center.y;
	                angle += inc;
            }
	        firsttime=0;
    }
	glColor3ub(90,140,90);
    glPushMatrix();
	glBegin(GL_TRIANGLE_FAN);
	    for (int i=0; i<n; i++)
		        glVertex2i(verts[i][0], verts[i][1]);  
	glEnd();
	glPopMatrix();
		
    //press b to turn on bubbler
    if(bubbler){
	    for(int i=0; i<10; i++)
	         makeParticle(game, game->lastMousex, game->lastMousey);
    }

	//draw box
	Shape *s;
	glColor3ub(90,140,90);
	for (int j=0; j<5; j++){
	        s = &game->box[j];
	        glPushMatrix();
	        glTranslatef(s->center.x, s->center.y, s->center.z);
	        w = s->width;
	        h = s->height;
	        glBegin(GL_QUADS);
		    glVertex2i(-w,-h);
		    glVertex2i(-w, h);
		    glVertex2i( w, h);
		    glVertex2i( w,-h);
	        glEnd();
	        glPopMatrix();
    } 

	//draw all particles here
	for(int i=0; i<game->n; i++){
		    glPushMatrix();
		    glColor3ub(rnd()*150,rnd()*160,220);
		    Vec *c = &game->particle[i].s.center;
		    w = 2;
		    h = 2;
		    glBegin(GL_QUADS);
			glVertex2i(c->x-w, c->y-h);
			glVertex2i(c->x-w, c->y+h);
			glVertex2i(c->x+w, c->y+h);
			glVertex2i(c->x+w, c->y-h);
		    glEnd();
		    glPopMatrix();
	}
    Rect r[4];
    Rect re;
    Rect rec;
    glBindTexture(GL_TEXTURE_2D, 0);   
 
    r[0].bot =  495 - 5 * 60;
    r[0].left = 270 + 5 * 65;
    r[0].center = -100;
    r[1].bot =  495 - 5 * 60 + 45;
    r[1].left = 270 + 5 * 65 - 75;
    r[1].center = -100;      
    r[2].bot =  495 - 5 * 60 + 90;
    r[2].left = 270 + 5 * 65 - 150;
    r[2].center = -100;
    r[3].bot =  495 - 5 * 60 + 135;
    r[3].left = 270 + 5 * 65 - 225;
    r[3].center = -100;      
    re.bot =  495 - 5 * 60 + 180;
    re.left = 270 + 5 * 65 - 300;
    re.center = -100;      
    rec.bot =  495 - 5 * 60 + 225;
    rec.left = 270 + 5 * 65 - 375;
    rec.center = -100;      

    unsigned int cref = 0x00ffff;
    ggprint8b(&r[0], 16, cref, "Maintenance");
    ggprint8b(&r[1], 16, cref, "Testing");
    ggprint8b(&r[2], 16, cref, "Coding");
    ggprint8b(&r[3], 16, cref, "Design");
    ggprint8b(&re, 16, cref, "Requirements");
    ggprint16(&rec, 16, 0x00ffffff, "Waterfall Model");
}
Exemple #10
0
void render(Game *game)
{
    Rect r[6];
    float w, h;
    glClear(GL_COLOR_BUFFER_BIT);
    //Draw shapes...

    //Draw circle

    static int first = 1;
    static int vertices[60][2];
    static int x = 60;
    glColor3ub(50,0,0);
    if (first) {
	float angle = 0.0;
	float inc = (3.14159 * 2.0) / (float) x;

	for (int i = 0; i < x; i++) {
	    vertices[i][0] = cos(angle) * game->circle.radius + game->circle.center.x;
	    vertices[i][1] = sin(angle) * game->circle.radius + game->circle.center.y;
	    angle += inc;
	}
	first = 0;
    }

    glPushMatrix();
    glBegin(GL_TRIANGLE_FAN);
    for (int i = 0; i < x; i++) {
	glVertex2i(vertices[i][0], vertices[i][1]);
    }
    glEnd();
    glPopMatrix();


    //draw box
    Shape *s;
    glColor3ub(90,140,90);
    for (int k = 0; k < 5; k++) {
	s = &game->box[k];
	glPushMatrix();
	glTranslatef(s->center.x, s->center.y, s->center.z);
	w = s->width;
	h = s->height;
	glBegin(GL_QUADS);
	glVertex2i(-w,-h);
	glVertex2i(-w, h);
	glVertex2i( w, h);
	glVertex2i( w,-h);
	glEnd();
	glPopMatrix();
    }

    //draw all particles here
    glPushMatrix();
    glColor3ub(150,160,220);
    for (int i = 0; i < game->n; i++)
    {
	Vec *c = &game->particle[i].s.center;
	w = 2;
	h = 2;
	glBegin(GL_QUADS);
	glVertex2i(c->x-w, c->y-h);
	glVertex2i(c->x-w, c->y+h);
	glVertex2i(c->x+w, c->y+h);
	glVertex2i(c->x+w, c->y-h);
	glEnd();
	glPopMatrix();
    }


    //Enter text

    r[5].bot = WINDOW_HEIGHT - 20;
    r[5].left = 10;
    r[5].center = 0;
    unsigned int black = 0x0000000000;

    //ggprint8b(&r[5], 16, cref, "Waterfall Model");

    for (int k = 0; k < 5; k++) {
	s = &game->box[k];

	r[k].bot = s->center.y - 5;
	r[k].left = s->center.x;
	r[k].right = 1;

	if (k == 0) {
	    ggprint8b(&r[k],16,black, "Requirements");
	}
	if (k == 1) {
	    ggprint8b(&r[k],16,black, "Design");
	}
	if (k == 2) {
	    ggprint8b(&r[k],16,black, "Coding");
	}
	if (k == 3) {
	    ggprint8b(&r[k],16,black, "Testing");
	}
	if (k == 4) {
	    ggprint8b(&r[k],16,black, "Maintenance");
	}
    }
}
Exemple #11
0
void render(void)
{
	Rect r;

	//Clear the screen
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	//
	//
	//draw a quad with texture
	float wid = 120.0f;
	glColor3f(1.0, 1.0, 1.0);
	if (forest) {
		glBindTexture(GL_TEXTURE_2D, forestTexture);
		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2i(0, 0);
			glTexCoord2f(0.0f, 0.0f); glVertex2i(0, yres);
			glTexCoord2f(1.0f, 0.0f); glVertex2i(xres, yres);
			glTexCoord2f(1.0f, 1.0f); glVertex2i(xres, 0);
		glEnd();
	}
	if (show_bigfoot) {
		glPushMatrix();
		glTranslatef(bigfoot.pos[0], bigfoot.pos[1], bigfoot.pos[2]);
		if (!silhouette) {
			glBindTexture(GL_TEXTURE_2D, bigfootTexture);
		} else {
			glBindTexture(GL_TEXTURE_2D, silhouetteTexture);
			glEnable(GL_ALPHA_TEST);
			glAlphaFunc(GL_GREATER, 0.0f);
			glColor4ub(255,255,255,255);
		}
		glBegin(GL_QUADS);
			if (bigfoot.vel[0] > 0.0) {
				glTexCoord2f(0.0f, 1.0f); glVertex2i(-wid,-wid);
				glTexCoord2f(0.0f, 0.0f); glVertex2i(-wid, wid);
				glTexCoord2f(1.0f, 0.0f); glVertex2i( wid, wid);
				glTexCoord2f(1.0f, 1.0f); glVertex2i( wid,-wid);
			} else {
				glTexCoord2f(1.0f, 1.0f); glVertex2i(-wid,-wid);
				glTexCoord2f(1.0f, 0.0f); glVertex2i(-wid, wid);
				glTexCoord2f(0.0f, 0.0f); glVertex2i( wid, wid);
				glTexCoord2f(0.0f, 1.0f); glVertex2i( wid,-wid);
			}
		glEnd();
		glPopMatrix();
		//
		if (trees && silhouette) {
			glBindTexture(GL_TEXTURE_2D, forestTransTexture);
			glBegin(GL_QUADS);
				glTexCoord2f(0.0f, 1.0f); glVertex2i(0, 0);
				glTexCoord2f(0.0f, 0.0f); glVertex2i(0, yres);
				glTexCoord2f(1.0f, 0.0f); glVertex2i(xres, yres);
				glTexCoord2f(1.0f, 1.0f); glVertex2i(xres, 0);
			glEnd();
		}
		glDisable(GL_ALPHA_TEST);
	}

	glDisable(GL_TEXTURE_2D);
	//glColor3f(1.0f, 0.0f, 0.0f);
	//glBegin(GL_QUADS);
	//	glVertex2i(10,10);
	//	glVertex2i(10,60);
	//	glVertex2i(60,60);
	//	glVertex2i(60,10);
	//glEnd();
	//return;
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	if (show_rain)
		draw_raindrops();
	glDisable(GL_BLEND);
	glEnable(GL_TEXTURE_2D);
	//
	#ifdef USE_UMBRELLA
	if (show_umbrella)
		draw_umbrella();
	#endif //USE_UMBRELLA
	glBindTexture(GL_TEXTURE_2D, 0);
	//
	//
	r.bot = yres - 20;
	r.left = 10;
	r.center = 0;
	ggprint8b(&r, 16, 0, "B - Bigfoot");
	ggprint8b(&r, 16, 0, "F - Forest");
	ggprint8b(&r, 16, 0, "S - Silhouette");
	ggprint8b(&r, 16, 0, "T - Trees");
	ggprint8b(&r, 16, 0, "U - Umbrella");
	ggprint8b(&r, 16, 0, "R - Rain");
	ggprint8b(&r, 16, 0, "D - Deflection");
	ggprint8b(&r, 16, 0, "N - Sounds");
}
Exemple #12
0
void render(Game *game)
{
    float w, h;
    Rect r;
    glClear(GL_COLOR_BUFFER_BIT);
    r.bot = WINDOW_HEIGHT - 20;
    r.left = 10;
    r.center = 0;
    ggprint8b(&r, 16, 0x00FFFFFF, "Waterfall Model");
    //Draw shapes...

    const int n=40;
    static int firsttime = 1;
    static Vec vert[n];
    if (firsttime) {
        float ang = 0.0, inc = (3.14159 * 2.0) / (float)n;
        for (int i = 0; i<n; i++) {
            vert[i].x = cos(ang) * game->circle.radius;
            vert[i].y = sin(ang) * game->circle.radius;
            ang += inc;
        }
        firsttime = 0;
    glColor3ub(90,140,90);
    }

    //draw circle
    glColor3ub(90,140,90);
    glBegin(GL_LINE_LOOP);
    glColor3ub(90,140,90);
    for (int i = 0; i < n; i++) {
        glVertex2i(game->circle.center.x + vert[i].x, game->circle.center.y + vert[i].y);
    }
    glEnd();

    //draw box
    Shape *s;
    glColor3ub(90,140,90);
    
    const char* text[5] = {"Requirements", "Design", "Coding", "Testing", "Maintenance"};
    
    for (int i = 0; i < 5; i++) {
    glColor3ub(90,140,90);
    
    r.bot = WINDOW_HEIGHT - (110 + (i * 60));
    r.left = (60 + (i * 70));
    r.center = 0;

    s = &game->box[i];
    glPushMatrix();
    glTranslatef(s->center.x, s->center.y, s->center.z);
    w = s->width;
    h = s->height;
    glBegin(GL_QUADS);
    glVertex2i(-w,-h);
    glVertex2i(-w, h);
    glVertex2i( w, h);
    glVertex2i( w,-h);
    glEnd();
    glPopMatrix();
    
    ggprint8b(&r, 16, 0x00F3FF00, text[i]); //0x00ff0000
    
    }

    //draw all particles here
    glPushMatrix();
    glColor3ub(150,160,220);
    for (int i = 0; i < game->n; i++) {
    Vec *c = &game->particle[i].s.center;
    w = 2;
    h = 2;
    glBegin(GL_QUADS);
    glVertex2i(c->x-w, c->y-h);
    glVertex2i(c->x-w, c->y+h);
    glVertex2i(c->x+w, c->y+h);
    glVertex2i(c->x+w, c->y-h);
    glEnd();
    }
    glPopMatrix();
}