Example #1
0
//-------- Begin of function Lightning::draw_whole ----------//
void Lightning::draw_whole(VgaBuf *vgabuf)
{
	int prex, prey;
	while(!goal() )
	{
		prex = (int) x;
		prey = (int) y;
		move_particle();
		// ignore clipping, currently
		if( energy_level > 4)
		{
			if( prex >= bound_x1+2 && (int)x >= bound_x1+2 &&
				prex <= bound_x2-2 && (int)x <= bound_x2-2 &&
				prey >= bound_y1+2 && (int)y >= bound_y1+2 &&
				prey <= bound_y2-2 && (int)y <= bound_y2-2 )
			{
				vgabuf->line(prex+2, prey, (int) x+2, (int) y, OUTLIGHTNCOLOR);
				vgabuf->line(prex, prey+2, (int) x, (int) y+2, OUTLIGHTNCOLOR);
				vgabuf->line(prex-2, prey, (int) x-2, (int) y, OUTLIGHTNCOLOR);
				vgabuf->line(prex, prey-2, (int) x, (int) y-2, OUTLIGHTNCOLOR);
				vgabuf->line(prex+1, prey, (int) x+1, (int) y, INLIGHTNCOLOR);
				vgabuf->line(prex, prey+1, (int) x, (int) y+1, INLIGHTNCOLOR);
				vgabuf->line(prex-1, prey, (int) x-1, (int) y, INLIGHTNCOLOR);
				vgabuf->line(prex, prey-1, (int) x, (int) y-1, INLIGHTNCOLOR);
				vgabuf->line(prex, prey, (int) x, (int) y, CORELIGHTNCOLOR);
			}
		}
		else if( energy_level > 2)
		{
			if( prex >= bound_x1+1 && (int)x >= bound_x1+1 &&
				prex <= bound_x2-1 && (int)x <= bound_x2-1 &&
				prey >= bound_y1+1 && (int)y >= bound_y1+1 &&
				prey <= bound_y2-1 && (int)y <= bound_y2-1 )
			{
				vgabuf->line(prex+1, prey, (int) x+1, (int) y, OUTLIGHTNCOLOR);
				vgabuf->line(prex, prey+1, (int) x, (int) y+1, OUTLIGHTNCOLOR);
				vgabuf->line(prex, prey, (int) x, (int) y, INLIGHTNCOLOR);
			}
		}
		else
		{
			if( prex >= bound_x1 && (int)x >= bound_x1 &&
				prex <= bound_x2 && (int)x <= bound_x2 &&
				prey >= bound_y1 && (int)y >= bound_y1 &&
				prey <= bound_y2 && (int)y <= bound_y2 )
			{
				vgabuf->line(prex, prey, (int) x, (int) y, OUTLIGHTNCOLOR);
			}
		}

	}
}
Example #2
0
void SmokeTrail::update(int a_delta)
{
   // Move the existing particles
   list<Particle>::iterator it = particles.begin();
   while (it != particles.end()) {
      if (move_particle(*it, a_delta))
         it = particles.erase(it);
      else
         ++it;
   }
   
   my_spawn_counter -= a_delta;

   if (my_spawn_counter <= 0) {
      // Generate a new particle
      new_particle();

      my_spawn_counter = my_spawn_delay;
   }
}