Exemplo n.º 1
0
void check_mouse(XEvent *e, Game *game)
{
	static int savex = 0;
	static int savey = 0;
	static int n = 0;

	if (e->type == ButtonRelease) {
	    return;
	}
	if (e->type == ButtonPress) {
	    if (e->xbutton.button == 1) {
		//Left button was pressed
		int y = WINDOW_HEIGHT - e->xbutton.y;
		makeParticle(game, e->xbutton.x, y);
		return;
	    }
	    if (e->xbutton.button == 3) {
		//Right button was pressed
		return;
	    }
	}
	//Did the mouse move?
	if (savex != e->xbutton.x || savey != e->xbutton.y) {
	    savex = e->xbutton.x;
	    savey = e->xbutton.y;
	    if (++n < 10)
		return;
	    int y = WINDOW_HEIGHT - e->xbutton.y;
	    makeParticle(game, e->xbutton.x, y);
	
	}
}
Exemplo n.º 2
0
void check_mouse(XEvent *e, Game *game)
{
	//static int savex = 0;
	//static int savey = 0;
	//static int n = 0;

	if (e->type == ButtonRelease) {
		return;
	}
	if (e->type == ButtonPress) {
		if (e->xbutton.button==1) {
			//Left button was pressed
			int y = WINDOW_HEIGHT - e->xbutton.y;
			for (int i=0; i<10; i++)
				makeParticle(game, e->xbutton.x, y);
			return;
		}
		if (e->xbutton.button==3) {
			//Right button was pressed
			return;
		}
	}
	//Did the mouse move?
	/*if (savex != e->xbutton.x || savey != e->xbutton.y) {
		savex = e->xbutton.x;
		savey = e->xbutton.y;
		int y = WINDOW_HEIGHT - e->xbutton.y;
		for (int i=0; i<10; i++)
			makeParticle(game, e->xbutton.x, y);
		//if (++n < 10)
		//	return;
		game->lastMousex = e->xbutton.x;
		game->lastMousey = y;
	}*/
}
Exemplo n.º 3
0
void doMakeParticles(Game *game){
   int y = START_Y;
   int x = START_X;
      for (int i=0;i<10; i++){
         makeParticle(game, x, y);
     }
}
Exemplo n.º 4
0
void movement(Game *game)
{
    Particle *p;
    if (game->bubbler) {
        for (int i = 0; i <= MAX_PARTICLES; i++) {
            makeParticle(game, game->lastMousex, game->lastMousey);
        }
    }

    if (game->n <= 0)
        return;

    for (int i = 0; i < game->n; i++) {
        p = &game->particle[i];
        p->s.center.x += p->velocity.x;
        p->s.center.y += p->velocity.y;
        p->velocity.y -= GRAVITY;

        //check for collision with shapes...
        Shape *s;
        for (int j = 0; j < 5; j++) {
            s = &game->box[j];
            if (p->s.center.y >= s->center.y - (s->height) &&
                    p->s.center.y <= s->center.y + (s->height) &&
                    p->s.center.x >= s->center.x - (s->width) &&
                    p->s.center.x <= s->center.x + (s->width)) {
                p->s.center.y = p->s.center.y + (s->height*2);
                p->velocity.x += 0.06;
                p->velocity.y *= rnd() * -0.3;
            } 
        }
        //check for off-screen
        if (p->s.center.y < 0.0) {
            //std::cout << "off screen" << std::endl;
            game->particle[i] = game->particle[game->n-1];  //value at end of array switches with
            //particle that left the screen
            game->n--;

        }

        //check for collision with circle
        Shape *c;
        c = &game->circle;
        float diffx, diffy, distance;
        diffx = p->s.center.x - c->center.x;
        diffy = p->s.center.y - c->center.y;
        distance = sqrt((diffx*diffx) + (diffy*diffy));
        if (distance < c->radius) {
            //moving particle to circle edge
            p->s.center.x = c->center.x + (diffx/distance) * c->radius + 1.01;
            p->s.center.y = c->center.y + (diffy/distance) * c->radius + 1.01;
            //collision
            p->velocity.x -= 0.08;
            p->velocity.y *= rnd() * -0.3;
        }
    }
}
Exemplo n.º 5
0
void movement(Game *game)
{
	Particle *p;

	if (game->n <= 0)
		return;

	for (int i=0; i<10; i++)
		makeParticle(game, game->lastMousex, game->lastMousey);

	/*for (int i=0; i<10; i++)
		makeParticle(game, game->lastKeyx, game->lastKeyy);*/

	for (int i=0; i<game->n; i++) {
		p = &game->particle[i];
		p->s.center.x += p->velocity.x;
		p->s.center.y += p->velocity.y;
		p->velocity.y -= GRAVITY;

		//check for collision with shapes...
		for (int j=0; j<5; j++) {
			Shape *s = &game->box[j];
			if (p->s.center.y < s->center.y + s->height &&
					p->s.center.y > s->center.y - s->height &&
					p->s.center.x >= s->center.x - s->width &&
					p->s.center.x <= s->center.x + s->width) {
				p->velocity.y *= -0.25;
				p->s.center.y = s->center.y + s->height + 0.01;
			}
		}
		//check circle collision
		float d0,d1,dist;
		d0 = p->s.center.x - game->circle.center.x;
		d1 = p->s.center.y - game->circle.center.y;
		dist = sqrt(d0*d0 + d1*d1);
		if (dist <= game->circle.radius) {
			//p->velocity.y = 0.0;
			//float v[2];
			d0 /= dist;
			d1 /= dist;
			d0 *= game->circle.radius * 1.01;
			d1 *= game->circle.radius * 1.01;
			p->s.center.x = game->circle.center.x + d0;
			p->s.center.y = game->circle.center.y + d1;
			p->velocity.x += d0 * 0.02;
			p->velocity.y += d1 * 0.02;
		}

		//check for off-screen
		if (p->s.center.y < 0.0 || p->s.center.y > WINDOW_HEIGHT) {
			//std::cout << "off screen" << std::endl;
			memcpy(&game->particle[i], &game->particle[game->n-1],
					sizeof(Particle));
			game->n--;
		}
	}
}
Exemplo n.º 6
0
/** Template method to create a new particle, or reuse an existing expired particle. */
CC3Particle* CC3ParticleEmitter::acquireParticle()
{
	if ( m_particleCount < m_particles->count() ) 
	{
		return (CC3Particle*)m_particles->objectAtIndex( m_particleCount );
	}
		
	return makeParticle();
}
Exemplo n.º 7
0
void movement(Game *game)
{
    Particle *p;

    if(game->bubbler)
        for(int i=0; i<10; i++)
            makeParticle(game, game->lastMouse[0], game->lastMouse[1]);

    if (game->n <= 0)
        return;
    for (int i =0; i<game->n; i++) {    

        p = &game->particle[i];
        p->s.center.x += p->velocity.x;
        p->s.center.y += p->velocity.y;
        p->velocity.y-= GRAVITY;

        //check for collision with shapes...
        //Shape *s;
        for(int j=0; j<5; j++) {
            if(p->s.center.x >=game->box[j].center.x - game->box[j].width &&
                    p->s.center.x <=game->box[j].center.x + game->box[j].width &&
                    p->s.center.y < game->box[j].center.y + game->box[j].height &&
                    p->s.center.y > game->box[j].center.y - game->box[j].height) {
                //collision with box
                p->s.center.y= game->box[j].center.y + game->box[j].height + 0.1;
                p->velocity.y *= -0.5;
            }


        }

        //collision with circle
        float d0, d1, dist;
        d0 = p->s.center.x - game->circle.center.x;
        d1 = p->s.center.y - game->circle.center.y;
        dist = sqrt(d0*d0 + d1*d1);
        if(dist < game->circle.radius) {
            //collision! apply penalty to the particle
            p->s.center.x = game->circle.center.x + (game->circle.radius * d0/dist); 
            p->s.center.y = game->circle.center.y + (game->circle.radius * d1/dist); 
            p->velocity.x += d0/dist;
            p->velocity.y += d1/dist;
        }


        //check for off-screen
        if (p->s.center.y < 0.0) {
            memcpy(&game->particle[i], &game->particle[game->n-1],sizeof(Particle));
            std::cout << "off screen" << std::endl;
            game->n--;

        }

    }
}
Exemplo n.º 8
0
void bubbles(Game *game)
{
    if (bubble) {
	if (game->n < MAX_PARTICLES) {
	    for (int i = 0; i < 1; i++) {
		makeParticle(game, 120, 550);
	    }
	}
    }
}
Exemplo n.º 9
0
void physics(Game *game)
{
	if (showbubbles){
		int loop = 0;
		while(loop<3)
		{
			makeParticle(game, 120, 560);
			loop++;
		}
	}
}
Exemplo n.º 10
0
void check_mouse(XEvent *e, Game *game)
{

	game->lastMousex = e->xbutton.x;
	game->lastMousey = WINDOW_HEIGHT - e->xbutton.y;
	static int savex = 0;
	static int savey = 0;
	if (e->type == ButtonRelease) {
		return;
	}
	if (e->type == ButtonPress) {
		if (e->xbutton.button==1) {
			//Left button was pressed
			int y = WINDOW_HEIGHT - e->xbutton.y;

			if(!game->bubbler)// if bubbler is not toggled, mouse movement for water is allowed
				for(int i = 0; i < 10; i++)
					makeParticle(game, e->xbutton.x, y);
			return;
		}
		if (e->xbutton.button==3) {
			//Right button was pressed
			//std::cout << "right mouse b down" << std::endl;
			return;
		}
	}
	//Did the mouse move?
	if (savex != e->xbutton.x || savey != e->xbutton.y) {
		savex = e->xbutton.x;
		savey = e->xbutton.y;
		int y = WINDOW_HEIGHT - e->xbutton.y;

		if(!game->bubbler)// if bubbler is not toggled, mouse movement for water is allowed
			for(int i = 0; i < 10; i++)
				makeParticle(game, e->xbutton.x, y);
	}
}
Exemplo n.º 11
0
void movement(Game *game)
{
    Particle *p;

    if (game->n <= 0)
        return;

    for (int i=0;i<10;i++)
        makeParticle(game, game->lastMousex, game->lastMousey);

    for (int i=0; i<game->n; i++){
        p = &game->particle[i];
        p->s.center.x += p->velocity.x;
        p->s.center.y += p->velocity.y;
        p->velocity.y -= GRAVITY;

        //check for collision with shapes...
        for (int j=0;j<5;j++){
            Shape *s=&game->box[j];

            if (p->s.center.y < s->center.y + s->height && (p->s.center.x >= s->center.x - s->width && p->s.center.x <= s->center.x + s->width) && (p->s.center.y > s->center.y - s->height)){
                p->velocity.y *= -.25;
                p->s.center.y = s->center.y + s->height + 0.01;
                p->velocity.x = 0.5;
            }

        }
        //CALCULATE PARTICLES DISTANCE TO CIRCLE CENTER:
        Shape *s=&game->circle;
        double distance = sqrt(pow(p->s.center.y - s->center.y,2) + pow(p->s.center.x - s->center.x,2));
        if (distance < s->radius){
                p->velocity.y *= -.25;
                p->velocity.x += rnd() -0.65;
                p->s.center.y = s->center.y + sqrt(pow(s->radius,2.0) - (pow(p->s.center.x - s->center.x,2.0))) + 0.01;
        }

        //check for off-screen
        if (p->s.center.y < 0.0 || p->s.center.y > WINDOW_HEIGHT) {
            std::cout << "off screen" << std::endl;
            memcpy(&game->particle[i], &game->particle[game->n-1], sizeof(Particle));
            game->n--;
        }
    }
}
Exemplo n.º 12
0
int check_keys(XEvent *e, Game *game)
{
    //Was there input from the keyboard?
    if (e->type == KeyPress) {
        int key = XLookupKeysym(&e->xkey, 0);
        if (key == XK_Escape) {
            return 1;
        }
        //You may check other keys here.
        int key2 = XLookupKeysym(&e->xkey, 1);
        if(key2 == XK_B){
            int x = game->lastMousex;
            int y = game->lastMousey;
            makeParticle(game, x, y);
        }

    }
    return 0;
}
Exemplo n.º 13
0
void check_mouse(XEvent *e, Game *game)
{
	static int savex = 0;
	static int savey = 0;
	//static int n = 0; took out

	if (e->type == ButtonRelease) {
		return;
	}
	if (e->type == ButtonPress) {
		if (e->xbutton.button==1) {
			//Left button was pressed
			int y = WINDOW_HEIGHT - e->xbutton.y;

			for(int i=0; i<10; i++)
				makeParticle(game, e->xbutton.x, y);
			return;
			
		}
		if (e->xbutton.button==3) {
			//Right button was pressed
			return;
		}
	}
	//Did the mouse move?
	if (savex != e->xbutton.x || savey != e->xbutton.y) {
		savex = e->xbutton.x;
		savey = e->xbutton.y;
		int y = WINDOW_HEIGHT - e->xbutton.y;
        /*if(bubbler){
		    for (int i=0; i<10; i++)
		 	    makeParticle(game, e->xbutton.x, y); //make particle if mouse moves
        }*/
            //if (n++ < 10;
			//return;
	
			game->lastMousex = e->xbutton.x;  //added
			game->lastMousey = y;    //added
		
	}
}
Exemplo n.º 14
0
Arquivo: hw1.cpp Projeto: jcadena3/hw1
int check_keys(XEvent *e, Game *game)
{
	//Was there input from the keyboard?
	if (e->type == KeyPress) {
		int key = XLookupKeysym(&e->xkey, 0);
		if (key == XK_Escape) {
			return 1;
		}
		//You may check other keys here.
		
		// Was the b key pressed? If so, turn on a bubbler
		// to turn on a constant stream of water particles
		// that flow 
		if (key == XK_b) {
			int y = WINDOW_HEIGHT - e->xbutton.y;
			makeParticle(game, e->xbutton.x, y);
		}

	}
	return 0;
}
Exemplo n.º 15
0
Arquivo: hw1.cpp Projeto: jgarcia4/hw1
int check_keys(XEvent *e, Game *game)
{
	//Was there input from the keyboard?
	if (e->type == KeyPress) {
		int key = XLookupKeysym(&e->xkey, 0);
		if (key == XK_Escape) {
			return 1;
		}
		//You may check other keys here.
		
		// Was b key pressed? turn on stream  
		if (key == XK_b) {
			int y = WINDOW_HEIGHT - e->xbutton.y;
			makeParticle(game, e->xbutton.x, y);
			if (key == XK_Escape) {
				return 1;
			}
		}

	}
	return 0;
}
Exemplo n.º 16
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    game.n=0;

    //declare a box shape

    for (int i = 0; i < 5; i++) {
	game.box[i].width = 70 + i*5;
	game.box[i].height = 10;
	game.box[i].center.x = 120 + (i*80);
	game.box[i].center.y = 500 - (i*70);
    }

    game.circle.center.x = 700;
    game.circle.center.y = 0;
    game.circle.radius = 200;

    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    //check_mouse(&e, &game);
	    done = check_keys(&e, &game);
	}
	makeParticle(&game,35,550);
	movement(&game);
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}
Exemplo n.º 17
0
int check_keys(XEvent *e, Game *game)
{
    //Was there input from the keyboard?
    static int water = 0;
    int key = XLookupKeysym(&e->xkey, 0);

    if(e->type == KeyPress) {
        if(key == XK_b)
            std::cout << "Water: On" << std::endl;
        water = 1;
    }
    if(e->type == KeyRelease) {
        if(key == XK_b)
            std::cout << "Water: Off" << std::endl;
        water = 0;
    }
    if(water) {
        makeParticle(game, 1, 580);
        makeParticle(game, 1, 579);
        makeParticle(game, 1, 578);
        makeParticle(game, 602, 557);
        makeParticle(game, 598, 553);
        makeParticle(game, 605, 531);
        makeParticle(game, 655, 547);
        makeParticle(game, 675, 524);
        makeParticle(game, 685, 490);
        makeParticle(game, 674, 587);
        makeParticle(game, 700, 490);
        makeParticle(game, 654, 486);
        makeParticle(game, 737, 474);
        makeParticle(game, 722, 485);
    }


    return 0;
}
Exemplo n.º 18
0
void movement(Game *game)
{
	Particle *p;

	//declare a box shape
	game->box[1].width = box_length;
	game->box[1].height = 40;
	game->box[1].center.x = box_x -= 3;
	game->box[1].center.y = box_y;

	game->box[2].width = 10;
	game->box[2].height = 20;
	game->box[2].center.x = sprite_x;
	game->box[2].center.y = sprite_y;
	if (jump) {
		game->box[2].center.y = sprite_y + 90;
		jump = 0;
	} 
	else {
		for (int a = 0; a < 100000; a++) {
			if (game->box[2].center.y == sprite_y)
				game->box[2].center.y -= 1;
		}
	}

	if ( game->box[1].center.x < -40)
		box_x = 1500;
	game->lastMousex = 445;
	game->lastMousey = 540;
	if(set){
		for(int i = 0; i < 10; i++)
			makeParticle(game, game->lastMousex, game->lastMousey);
	}
	if (game->n <= 0)
		return;
	int box_num = 5;
	for(int i=0; i<game->n; i++){
		p = &game->particle[i];
		p->s.center.x += p->velocity.x;
		p->s.center.y += p->velocity.y;
		p->velocity.y -= GRAVITY;

		for (int b = 0; b < box_num; b++) {
			Shape *s = &game->box[b];	 
			if (p->s.center.y >= s->center.y - (s->height) &&
					p->s.center.y <= s->center.y + (s->height) &&
					p->s.center.x >= s->center.x - (s->width) &&
					p->s.center.x <= s->center.x + (s->width)) {
				p->velocity.y *= -0.45;
				p->s.center.y = s->center.y + s->height + 0.01;
			}
		}
		//check circle collison
		float d0, d1, dist;
		for (int j = 0; j < 2; j++) {
			d0 = p->s.center.x - game->circle[j].center.x;
			d1 = p->s.center.y - game->circle[j].center.y;
			dist = sqrt(d0*d0 + d1*d1);
			if(dist <= game->circle[j].radius) {
				d0 /= dist;
				d1 /= dist;
				d0 *= game->circle[j].radius * 1.01;
				d1 *= game->circle[j].radius * 1.01;
				p->s.center.x = game->circle[j].center.x + d0;
				p->s.center.y = game->circle[j].center.y + d1;
				p->velocity.x += d0 * 0.02;
				p->velocity.y += d0 * 0.02;
			}
		}
		if (p->s.center.y < 0.0) {
			game->particle[i] = game->particle[game->n-1];
			game->n--;
		}
	}
}
Exemplo n.º 19
0
// checking for collisions
void movement(Game *game)
{
	Particle *p;

	if (game->n <= 0)
		return;

	int x_bubbler = 60;
	int y_bubbler = WINDOW_HEIGHT;

	if(game->bubbler) // if bubbler is toggled only stream water from the top, no mouse involved
	{
		for(int i = 0; i < 10; i++)
			makeParticle(game, x_bubbler, y_bubbler);
	}

	if(!game->bubbler) // if bubbler is not toggled, mouse movement for water is allowed
		for(int i = 0; i < 10; i++)
			makeParticle(game, game->lastMousex, game->lastMousey);

	for(int i = 0; i < game->n; ++i)
	{
		p = &game->particle[i];
		p->s.center.x += p->velocity.x;
		p->s.center.y += p->velocity.y;
		p->velocity.y -= GRAVITY; 
		//check for collision with shapes...
		// check for number of collisions with boxes
		for(int j = 0; j < 5; ++j)
		{
			// collision of box
			Shape * s = &game->box[j];
			if ( p->s.center.y < s->center.y + s->height &&
				p->s.center.x >= s->center.x - s->width &&
				p->s.center.x <= s->center.x + s->width &&
				p->s.center.y > s->center.y - s->height){

					p->velocity.y *= -0.25;
					p->s.center.y = s->center.y + s->height;
			}
		}

		// collisions with circle
		Shape * c = &game->circle;

		// x axis WORKS
		float x_p, y_p,
			x_c, y_c;

		// checks if the particles x position and y position are within the circles area
		if(p->s.center.x >= c->center.x - RADIUS && p->s.center.x <= c->center.x + RADIUS && p->s.center.y < RADIUS + 3)
		{
			x_p = p->s.center.x;
			y_p = p->s.center.y;

			x_c = c->center.x;
			y_c = c->center.y;

			float distance = sqrt( pow(x_p - x_c, 2) + pow(y_p - y_c, 2));

			if(distance - RADIUS <= 0)
			{
				// changes direction of water depenting where it lands on the circle
				if(p->s.center.x < c->center.x - 5)
				{
					p->velocity.x =  -(1.0 + rnd() * 0.1);
				}
				else
					p->velocity.y = rnd() * 0.1;

				p->velocity.y *= -0.1;
				p->s.center.y += 2;
			}
		}

		//check for off-screen
		if (p->s.center.y < 0.0 || p->s.center.y > WINDOW_HEIGHT) {
			memcpy(&game->particle[i], &game->particle[game->n -1], 
				sizeof(Particle));
			game->n--;

		}
	}
}
Exemplo n.º 20
0
 Particle* ParticleSystem::makeParticle()
 {  
     return makeParticle( 1.0f, 0.0f, 0.0f, 0.0f );
 }
Exemplo n.º 21
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");
}
Exemplo n.º 22
0
void render(Game *game)
{
	float w, h;
	Rect r;
	glClear(GL_COLOR_BUFFER_BIT);
	//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(255,255,255);
	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,255);
	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(255,0,0);
		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();
	}
	if(game->bubble){
	makeParticle(game, 50, 550);
	}
	
		glBindTexture(GL_TEXTURE_2D, 0);
	//
	//
	
	r.bot = WINDOW_HEIGHT - 110;
	r.left = 100;
	r.center = 0;
	unsigned int cref = 0x0000FF11;
	ggprint16(&r, 16, cref, "Requirements");
	r.bot = WINDOW_HEIGHT - 185;
	r.left = 200;
	r.center = 0;
	ggprint16(&r, 16, cref, "Requirements");
	r.bot = WINDOW_HEIGHT - 260;
	r.left = 300;
	r.center = 0;
	ggprint16(&r, 16, cref, "Requirements");
	r.bot = WINDOW_HEIGHT - 335;
	r.left = 400;
	r.center = 0;
	ggprint16(&r, 16, cref, "Requirements");
	r.bot = WINDOW_HEIGHT - 410;
	r.left = 500;
	r.center = 0;
	ggprint16(&r, 16, cref, "Requirements");








}
Exemplo n.º 23
0
void ParticleEmitter::spawnParticle(float frameTimePassed, float deltaTime) {
	float t2 = 1;//frameTimePassed/deltaTime;
    Particle pt = makeParticle(frameTimePassed, deltaTime, oldWorldPos * (1-t2) + currWorldPos * t2);
	//pt.update(deltaTime-frameTimePassed); //update for the rest of the frame time
	sys->addParticle(pt);
}
Exemplo n.º 24
0
void physics(Game * game)
{


	if(STATE == RUN_GAME && !pausegame)	//if the game is playing and not paused, run all the physics checks and apply movement and gravity
	{					//I have it set up this way, so that when the game is paused, the game no longer checks for physics
		game->inAir();
		game->updatePlatforms();
		game->applyGravity();
		if(game->checkBottomScreen() && bloodToggle) // spikes collision    bloodToggle is a switch that is turned off once this statement has run once and is turned back one once the game is over. This means when
		{					     //the character hits the spikes, the sounds wont play multiple times. I nearly blew out my eardrum at first
			int choice = rand() % 3;

			if(choice == 1)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/death1.wav");
				playSound(1);
			}
			if(choice == 2)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/death2.wav");	//random sound selection
				playSound(2);
			}
			if(choice == 0)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/death3.wav");
				playSound(3);
			}
			calls++;

			game->guts = true;
			bloodToggle = false;

		}

		game->missileChasePlayer();
		game->removeMissiles();
		game->checkCollision();

		if(!game->setMissiles && game->missiles.numExp <= 0)
		{
			//for(int i = 0; i < 5; ++i)					//Unroll that loop! Efficiency.
			{
				if((int)SCORE % 100 == rand() % 100 && !game->setMissiles)
				{
					game->createMissiles();
					alBuffer = alutCreateBufferFromFile("./Sounds/missile.wav");
					calls++;
					playSound(4);
				}
			}
		}

		if(game->checkMissileHit())
		{
			game->guts = true;						//if the missile hits the player, display the guts particles and quit rendering missile
			game->setMissiles = false;
		}

		if(keys[XK_Left]) // left arrow, move right
		{
			game->player.right = false;
			game->player.left = true;
			if(frames == 1)
				frame += 0.125;
			game->accelX(-1 * INITIAL_VELOCITY);
		}

		if(keys[XK_Right]) // right arrow, move right
		{
			game->player.left = false;
			game->player.right = true;
			if(frames == 1)
				frame +=  0.125;
			game->accelX(INITIAL_VELOCITY);
		}

		if(keys[XK_space] && game->if_jump) // spacebar to jump if you arent already in the air
		{
			int choice = rand() % 4;
			if(choice == 1)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/jump1.wav");
				playSound(5);
			}
			if(choice == 2)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/jump2.wav");	//random sound selection
				playSound(6);
			}

			if(choice == 3)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/jump3.wav");
				playSound(7);
			}
			if(choice == 0)
			{
				alBuffer = alutCreateBufferFromFile("./Sounds/jump4.wav");
				playSound(8);
			}
			game->accelY(2 * INITIAL_VELOCITY);
		}

		if(killmovement && game->inAir()) // kill movement on x axis only
			game->player.velocity.x = 0;


		if(game->velX() > MAX_VELOCITY)
			game->player.velocity.x = MAX_VELOCITY;
		if(game->velX() < -1 * MAX_VELOCITY)
			game->player.velocity.x = -1 * MAX_VELOCITY;

		game->move();
	}
	int x_bubbler = 100;
	int y_bubbler = window_height;

	if(bubbler) // if bubbler is toggled only stream water from the top, no mouse involved
	{
		for(int i = 0; i < window_height * 0.15; i++)
		{
			x_bubbler += rnd()*10;
			makeParticle(x_bubbler, y_bubbler);
		}
	}




	// waterfall particle settings
	Particle *p = &par[numParticles];
	if(!pausegame)
	{
		for(int i = 0; i < numParticles; ++i)
		{
			p = &par[i];
			p->s.center.x += p->velocity.x;
			p->s.center.y += p->velocity.y;
			p->velocity.y -= 0.1;

			if (p->s.center.y < 0.0 || p->s.center.y > window_height)
			{
				memcpy(&par[i], &par[numParticles -1],
						sizeof(Particle));
				numParticles--;
			}
		}
	}

	// blood particle settings
	Particle *p2 = &blood[numblood];
	if(!pausegame)
	{
		for(int i = 0; i < numblood; ++i)
		{
			p2 = &blood[i];
			p2->s.center.x += p2->velocity.x;
			p2->s.center.y += p2->velocity.y;
			p2->velocity.y -= 0.1;

			if (p2->s.center.y < 0.0 || p2->s.center.y > window_height)
			{
				memcpy(&blood[i], &blood[numblood -1],
						sizeof(Particle));
				numblood--;
			}
		}
	}

	//making missile exp particles
	Particle *p3 = &game->missiles.exp[game->missiles.numExp];				//takes over after makeMissilesExp() creates the particles and their respective directions
	if(!pausegame)
	{
		for(int i = 0; i < game->missiles.numExp; ++i)
		{
			p3 = &game->missiles.exp[i];
			p3->s.center.x += p3->velocity.x;
			p3->s.center.y += p3->velocity.y;
			p3->velocity.y -= 0.1;

			if (p3->s.center.y < 0.0 || p3->s.center.y > window_height)
			{
				memcpy(&game->missiles.exp[i], &game->missiles.exp[game->missiles.numExp -1],
						sizeof(Particle));
				game->missiles.numExp--;
			}
		}

	}
}