Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bahh, dunno whats wrong #359973
02/20/11 23:09
02/20/11 23:09
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
Hey, I have recently been trying to make a simple 3rd person shooter in a simplistic style, everything was going swimmingly until I tried to make a health-bar script. I have pulled my hair out and just dont know what to do, normally i try to work things out myself before posting on any forum, but here is the script:

function healthbar(ENTITY* ent, var healthheight, var maxhealth)
{
VECTOR* temp;
while(1)
{
vec_set(temp, ent.x);
vec_to_screen(temp, camera);

PANEL* healthbar =
{
window(temp.x, temp.y, 20, 5, "windowhealth.png", ent.skill1 / maxhealth * 40, NULL);
flags = SHOW;
}

wait(1);
}




Thanks in advance.


One day there will be an unfixable bug,
That day is not today.
Re: Bahh, dunno whats wrong [Re: dakilla] #360158
02/22/11 14:45
02/22/11 14:45
Joined: Jan 2011
Posts: 65
R
reknak Offline
Junior Member
reknak  Offline
Junior Member
R

Joined: Jan 2011
Posts: 65
I don't know what is wrong but I know an way to make a simple healthbar script for players; an variable, window panel + frame panel and a digit panel if you want that too. When you an action/function effects the player health just change healthplayer variable in that action/function.

e.g. what I use in one of my maps:
Code:
BMAP* healthbarframe_bmp = "healthbarframe.bmp";
... 
var healthplayer = 150;
...

PANEL* first_pan =
{
	pos_x = 1077;
	pos_y = 919;
	layer = 1;
	bmap = healthbarframe_bmp;
	flags = OVERLAY | SHOW;
}

PANEL* second_pan =
{
    window (1080, 919, 65, 25, "healthbar.bmp", healthplayer, 0);
    flags = SHOW;
}

PANEL* third_pan =
{
	digits (1100, 900, 3, "Arial#15b", 0.667, healthplayer); 
	flags = SHOW | OUTLINE;



If players regenerate health, you can add this code within a while loop in the main function;

Code:
if (healthplayer < 150)
healthplayer += 0.03;



Hope that helps somewhat!


Last edited by reknak; 02/22/11 21:17. Reason: added BMAP*
Re: Bahh, dunno whats wrong [Re: reknak] #360171
02/22/11 16:14
02/22/11 16:14
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
o don't think that this code really helps him, because you have many errors!
so first think about your code and test it before posting!
corrected:
Code:
var healthplayer = 150;
...
PANEL* first_pan =
{
	pos_x = 1077;	//It works, but only for one screen resolution!
	pos_y = 919;	//The same here!
			//Fix: Function which updates the position
	bmap = "healthbarframe_bmp";	//Forgot quotation marks
	window (1080, 919, 65, 25, "healthbar.bmp", healthplayer, 0);
	//Can be used directly without new panel
	digits (1100, 900, 3, "Arial#15b", 0.667, healthplayer); 
	//Same here
	flags = SHOW;
	//Refresh isn't needed anymore
	layer = 1;
}

//Your snippet:
if (healthplayer < 150)
	healthplayer = minv(150,healthplayer + 0.03 * time_step);	//Timestep needed because of different frame rates!



Last edited by Richi007; 02/22/11 16:15. Reason: Small code correction

Visit my site: www.masterq32.de
Re: Bahh, dunno whats wrong [Re: MasterQ32] #360236
02/22/11 21:14
02/22/11 21:14
Joined: Jan 2011
Posts: 65
R
reknak Offline
Junior Member
reknak  Offline
Junior Member
R

Joined: Jan 2011
Posts: 65
Quote:
o don't think that this code really helps him, because you have many errors!
, nah it works perfectly with me, maybe I made some spelling errors


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1