Go Back   The Mighty Oxen Forums > Public Forums > -]OX[- Tech Room
Reply
 
Thread Tools Display Modes

WORK, DAMMIT!
Old 11-14-2009, 07:47 AM   #1
Star-Demon
Even Worse Than DMX
 
Join Date: May 2004
Posts: 2,002
Default WORK, DAMMIT!

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;
}
__________________


"I farm turrets. I cast Spells. I swing a Big Sword. Don't mess with me in videogames."
Star-Demon is offline   Reply With Quote

Old 11-15-2009, 07:51 PM   #2
DMX
Administrator of Vegas
 
Join Date: Jun 2004
Location: FL
Posts: 4,741
Default

FilledRect.um


hurhurhurhurhurhruhrur
__________________
a youtube link? i'll click it!
DMX is offline   Reply With Quote

Old 11-16-2009, 09:41 AM   #3
sneakygare
Senior Member
 
Join Date: May 2005
Location: Fargo, ND
Posts: 705
Send a message via Yahoo to sneakygare
Default

SDL_UpdateRects(barFrame, 1, &FilledRect);

just a guess, the second parameter is an integer count for number of rectums
__________________
With great bacon powers come great bacon responsibilities.
sneakygare is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 07:18 AM.


vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
| Home | Register | FAQ | Members List | Calendar | Today's Posts | Search | New Posts |