How can I decrease this panel?

Posted By: exile

How can I decrease this panel? - 07/06/13 09:10

So I have a health bar that I want to have decreased to the center. Its a shame that we dont have a library of simple functions like these at our disposal. Anyway, enough ranting. Here is what I am trying to do, I want to have a health bar clip its image from the outside going to the inside. I have checked into using the bmap pixel functions but they seem slow for what I need. I also considered using scale_x, however all that does is just stretch the panel without regard to the shape of the image on the bmap. I suppose its best to show in a series of pictures to show what i am looking for


Health = 100;
oooooooooooo
ooo ooo

Health = 60;
oooooooo
oo oo

Health = 30;
oooo


Health = 10;
oo

Notice how as the health gets lower, the image gets CLIPPED from the outsides towards the center of the image. It would be nice to have a simple CLIP flag for the panels which would instruct the engine to always clip anything outside of the panels size_x/size_y range. Heck even allowing manipulation of the bmaps position within the panel would be a treat.

Anyway, does anyone know of a way I could achieve this effect? Any suggestions would be most helpful. Thanks again guys.
Posted By: txesmi

Re: How can I decrease this panel? - 07/06/13 09:45

Hi,
you can clip and move images on panels with windows (pan_setwindow). You only have to calculate the new window position and width each time the health changes.

Salud!
Posted By: Error014

Re: How can I decrease this panel? - 07/06/13 09:50

I'm not sure I understand correctly - I suppose you'd want to use the forum's CODE-thing for your ASCII-art up there.

Anyway, have you checked the window-parameter of a panel? It's probably the easiest way to achieve this for you, though you do need two variables for this. (or use pan_setwindow)

A better way would be using draw_quad. The x-coordinates of vOffs would then be something along the lines of (bmap_width/2*(1-HEALTH/100)) (assuming HEALTH goes from 0..100, whereas the x-coordinate of the size-parameter would be (bmap_width*HEALTH/100) [again assuming Health is 100 at max].
I'm not quite sure what happens with the y-coordinate (the height) in your example - you maybe need the same code as above but with _height.
Anyways, that should get you started.

Feel free to ask if you need more help!
Posted By: Superku

Re: How can I decrease this panel? - 07/06/13 12:34

I assume you are already aware that you can clip the image/ its right side via panel.size_x as a workaround.

Shaders are surprisingly good for UI related things and if you want I can write one for you that does approximately what you are looking for.
Posted By: exile

Re: How can I decrease this panel? - 07/06/13 19:15

Thanks for the tips guys, draw quad was EXACTLY what I was looking for. It would be nice if there was a page in the manual that listed the functionality of the draw functions.

Thanks again!
Posted By: Error014

Re: How can I decrease this panel? - 07/07/13 09:51

Quote:
It would be nice if there was a page in the manual that listed the functionality of the draw functions.


Yeah, that's true. I agree that sometimes, it can be difficult to find what you want - if you don't know that there's a bunch of functions with "draw_", how are you supposed to find it? So you're definitely right that more "HOW TO DO [X]"-pages in the manual that cover certain specific aspects would be nice.

May I humbly ask you to post your request in "Blame the Manual", however? I've found jcl to be rather friendly about these kind of suggestions - after all, he himself probably knows the engine too well to understand what kind of problems those who do not know it's source code face.
Posted By: lemming

Re: How can I decrease this panel? - 07/07/13 19:47

Quote:
It would be nice if there was a page in the manual that listed the functionality of the draw functions.

Originally Posted By: Error014
if you don't know that there's a bunch of functions with "draw_", how are you supposed to find it?


Are you guys serious?

© 2024 lite-C Forums