示例#1
0
int TileMap::getTile(int x, int y)
{
    if (x < 0)
    {
        x = 0;
    }

    if (y < 0)
    {
        y = 0;
    }

    if (x >= getWidth())
    {
        x = getWidth() - 1;
    }

    if (y >= getHeight())
    {
        y = getHeight() - 1;
    }

    int pixel = _getpixel24(mTileMapBitmap, x, y);

    return getr24(pixel) | (getg24(pixel) << 8);
}
示例#2
0
void save_level(PACKFILE *file,LEVEL *data) {
     int i;
     pack_iputw(data->sizey,file);
     pack_iputw(data->sizex,file);
     pack_putc(data->bgtype,file);
     if (data->bgtype == 1) for (i=0;i<600;i++) {pack_putc(getr24(data->lines[i]),file); pack_putc(getg24(data->lines[i]),file); pack_putc(getb24(data->lines[i]),file);}
     pack_iputw(data->entitycnt,file);
     pack_fwrite(data->map,data->length,file);
     for(i=0;i<data->entitycnt;i++) {
         save_entity(file,&data->entities[i]);
     }
}
示例#3
0
void TileMap::setTileFlags(int x, int y, int flags)
{
    if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
    {
        return;
    }

    int pixel = _getpixel24(mTileMapBitmap, x, y);
    int newPixel = makecol24(getr24(pixel),
                             getg24(pixel),
                             flags);
    _putpixel24(mTileMapBitmap, x, y, newPixel);
}
示例#4
0
/* save_rgb:
 *  Core save routine for 15/16/24 bpp images (original by Martijn Versteegh).
 */
static int save_rgb(png_structp png_ptr, BITMAP *bmp)
{
    AL_CONST int depth = bitmap_color_depth(bmp);
    unsigned char *rowdata;
    int y, x;

    ASSERT(depth == 15 || depth == 16 || depth == 24);

    rowdata = (unsigned char *)malloc(bmp->w * 3);
    if (!rowdata)
	return 0;

    for (y=0; y<bmp->h; y++) {
	unsigned char *p = rowdata;

	if (depth == 15) {
	    for (x = 0; x < bmp->w; x++) {
		int c = getpixel(bmp, x, y);
		*p++ = getr15(c);
		*p++ = getg15(c);
		*p++ = getb15(c);
	    }
	}
	else if (depth == 16) {
	    for (x = 0; x < bmp->w; x++) {
		int c = getpixel(bmp, x, y);
		*p++ = getr16(c);
		*p++ = getg16(c);
		*p++ = getb16(c);
	    }
	}
	else { /* depth == 24 */
	    for (x = 0; x < bmp->w; x++) {
		int c = getpixel(bmp, x, y);
		*p++ = getr24(c);
		*p++ = getg24(c);
		*p++ = getb24(c);
	    }
	}

	png_write_row(png_ptr, rowdata);
    }

    free(rowdata);

    return 1;
}
示例#5
0
void render_sky(int *lines) {
    if (lines == NULL) return;
    for (int y = 0; y < SCREEN_H; y++) {
        short *line = ((short*)buffer->line[y]);
        int r = getr24(lines[y]);
        int g = getg24(lines[y]);
        int b = getb24(lines[y]);
        for (int x = 0; x < 200; x++) {
            //hline(buffer,0,i,SCREEN_W -1,makecol16(getr24(lines[y]),getg24(lines[y]),getb24(lines[y])));
            int col = makecol16_dither(r,g,b,x,y);
            line[x] = col;
            line[x+200] = col;
            line[x+400] = col;
            line[x+600] = col;
        }
    }
}
示例#6
0
/* getr_depth:
 *  Extracts the red component (ranging 0-255) from a pixel in the format
 *  being used by the specified color depth.
 */
int getr_depth(int color_depth, int c)
{
   switch (color_depth) {

      case 8:
	 return getr8(c);

      case 15:
	 return getr15(c);

      case 16:
	 return getr16(c);

      case 24:
	 return getr24(c);

      case 32:
	 return getr32(c);
   }

   return 0;
}