Shape Filling Advice
Shape Filling Advice
While working on the final part of my game, the life bar, 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
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: Shape Filling Advice
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.
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.
Re: Shape Filling Advice
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.
ʕ •ᴥ•ʔ