Esempio n. 1
0
/**
**	Draw (sprite) cursor when visible, defined by
**      OldCursorW (!=0),..
**      Pre: for this to work OldCursorW should be 0 upfront
**
**	@param type	Cursor-type of the cursor to draw.
**	@param x	Screen x pixel position.
**	@param y	Screen y pixel position.
**	@param frame	Animation frame # of the cursor.
*/
local void DrawCursor(const CursorType* type,int x,int y,int frame)
{
    int size;
    int w;
    int h;
    int spritex;
    int spritey;

    //
    //	Save cursor position and size, for faster cursor redraw.
    //
    spritex=(x-=type->HotX);
    spritey=(y-=type->HotY);
    w=VideoGraphicWidth(type->Sprite);
    h=VideoGraphicHeight(type->Sprite);

    //Reserve enough memory for background of sprite (also for future calls)
    size=w*h*MemSize;
    if( OldCursorSize<size ) {
	if( OldCursorImage ) {
	    OldCursorImage=realloc(OldCursorImage,size);
	} else {
	    OldCursorImage=malloc(size);
	}
	OldCursorSize=size;
    }

    //Save (seen) area behind sprite
    CLIP_RECTANGLE(x,y,w,h);
    SaveCursorBackground(OldCursorX=x,OldCursorY=y,OldCursorW=w,OldCursorH=h);

    //Draw sprite (using its own clipping)  FIXME: prevent clipping twice
    VideoDrawClip(type->Sprite,frame,spritex,spritey);
    OldCursorInvalidate=1;
}
Esempio n. 2
0
/**
**  Draw only fog of war
**
**  @param x  X position into video memory
**  @param y  Y position into video memory
*/
void VideoDrawOnlyFog(int x, int y)
{
#if defined(USE_OPENGL) || defined(USE_GLES)
	if (UseOpenGL) {
		Video.FillRectangleClip(Video.MapRGBA(0, 0, 0, 0, FogOfWarOpacity),
								x, y, PixelTileSize.x, PixelTileSize.y);
	} else
#endif
	{
		int oldx;
		int oldy;
		SDL_Rect srect;
		SDL_Rect drect;

		srect.x = 0;
		srect.y = 0;
		srect.w = OnlyFogSurface->w;
		srect.h = OnlyFogSurface->h;

		oldx = x;
		oldy = y;
		CLIP_RECTANGLE(x, y, srect.w, srect.h);
		srect.x += x - oldx;
		srect.y += y - oldy;

		drect.x = x;
		drect.y = y;

		SDL_BlitSurface(OnlyFogSurface, &srect, TheScreen, &drect);
	}
}