Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Grant, AndrewAMD), 911 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
life meter ontop of enitty #143448
07/26/07 05:44
07/26/07 05:44
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
How do i place a bmap so that it follows where the enemy is relative to the camera? I dont even know where to start...

kinda like runescape... like this: (the green and red bars are life bars)


Can someone please help me get started?


Thanks,
Devon
S.D.S.D.inc.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: life meter ontop of enitty [Re: DLively] #143449
07/26/07 06:37
07/26/07 06:37
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
You need to use vec_to_screen. It converts 3D world coordinates into 2D screen coordinates (You can find this in the manual if you look, ).

You need to define where you want the health bar to be relative to the entity's position with a vector:

Code:

function set_vec_params()
{
while(1)
{
vec_set(temp,vector(ent.x,ent.y,ent.z + height_var);
wait(1);
}
}



Then you use vec_to_screen to convert this vector into 2D screen coordinates:

Code:

function set_vec_params()
{
while(1)
{
vec_set(temp,vector(ent.x,ent.y,ent.z + height_var);
vec_to_screen(temp,camera);
wait(1);
}
}



Then use pan_setpos to match the health bar's coordinates with temp's:

Code:

function set_vec_params()
{
while(1)
{
vec_set(temp,vector(ent.x,ent.y,ent.z + height_var);
vec_to_screen(temp,camera);
pan_setpos(health_pan,5,1,temp);
wait(1);
}
}



This should (if not let me know) give you a health bar that follows the player('s) entity(s) around the map.


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: life meter ontop of enitty [Re: MrCode] #143450
07/26/07 09:26
07/26/07 09:26
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
pan_setpos(health_pan,5,1,temp);

how does this work? what is health_pan? is it a panel? or a bmap?

also, what is the 5 and the 1? what do they do?

Sorry
Devon
S.D.S.D.inc.

Ps. This code isnt in the manual... at least i couldnt find it in there...

Last edited by DevoN; 07/26/07 09:33.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: life meter ontop of enitty [Re: DLively] #143451
07/26/07 19:43
07/26/07 19:43
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
i did vind it in manual

pan_setpos(PANEL*, var type, var num, VECTOR* xy)
Changes the xy position of a panel element.

Parameters:
PANEL* Panel pointer.
type Element type:
1 = digits
3 = button, toggle
4 = slider
5 = window
6 = needle


num Number of the element, starting with 1.
xy Vector containing the element's new x and y values

Remarks:
The changed element is not saved by game_save.
Example:
pan_setpos(_dbg_pan,1,1,vector(20,30,0));


"empty"
Re: life meter ontop of enitty [Re: flits] #143452
07/26/07 21:58
07/26/07 21:58
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Yes, you need to use a panel with a window for your health bar, and set the x, y, and "z" position of the panel to match the entity's.

The z coordinate of the vector that the panel is matching is simply there so that the engine can accurately imitate to panel being in 3D space. Of course if you want the panel to resize ifself according to distance from the camera, you'll probably have to use vec_dist.

Hope I've helped, .


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: life meter ontop of enitty [Re: MrCode] #143453
07/28/07 05:36
07/28/07 05:36
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Hmmm... so i've tried it out... and i cant seem to get it to work...
All it does is place the panel in the corner of the screen...

is what i have done correct? here is what ive got:


Basically, its checking to see if i've hit something after i swung my sword, and if i have, and its health is greater then 0 (so if it even has health) then it will show the enemies hp above the enemies head...

Code:


bmap ehp = <ehpbar.bmp>;
panel enemy_health_pan{
window = 0,0,80,10,ehp,temp.x,temp.y);
}

IF(result != 0){
IF (you != null) {
you.health -= weapon_power;

if(you.health > 0){
enemy_health_pan.visible = on;

vec_set(temp,vector(you.x,you.y,you.z + height_var));
vec_to_screen(temp,camera);
pan_setpos(enemy_health_pan,5,1,temp);

}else{

enemy_health_pan.visible = off;

}

}
}




I also dont understand where i put the enemies health variable in this equation.. help? please


Thanks again,
Devon.
S.D.S.D.inc.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com

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