You want a health bar over a monster? You don't need malloc.

Code:
action eTank()
{
	PANEL* hPan;			//declare a panel pointer for the health bar
	VECTOR test;			//declare a vector to test if the smoke vector is visible
	VECTOR hSpot;			//declare a vector for the healthbar position
        ....//bunch of parameters and such that has nothing to do with the healthbar
	hPan = pan_create(NULL,9999);						//create a panel for the healthbar
	set(hPan,VISIBLE | LIGHT | TRANSLUCENT);		//set the panel's flags, visible, light and translucent
	hPan.alpha = 50;										//set its transparency to 50
	hPan.size_y = 10;	 												//make the y component a constant ten
	while(my.health > 0)
	{
		vec_set(hSpot,my.x);											//set hSpot to my position
		vec_to_screen(hSpot,camera);								//convert hSpot to screen coordinates
		hPan.pos_x = hSpot.x - (0.5 * (hPan.size_x));		//place the health panel so it is centered on the tank
		hPan.pos_y = hSpot.y - 40;
		hPan.size_x = 100 * (my.health / my.maxHealth);		//make the size dependant on the tank's % of health											
		vec_set(hPan.blue,vector(0,200,0));

                //the rest of the code
      }
 
}	



Simple explanation, I declared a local PANEL pointer called "hPan." This will be our panel. Then I declared a local vector called "hSpot" and this is the position of the panel.

Next, I set hPan to a pan_create instruction with no bmap and 9999 layer so it'd be on top, I'm going to use a color vector rather than a bitmap. Since I'm using color, I set LIGHT. I also want TRANSLUCENT and VISIBLE. I set alpha and y, before the while() loop as these two are constants.

Then, using vec_set, I copy the tank's position into hSpot. Using vec_to_screen, I convert hSpot to screen coordinates. Then I can use hSpot to position hPan and I set size_x to 100 * the tank's percentage of health.

The last line defines the color of the panel, making it green. (.blue can also be used to store a vector, it doesn't necessarily indicate blue color).

When the tank dies, I use reset to turn of the visible flag and then remove the panel with ptr_remove.

This works with multiple enemies


I was once Anonymous_Alcoholic.

Code Breakpoint;