Ejemplo n.º 1
0
/** @details
 * Parsuje XML element a vytváří z něj konkrétní jeden frame.
 * @param el XML element <animation_item x,y,(shadow_x, shadow_y)>
 * obsahující definici jednoho framu.
 * @param width šířka framu animace
 * @param height výška framu animace
 * @param sur_src zdrojový obrázek, ze kterého se vyřízne frame
 * @param sur_shadow_src zdrojový obrýzek, ze kterého se vyřízne stín.
 * @see readAttr()
 */
void Animation::loadItem_(TiXmlElement* el, Uint16 width, Uint16 height,
			const Surface & sur_src, const Surface & sur_shadow_src){

	// atributy pro surface
	Uint16 x, y;
	readAttr(el, "x", x);
	readAttr(el, "y", y);

	// vytvorit surface
	Surface sur= create_transparent_surface(width, height, false);
	SDL_Rect rect={x,y,width,height};
	SDL_BlitSurface(sur_src.GetSurface(), &rect, sur.GetSurface(), 0);
	frames_.push_back(sur);

	if(!draw_shadow_) return;

	// atributy pro shadow
	readAttr(el, "shadow_x", x);
	readAttr(el, "shadow_y", y);

	// vytvorit surface
	sur= create_transparent_surface(width, height, true);
	rect.x=x; rect.y=y;
	SDL_BlitSurface(sur_shadow_src.GetSurface(), &rect, sur.GetSurface(), 0);
	shadow_frames_.push_back(sur);
}
Ejemplo n.º 2
0
void Surface::Blit(const Surface &surf, SDL_Rect *src, SDL_Rect *dest)
{
	int ret = SDL_BlitSurface(surf.GetSurface(), src, surface, dest);
	if (ret < 0)
	{
		throw SDLException("SDL_BlitSurface");
	}
}
Ejemplo n.º 3
0
    void DrawingArea::DrawSurface(const int x, const int y, const Surface& Surface) {
        if (Surface.GetSurface()) { // Check if surface is loaded
            SDL_Rect src, dest;

            src.x = 0;
            src.y = 0;
            src.w = Surface.GetSurface()->w;
            src.h = Surface.GetSurface()->h;

            dest.x = x;
            dest.y = y;
            dest.w = Surface.GetSurface()->w;
            dest.h = Surface.GetSurface()->h;

            SDL_BlitSurface(Surface.GetSurface(), &src, this->surface, &dest);
        } else {
#ifdef DEBUG
            std::cerr << "WARNING: Empty surface would be drawn " << std::endl;
#endif
        }
    }