Code Snippet

I wrote a very simple code snippet (inspired by apple),
incase any one is interested.

This is it…

void SDL_SetRect(SDL_Rect *Rect, Sint16 x, Sint16 y, Uint16 w, Uint16 h);

void SDL_SetRect(SDL_Rect *Rect, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
{
Rect->x = x;
Rect->y = y;
Rect->w = w;
Rect->h = h;
}

This is just a cleaner way to set rects eg:

SDL_SetRect(&screenRect, 0, 0, ScreenWidth, ScreenHeight);

versus

screenRect.x = 0;
screenRect.y = 0;
screenRect.h = ScreenWidth;
screenRect.w= ScreenHeight;

I know it’s simple, but i found it useful, and i thought others might
appreciate it.–
Nathan Williams

When the going gets tough, the tough get duct tape.

At 01:23 PM 11/17/02 +1100, you wrote:

I wrote a very simple code snippet (inspired by apple),
incase any one is interested.

This is it…

void SDL_SetRect(SDL_Rect *Rect, Sint16 x, Sint16 y, Uint16 w, Uint16 h);

void SDL_SetRect(SDL_Rect *Rect, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
{
Rect->x = x;
Rect->y = y;
Rect->w = w;
Rect->h = h;
}

Change it to SDL_Rect * SDL_SetRect(…), and have the function return Rect
– then you can use it inside of a function call needing the SDL_Rect *,
instead of having to set it above the call.–
“It startled him even more when just after he was awarded the Galactic
Institute’s Prize for Extreme Cleverness he got lynched by a rampaging mob
of respectable physicists who had finally realized that the one thing they
really couldn’t stand was a smart-ass.”
– Hitchhiker’s Guide to the Galaxy