Пример #1
0
void worm::render_flip(BITMAP* where, int frame, int _x, int _y)
{
  int r,g,c,R,G,B,i;
  float h1,s1,v1,h,s,v;
  for (i=0;i<skin->img[frame]->w;i++)
  {
    for (r=0;r<skin->img[frame]->h;r++)
    {
      g=getpixel(skin->img[frame],i,r);
      c=getpixel(mask->img[frame],i,r);
      if(g!=makecol(255,0,255))
      {
        if(c!=makecol(255,0,255))
        {
          c=color;
          rgb_to_hsv(getr(c), getg(c), getb(c), &h1, &s1, &v1);
          
          R = getr(g);
          G = getg(g);
          B = getb(g);
          
          rgb_to_hsv(R, G, B, &h, &s, &v);
          h = h1;
          s = s1;
          v -= (1-v1)/1.4;
          if (v<0)v=0;
          
          hsv_to_rgb(h,s,v, &R, &G, &B);
          g = makecol(R,G,B);
          putpixel(where,_x+skin->img[frame]->w-1-i,_y+r,g);
        }else putpixel(where,_x+skin->img[frame]->w-1-i,_y+r,g);
      };
    };
  };
};
Пример #2
0
static void
lic_image (GimpPixelRgn *src_rgn,
           gint          x,
           gint          y,
           gdouble       vx,
           gdouble       vy,
           GimpRGB      *color)
{
  gdouble u, step = 2.0 * l / isteps;
  gdouble xx = (gdouble) x, yy = (gdouble) y;
  gdouble c, s;
  GimpRGB col = { 0, 0, 0, 0 };
  GimpRGB col1, col2, col3;

  /* Get vector at x,y */
  /* ================= */

  c = vx;
  s = vy;

  /* Calculate integral numerically */
  /* ============================== */

  getpixel (src_rgn, &col1, xx + l * c, yy + l * s);
  if (source_drw_has_alpha)
    gimp_rgba_multiply (&col1, filter (-l));
  else
    gimp_rgb_multiply (&col1, filter (-l));

  for (u = -l + step; u <= l; u += step)
    {
      getpixel (src_rgn, &col2, xx - u * c, yy - u * s);
      if (source_drw_has_alpha)
        {
          gimp_rgba_multiply (&col2, filter (u));

          col3 = col1;
          gimp_rgba_add (&col3, &col2);
          gimp_rgba_multiply (&col3, 0.5 * step);
          gimp_rgba_add (&col, &col3);
        }
      else
        {
          gimp_rgb_multiply (&col2, filter (u));

          col3 = col1;
          gimp_rgb_add (&col3, &col2);
          gimp_rgb_multiply (&col3, 0.5 * step);
          gimp_rgb_add (&col, &col3);
        }
      col1 = col2;
    }
  if (source_drw_has_alpha)
    gimp_rgba_multiply (&col, 1.0 / l);
  else
    gimp_rgb_multiply (&col, 1.0 / l);
  gimp_rgb_clamp (&col);

  *color = col;
}
Пример #3
0
// Create a surface which has the RGB values of the base surface and the Alpha values made from an average between the RGB values of the alpha mask surface
// Both input surfaces must have the same dimensions
extern SDL_Surface *TransferAlpha( SDL_Surface *base, SDL_Surface *alpha )
{
	SDL_Surface *_outsurf = SDL_CreateRGBSurface(SDL_SWSURFACE,base->w,base->h,base->format->BitsPerPixel,base->format->Rmask,base->format->Gmask,base->format->Bmask,base->format->Amask);
	SDL_Surface *outsurf = SDL_DisplayFormatAlpha(_outsurf);
	SDL_FreeSurface(_outsurf);
	long int pix, piy;
	Uint32 pxx, pxx2, pxx3;
	Uint8 R,G,B,A;
	Uint8 A1,A2,A3,A4,A5;
	SDL_LockSurface(outsurf);
	SDL_LockSurface(base);
	SDL_LockSurface(alpha);
	pix = 0;
	piy = 0;
	while ( (pix < outsurf->w) && (piy < outsurf->h) )
	{
		pxx = getpixel(base,pix,piy);
		pxx2 = getpixel(alpha,pix,piy);
		SDL_GetRGBA(pxx,base->format,&R,&G,&B,&A5);
		SDL_GetRGBA(pxx2,alpha->format,&A1,&A2,&A3,&A4);
		A = (A1/3)+(A2/3)+(A3/3);
		A = (int)((((float)A/255.0*(float)A4)/255.0)*(float)A5);
		pxx3 = SDL_MapRGBA(outsurf->format,R,G,B,A);
		putpixel(outsurf,pix,piy,pxx3);
		pix++;
		if ( pix < outsurf->w )
			continue;
		pix = 0;
		piy++;
	}
	SDL_UnlockSurface(outsurf);
	SDL_UnlockSurface(base);
	SDL_UnlockSurface(alpha);
	return outsurf;
}
void boundryfill(int seedx,int seedy,int boundry,int color)
{Point p(seedx,seedy);
 s.push(p);
 do
 {p=s.pop();
  if(getpixel(p.x,p.y)==boundry) continue;
  while(getpixel(p.x,p.y)!=boundry)p.x--;
  p.x++;
  int flagup=false,flagdown=false;
  int cup,cdwn;
  while(getpixel(p.x,p.y)!=boundry)
  {cup=getpixel(p.x,p.y-1);
   cdwn=getpixel(p.x,p.y+1);
   if(cup==boundry||cup==color) flagup=false;
   else if(!flagup)
   {flagup=true;
    s.push(Point(p.x,p.y-1));
    }
  if(cdwn==boundry||cdwn==color) flagdown=false;
   else if(!flagdown)
   {flagdown=true;
    s.push(Point(p.x,p.y+1));
    }
  putpixel(p.x,p.y,color);
  p.x++;
  }
 }while(!s.isempty());
 s.reset();
}
Пример #5
0
static t_color		get_color_sample(t_data *data,
					 t_bunny_position *p)
{
  t_bunny_position	pos;
  t_3d_pos		color;
  t_color		actcolor;

  actcolor.full = BLACK;
  color.x = 0;
  color.y = 0;
  color.z = 0;
  pos.y = p->y * AA_SAMPLE;
  while (pos.y < p->y * AA_SAMPLE + AA_SAMPLE)
    {
      pos.x = p->x * AA_SAMPLE;
      while (pos.x < p->x * AA_SAMPLE + AA_SAMPLE)
	{
	  color.x += getpixel(data->pix, &pos).argb[0];
	  color.y += getpixel(data->pix, &pos).argb[1];
	  color.z += getpixel(data->pix, &pos).argb[2];
	  pos.x += 1;
	}
      pos.y += 1;
    }
  actcolor.argb[0] = color.x / (double)(AA_SAMPLE * AA_SAMPLE);
  actcolor.argb[1] = color.y / (double)(AA_SAMPLE * AA_SAMPLE);
  actcolor.argb[2] = color.z / (double)(AA_SAMPLE * AA_SAMPLE);
  return (actcolor);
}
Пример #6
0
int collision_detect(BITMAP *sprite1, int xmin1, int ymin1, BITMAP *sprite2, int xmin2, int ymin2)
{
  int xmax1, ymax1, xmax2, ymax2;
  xmin1 -= sprite1->w/2; ymin1 -= sprite1->h/2;
  xmin2 -= sprite2->w/2; ymin2 -= sprite2->h/2;
  xmax1 = xmin1 + sprite1->w; ymax1 = ymin1 + sprite1->h;
  xmax2 = xmin2 + sprite2->w; ymax2 = ymin2 + sprite2->h;
  
  int xmin = max(xmin1, xmin2);
  int ymin = max(ymin1, ymin2);
  int xmax = min(xmax1, xmax2);
  int ymax = min(ymax1, ymax2);
  
  if (!(xmin1 <= xmax2 && xmax1 >= xmin2 && ymin1 <= ymax2 && ymax1 >= ymin2)) return 0; 

  for (int y = ymin; y < ymax; y++) 
  {
    for (int x = xmin; x < xmax; x++) 
    {
      int x1 = x - xmin1, y1 = y - ymin1;
      int x2 = x - xmin2, y2 = y - ymin2;
      int color1 = getpixel(sprite1, x1, y1);
      int color2 = getpixel(sprite2, x2, y2);
      if (color1 != TRANSPARENT && color2 != TRANSPARENT) { return 1; }
    }
  }
  return 0;
}
Пример #7
0
// converts a dead person in black particles
void Person::burn()
{
  GamePlay *gameplay = GAMEPLAY;
  BITMAP *sprite = prepare_sprite();
  int x, y, u, v;

  gameplay->get_level()->to_screen(m_pos, x, y);

  x = x-TILE_W/2;
  y = y-TILE_H+1;

  for (v=0; v<sprite->h; ++v)
    for (u=0; u<sprite->w; ++u) {
      int color, ou;

      if (m_right)
	color = getpixel(sprite, ou=u, v);
      else
	color = getpixel(sprite, ou=sprite->w-1-u, v);

      if (color != bitmap_mask_color(sprite))
	gameplay->add_particle
	  (new PixelParticle(vector2d((m_pos.x*TILE_W - TILE_W/2 + ou) / TILE_W,
				      (m_pos.y*TILE_H - TILE_H+1 + v) / TILE_H),
			     vector2d(0, rand_range(-2.0, -0.1)),
			     vector2d(rand_range(0.5, 4.0), 0),
			     rand_range(BPS/4, BPS*3/4),
			     makecol(0, 0, 0),
			     makecol(0, 0, 0)));

    }
}
Пример #8
0
static inline int check_delta(int x1,int y1,int w,int h,int x,int y,int *a,int *b,int *c)
{
	int dx=0,dy=0;
	int xx=x,yy=y;
	while((getpixel(x,y)==0)&&(getpixel(x+1,y)==0))
	{
		if(next_2pixel(x1,y1,w,h,&x,&y)>=2)
			return EOB;
	}
	dx=x-xx;
	dy=yy-y;
	if((dx<0)&&(dy>0))
	{
		return EOL;
	}
	if((dx>0)&&(dy>0))
	{
		if(dx>0xfe)
			dx=0xfe;
		if(dy>0xfe)
			dy=0xfe;
		*a=dx;
		*b=dy;
		return DELTA;
	}
	return NOPE;
}
Пример #9
0
void rotation(SDL_Surface **img, double angle)
{
        int diagonal, centre_x, centre_y;
        SDL_Surface *new_img;
        diagonal = (sqrt(((*img)->w)*((*img)->w) + ((*img)->h)*((*img)->h))) + 1;
        new_img = SDL_CreateRGBSurface(0, diagonal, diagonal, 32,
                        0, 0, 0, 0);
        for(int x = 0; x <new_img->h ; x++)
        {
                for(int y = 0; y <new_img->w; y++)
                {
                        putpixel(new_img, x, y, 0xffffffff);
                }
        }
        centre_x = (((*img)->w)/2) + 1;
        centre_y = (((*img)->h)/2) + 1;
        for(int x = 0; x<(*img)->w; x++)
        {
                for(int y = 0; y<(*img)->h; y++)
                {
                        if(getpixel(*img, x, y) == 0)
                                putpixel(new_img, abs(lrint(centre_x + (x - centre_x)*cosf(-angle) - (y - centre_y)*sinf(-angle))), abs(lrint(centre_y + (x - centre_x)*sinf(-angle) + (y - centre_y)*cosf(-angle))),
                                        getpixel(*img, x, y));
                }
        }
        //free(img);
        *img = new_img;
}
Пример #10
0
void BlurEx( Image dst, Image src[] , uint32_t step )
#define Blur( d, s ) BlurEx( d, s, 1 )
{
   int y, x, row;

	for( x = 0; x < 96; x+=step)//x++ )
	{
		uint32_t idx;
      uint32_t divisor = 1;
		uint8_t rvals[96];
		uint8_t gvals[96];
		uint8_t bvals[96];
      uint8_t gain[96];
		uint32_t red = 0
	, green = 0
	, blue = 0, img = 0;
		idx = 0;
		for( row = 0; row < 96; row++ )
		{
			{
				CDATA pixel;
				pixel = getpixel( src[0], x, row );
				( rvals[row] = RedVal( pixel ) );
				( bvals[row] = BlueVal( pixel ) );
				( gvals[row] = GreenVal( pixel ) );
				gain[row] = ( (gvals[row] + bvals[row] + rvals[row]) / 128 ) + 1;
				divisor += gain[row];
				red += ( rvals[row] * gain[row] );
				blue += ( bvals[row] * gain[row] );
				green += ( gvals[row] * gain[row] );
			}
		}
		for( img = 1; img <= NUM_PICS; img++ )
		{
			for( y = 0; y < 96; y++ )
			{
				{
					CDATA pixel;
					pixel = getpixel( src[img], x, y);
					red -= rvals[idx] * gain[idx];
					blue -= bvals[idx] * gain[idx];
					green -= gvals[idx] * gain[idx];
					divisor -= gain[idx];
					( rvals[idx] = RedVal( pixel ) );
					( bvals[idx] = BlueVal( pixel ) );
					( gvals[idx] = GreenVal( pixel ) );
					gain[idx] = ( ( gvals[idx] + bvals[idx] + rvals[idx]) / 128 )  + 1;
					divisor += gain[idx];
					red += ( rvals[idx] * gain[idx] );
					blue += ( bvals[idx] * gain[idx] );
					green += ( gvals[idx] * gain[idx] );
					idx++;
					if( idx >= 96 )
						idx = 0;
					plot( dst, x, y + (img-1)*96, Color( red/divisor, green/divisor, blue/divisor ) );
				}
			}
		}
	}
}
Пример #11
0
/* Functions */
void filter_flood_fill(struct image *img, int x, int y, int r, int g, int b)
{
    int oldr, oldg, oldb;
    int nextr, nextg, nextb;

    if(x < 0 || y < 0 || x >= img->width || y >= img->height)
        return;

    getpixel(img, x, y, &oldr, &oldg, &oldb);
    setpixel(img, x, y, r, g, b);

    getpixel(img, x + 1, y, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x + 1, y, r, g, b);

    getpixel(img, x - 1, y, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x - 1, y, r, g, b);

    getpixel(img, x, y + 1, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x, y + 1, r, g, b);

    getpixel(img, x, y - 1, &nextr, &nextg, &nextb);
    if(nextr == oldr && nextg == oldg && nextb == oldb)
        filter_flood_fill(img, x, y - 1, r, g, b);
}
	void hit()
	{
		int flag=0;

		if(dir==1)
		if (getpixel(x+radius+BSPEED+0.5,y)==BLUE)
		flag=1;

		if(dir==2)
		if(getpixel(x,y+radius+BSPEED+0.5)==BLUE)
		flag=1;

		if(dir==3)
		if(getpixel(x-radius-BSPEED-0.5,y)==BLUE)
		flag=1;

		if(dir==4)
		if(getpixel(x,y-radius-BSPEED-0.5)==BLUE)
		flag=1;


		if(flag==1)
		{
			setcolor(BLACK);
			circle(x,y,radius);
			on_screen=0;
		}
	}
Пример #13
0
int collision_bleu(Calque calque,int posx_bleu,int y)
{ if(getpixel(calque.img,posx_bleu+20,y+88)== 65535 && getpixel(calque.img,posx_bleu+80,y+88)== 65535)
   {return 2;}
  else if(getpixel(calque.img,posx_bleu+20,y+88) == 16777215)
  {return 1;}
  else
  {return 0;}
}
Пример #14
0
static float laplacian(float *x, int w, int h, int i, int j)
{
	return  -4 * getpixel(x, w, h, i  , j  )
		     + getpixel(x, w, h, i+1, j  )
		     + getpixel(x, w, h, i  , j+1)
		     + getpixel(x, w, h, i-1, j  )
		     + getpixel(x, w, h, i  , j-1);
}
Пример #15
0
Uint32 get_ii_rect_sum(const Image *ii, Vec2 a, Vec2 b, Vec2 c, Vec2 d) {
	Uint32 pA = getpixel(ii->surface, a.x, a.y);
	Uint32 pB = getpixel(ii->surface, b.x, b.y);
	Uint32 pC = getpixel(ii->surface, c.x, c.y);
	Uint32 pD = getpixel(ii->surface, d.x, d.y);

	return pD - (pB + pC) + pA;
}
Пример #16
0
/* Main function */
char *decode_authimage(struct image *img)
{
    static struct font *font = NULL;
    char *result;
    struct image *tmp;
    int x, y, r, g, b, i;

    if(!font)
    {
        font = font_load_fixed(DECODER, "font.png",
                               "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        if(!font)
            exit(-1);
    }

    /* authimage captchas have 6 characters */
    result = malloc(7 * sizeof(char));
    memset(result, '\0', 7);

    /* double the captcha size for better accuracy in the rotation */
    tmp = image_dup(img);
    filter_scale(tmp, 2.0);
    getpixel(tmp, 0, 0, &r, &g, &b);
    filter_threshold(tmp, r * 3 / 4);
    filter_smooth(tmp);
    filter_threshold(tmp, 220);

    for(i = 0; i < 6; i++)
    {
        int mindiff = INT_MAX, minch = -1, ch;
        for(ch = 0; ch < font->size; ch++)
        {
            int diff = 0;
            for(y = 0; y < 7; y++)
            {
                for(x = 0; x < 5; x++)
                {
                    int newx, newy, r2;
                    newx = 35.0 + (x + 6 * i) * 218.0 / 34.0 + y * 5.0 / 6.0 + 0.5;
                    newy = 33.0 - (x + 6 * i) * 18.0 / 34.0 + y * 42.0 / 6.0 + 0.5;
                    getpixel(tmp, newx, newy, &r, &g, &b);
                    getpixel(font->img, x + 6 * ch, y, &r2, &g, &b);
                    diff += (r - r2) * (r - r2);
                }
            }
            if(diff < mindiff)
            {
                mindiff = diff;
                minch = ch;
            }
        }
        result[i] = font->glyphs[minch].c;
    }

    image_free(tmp);

    return result;
}
Пример #17
0
	bool collision_check(shot * shots1) {
		if (getpixel(bg_collision , shots1->pos.x - (shots1->speed.x/2), shots1->pos.y - (shots1->speed.y/2)) == makecol(0,255,0) ||
			getpixel(bld_collision, shots1->pos.x - (shots1->speed.x/2), shots1->pos.y - (shots1->speed.y/2)) == makecol(0,255,0)) {
			shots1->pos -= shots1->speed / 2;
			return true;
		}
		return getpixel(bg_collision, shots1->pos.x, shots1->pos.y) == makecol(0,255,0) ||
				getpixel(bld_collision, shots1->pos.x, shots1->pos.y) == makecol(0,255,0);
	}
Пример #18
0
Image calculate_ii(const Image *source) {

	Image res;
	SDL_Surface *ii_surf;
	Uint32 rmask, gmask, bmask, amask;

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
	rmask = 0xff000000;
	gmask = 0x00ff0000;
	bmask = 0x0000ff00;
	amask = 0x000000ff;
#else
	rmask = 0x000000ff;
	gmask = 0x0000ff00;
	bmask = 0x00ff0000;
	amask = 0xff000000;
#endif

	//ii_surf = &(*(source->surface));
	ii_surf = SDL_CreateRGBSurface(0, source->surface->w, source->surface->h,
		32, rmask, gmask, bmask, amask);

	printf("Creating ii, size {w=%d, h=%d}\n", ii_surf->w, ii_surf->h);

	for(int y = 0; y < ii_surf->h; y++) {
		for(int x = ii_surf->w - 1; x >= 0; x--) {
			//printf("pix(%d, %d) = %8x\n", x, y, getpixel(source->surface, x, y));
			Uint32 ii_value = 0;
			
			Uint32 leftSum = 0;
			for(int sx = 0; sx <= x; sx++) {
				leftSum += getpixel(source->surface, sx, y) & 0xff;
			}

			if(y == 0)
				ii_value = leftSum;
			else
				ii_value = leftSum + getpixel(ii_surf, x, y - 1);
			
			/*if(x == y && y > 0)
				printf("ii (%d, %d) = %d\t top=%d\n", x, y, ii_value, getpixel(ii_surf, x, y - 1));*/
			putpixel(ii_surf, x, y, ii_value);
		}
	}

	res.surface = ii_surf;

	SDL_Rect *dim = malloc(sizeof(SDL_Rect));
	dim->x = 0;
	dim->y = 0;
	dim->w = ii_surf->w;
	dim->h = ii_surf->h;
	res.dim = dim;

	return res;
}
Пример #19
0
	bool collision_check(angular * tank1) {
		std::vector<Vector> tmp_points = tank1->abs_points();
		for (int i = 0; i < (int)tmp_points.size(); ++i)
			if (getpixel(bg_collision, tmp_points[i].x, tmp_points[i].y) == makecol(0,255,0) ||
				getpixel(bld_collision, tmp_points[i].x, tmp_points[i].y) == makecol(0,255,0)) {
				tank1->last_collision = i;
				return true;
			}
		return false;
	}
Пример #20
0
  void seedfill(int x,int y,int fill,int bound)
  {
	stack st;ptr p;
	st.push(x,y);

	while(st.isempty()==0)
	{
	  p=st.pop();
	  int current=getpixel(p->x,p->y);
	  if((current!=fill)&&(current!=bound))
	  putpixel(p->x,p->y,fill);
	  int m=p->x,n=p->y;
	  while(getpixel(m+1,n)!=fill&&(getpixel(m+1,n)!=bound))
	  {
		putpixel(m+1,n,fill);
		m++;
	  }
	  m=p->x;n=p->y;
	  while(getpixel(m-1,n)!=fill&&(getpixel(m-1,n)!=bound))
	  {
		putpixel(m-1,n,fill);
		m--;
	  }
	 if((getpixel(p->x,p->y+1)!=fill)&&(getpixel(p->x,p->y+1)!=bound))
	 { st.push(p->x,p->y+1);}
	 if((getpixel(p->x,p->y-1)!=fill)&&(getpixel(p->x,p->y-1)!=bound))
	 { st.push(p->x,p->y-1); }
	  } return;
       }
Пример #21
0
// evaluate an image at a sub-pixel position, using bilinear interpolation
static float bilinear_interpolation(float *x, int w, int h, float p, float q)
{
	int ip = p;
	int iq = q;
	float a = getpixel(x, w, h, ip  , iq  );
	float b = getpixel(x, w, h, ip+1, iq  );
	float c = getpixel(x, w, h, ip  , iq+1);
	float d = getpixel(x, w, h, ip+1, iq+1);
	float r = evaluate_bilinear_cell(a, b, c, d, p-ip, q-iq);
	return r;
}
Пример #22
0
void boundary_fill(int x,int y,int fcolor,int bcolor)
{
	if ((getpixel(x,y)!=fcolor) && (getpixel(x,y)!=bcolor))
	{
		putpixel(x, y, fcolor);
		boundary_fill(x+1,y,fcolor,bcolor);
		boundary_fill(x-1,y,fcolor,bcolor);
		boundary_fill(x,y-1,fcolor,bcolor);
		boundary_fill(x,y+1,fcolor,bcolor);
	}
}
Пример #23
0
void boundaryfill4(int x , int y,int IC)
{
    if(getpixel(x,y)!=IC && getpixel(x,y)!=2)
    {
        putpixel(x,y,IC);
        boundaryfill4( x+1,  y, IC);
        boundaryfill4( x-1,  y, IC);
        boundaryfill4( x,  y+1, IC);
        boundaryfill4( x, y-1, IC);
    }
}
Пример #24
0
void change()
{z=random(4);
if(z==0)
{if(getpixel(x++,y)!=c)x++;}
else if(z==1)
{if(getpixel(x--,y)!=c)x--;}
else if(z==2)
{if(getpixel(x,y++)!=c)y++;}
else if(z==3)
{if(getpixel(x,y--)!=c)y--;}
}
Пример #25
0
SDL_Surface* Diff(SDL_Surface* entry, SDL_Surface* moy)
{
  for(int i = 0; i < entry->w; i++)
  {
    for(int j = 0; j < entry->h; j ++)
    {
      //rajouter surement boucle for
      defPixel(entry, i, j, getpixel(entry, i, j) - getpixel(moy, i, j));
    }
  }
  return entry;
}
Пример #26
0
void Tanque::MovaDireita(BITMAP *db)
{   

//aqui a mesma coisa ... so qe nao funciona nao  pq nao tem o maldito if ;;
   int r =  getr(getpixel(db, col+velocidade, lin));
   int g =  getg(getpixel(db, col+velocidade, lin));
   int b =  getb(getpixel(db, col+velocidade, lin));
    // Verifica colisão com lateral
   col+=velocidade;
   if ( col >= (SCREEN_W - img->w + 4) )
      col = SCREEN_W - img->w + 4; 
}
Пример #27
0
void Tanque::MovaCima(BITMAP *db)
	{
   // iden ...
   int r =  getr(getpixel(db, col-velocidade, lin));
   int g =  getg(getpixel(db, col-velocidade, lin));
   int b =  getb(getpixel(db, col-velocidade, lin));

   lin-=velocidade;
   //evia que o tanque saia  da tela por cima
   if ( lin <= 50 )
      lin = 50;
}
Пример #28
0
bool compare_bitmaps(BITMAP *bmp1, BITMAP *bmp2)
{
    if (bmp1->w != bmp2->w) return false;
    if (bmp1->h != bmp2->h) return false;
    for (int x = 0; x < bmp1->w; x++)
        for (int y = 0; y < bmp1->h; y++) {
            if (getpixel(bmp1, x, y) != getpixel(bmp2, x, y)) {
                return false;
            }
        }
    return true;
}
Пример #29
0
flood(seed_x,seed_y,foreground_col,background_col)
{
if(getpixel(seed_x,seed_y)!=background_col&&getpixel(seed_x,seed_y)!=foreground_col)
{
putpixel(seed_x,seed_y,foreground_col);
delay(10);
flood(seed_x+1,seed_y,foreground_col,background_col);
flood(seed_x-1,seed_y,foreground_col,background_col);
flood(seed_x,seed_y+1,foreground_col,background_col);
flood(seed_x,seed_y-1,foreground_col,background_col);
}
}
Пример #30
0
void render_loop() {
    int base,top,state;
    //draw them backgrounds!
    switch(levl->bgtype) {
    default:
    case 0:
        clear_bitmap(buffer); //black backgrund, not that useful
        break;
    case 1:
        render_sky(levl->lines); //sky-thingy
        break;
    case 2:
        show_fire(); //A fire...
        break;
    }
    render_level_map(levl,xorg,yorg);
    for (int ei=levl->entitycnt-1;ei>=0;ei--) {
        ENTITY *e = levl->entities+ei;
        switch (e->type) {
        default:
            printf("Unknown entity type in render loop! type: %d id: %d",e->type,ei);
        case ENTITY_TYPE_NULL:
            break;
        case ENTITY_TYPE_PLAYER:
            xorg = e->x-368/64.0 <=0 ? 0 : e->x+432/64.0 > levl->sizex ? levl->sizex-800/64.0 : e->x-368/64.0;
            yorg = e->y-268/64.0 <=0 ? 0 : e->y+332/64.0 > levl->sizey ? levl->sizey-600/64.0 : e->y-268/64.0;
            state = (e->data1&0x0300)>>16;
            top = 0;
            if (e->accely < 0) top = 1;
            if (e->accely > 0) top = 2;
            if (e->accely == 1/8.0) top = 5;
            if (e->accelx < 0) top = 3;
            if (e->accelx > 0) top = 4;
            if (e->health <= 0) top = 7;
            
            base = 0;
            render_player((e->x-xorg)*64,(e->y-yorg)*64,base,top);
            render_health(10,10,256,32,e->health,1024);
            textprintf_ex(buffer,font,0,0,getpixel(buffer,0,0)^0xFFFF,-1,"P: %d",e->data3);
            //stretch_blit(collectable_c[2],buffer,0,0,64,64,800-16,0,16,16);
            textprintf_right_ex(buffer,font,799,0,getpixel(buffer,799,0)^0xFFFF,-1,"%d",e->data4);
            break;
        case ENTITY_TYPE_COLLECTABLE:
            //printf("%X, %X, %X, %X ?? %X %X\n",e->data2,e->data2&0xFF00,e->data2&0xFF00 == 0x0100,0x0100,e->data2&0xFF00 > 0x0100,e->data2&0xFF00 < 0x0100);
            if ((e->data2&0xFF00) == 0x0100) {
                draw_rle_sprite(buffer,collectable_c[e->data2&0x0007],(e->x-xorg)*64,(e->y-yorg)*64);
                //draw_rle_sprite(buffer,collectable_c[e->data2&0x0007],0, 0);
            }
            break;
        }
    }
}