So , I'm working on a few things in SDL and I came back to try to get this porject to work. All it is is a HP bar. That's all. It is supposed to blit only a portion of a surface on top of another surface at a value that is inputted (although I'm just using static values for example)
And it's not working. It's driving me nuts. Any thoughts?
Code:
//Display
int x = 0;
int y = 0;
int BarFill_X; //Need a x,y location for the fill
int BarFill_Y;
double Extra;
BarFill_X = x + 3;
BarFill_Y = y + 4;
//Get and assign values
int Value = 65; //This is the value of the fill
int MaxValue = 100; //This is the maximum value of the value
int BarSize_X = 296; //Fill bar image is 296 pixels wide.
int BarSize_Y = 11; //Fill bar image is 11 pixels high.
double barPercent;
barPercent = Value / MaxValue;
Extra = (BarSize_X * barPercent); //size in X-pixels of the amount to fill.
int barRect_x = int(Extra);
int barRect_y = BarSize_Y;
//Create the RECT - this rect is displaying a portion of the image
SDL_Rect FilledRect;
FilledRect.x = BarFill_X;
FilledRect.y = BarFill_Y;
FilledRect.w = barRect_x;
FilledRect.h = barRect_y;
//Blitting the rect that contains the percent of fill
SDL_BlitSurface(barFill, &FilledRect, barFrame, &FilledRect);
SDL_UpdateRects(barFrame, 0, &FilledRect);
//Wait 5 seconds
SDL_Delay( 5000 );
//Free the surface and quit SDL
clean_up();
return 0;
}