Shape Filling Advice

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
codinitup
Posts: 112
Joined: June 27th, 2012, 7:43 am

Shape Filling Advice

Post by codinitup » July 5th, 2012, 1:50 am

While working on the final part of my game, the life bar, 8-) I realized that I need a way to fill it, it is a simple 50x10 pixel life bar at the top left hand part of my screen. I would like some advice on how to make a function that would fill it. Would it be similar to the disk function? I tried implementing that but it was fairly difficult to convert. Please help
MOOOOOO

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Shape Filling Advice

Post by chili » July 5th, 2012, 2:46 am

This was covered in Lesson 9 I believe.
Chili

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: Shape Filling Advice

Post by viruskiller » July 5th, 2012, 12:02 pm

hmm i'd say to make a function that looks like this:
void DrawBar(int x,int y,int yLength,int nLines,int r,int g,int bb);
x,y are base coords;
yLength is how tall the bar will be;
nLines is how much of that bar is filed.
so just loop trough x coord starting from base x and draw vertical lines of yLength for x<nLines;

now whenever u wana fill that bar more and more just pass it a higher nLine value:P

altough there might be faster algorithm to fill shapes it would be more complicated to just fill it how much u want,u'd have to draw a delimitation line inside the bar and choose to fill only the left interior
of the shape.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Shape Filling Advice

Post by LuX » July 5th, 2012, 1:30 pm

figure out in percents the connection between the max length and the current value, then just draw multiple lines over each other as much as the bar is high.
ʕ •ᴥ•ʔ

Post Reply