HP Bar above head?

Blitz3D Forums/Blitz3D Programming/HP Bar above head?

Guy Fawkes(Posted 2009) [#1]
Can someone show me an example of how to put ANY kind of HP, MP, magic, w/e bar above a players head?


BlitzSupport(Posted 2009) [#2]
Just take the x/y values from this code and draw rectangles representing the full value/current values as appropriate (add offsets to the x/y values as necessary):

LabelEntity (camera, entity, text$)


Guy Fawkes(Posted 2009) [#3]
Thanks alot! :D


Guy Fawkes(Posted 2009) [#4]
um yea. i need this in a 3d view. not just looking like its text positioned somewhere on the screen.

like when my character turns, i need the text to turn too.


Warner(Posted 2009) [#5]
sp = LoadSprite("img.bmp")
Entityparent sp, player
PositionEntity sp, 0, 5, 0
?


GIB3D(Posted 2009) [#6]
That LabelEntity code was posted over 7 years ago! Wow Blitz is old.


AJ00200(Posted 2009) [#7]
Do you know trigonometry?


Guy Fawkes(Posted 2009) [#8]
no. sorry. lol. why?

is there a way to use label entity, turn the hp rectangle into a sprite, and position that sprite above my player head and use warners code to be able to make it 3d coordinates? :)


AJ00200(Posted 2009) [#9]
Yes, make sprites for all the HPs (or every 5)
Parent it to the player.

Trigonometry would make it work too.


Guy Fawkes(Posted 2009) [#10]
um. how do i turn a rectangle into a sprite?

i need to see examples. i learn by example man :)


AJ00200(Posted 2009) [#11]
no, just make the images.
like in paint or GIMP or whatever you use.
one at 100%
one at 95%
one at 90%
...
or go every 10%


Warner(Posted 2009) [#12]
tex = createtexture(64,64)
rect 0, 0, 64, 64 ;draw rectangle
copyrect 0, 0, 64, 64, 0, 0, backbuffer(), texturebuffer(tex) ;copy to texture
sprite = createsprite() ;create sprite
entityparent sprite, player ;put texture on sprite
positionentity sprite, 0, 5, 0 ;put sprite on player
entitytexture sprite, tex



Guy Fawkes(Posted 2009) [#13]
no. what im saying is. can i use grabimage to turn it into an image, and then from there, use createsprite to turn it into a sprite?


AJ00200(Posted 2009) [#14]
^^
Just do something like that.
Use a loop to make the values into an array.

Sorry, I don't have time to code it right now.
If I get time tomorrow, I'll come back and code it for you.

Read my footer about UK internet tax :)


Guy Fawkes(Posted 2009) [#15]
ok, thanks :)


_PJ_(Posted 2009) [#16]
There's a few ways to accomplish this, many will require re-drawing the sprite, and more still will involve using greater resources.

Some variants (typical of suggestions above too) are here, with the 3rd one, being the preferred method in my opinion.

Solution 1:
Accurate, but slow.
Repaint a sprite with a unique brush which draws a rectangle to the required size each time, or update the existing texture each time a change to the HP or whatever value is made.

Solution 2:
Cheesey and slow due to 2D, but very easy,
Use the labelentity code, but for te string, use a number of "CHR$(9)"s proportional to the value you want (technically A 'Tab control', but as a printed character, it shows as a rectangular block.

Solution 3:
Fastest and most accurate, but most complex.
Use a quad as the bar. Make sure its length is the precise length you require for "full"
Ensure the reverse of the quad is culled.
At "FULL", the quad should face the camera directly.
Whenever the HP or whatever is changed, rotate the quad by HP% in Gradians. Alternatively, use ScaleEntity in the X (or Y for verrtical bar) axis relative to the camera view.
Ensure the changes are LOCAL, but the quad remains a child of the 'character', but iots rotation must be coordinated relative to the camera facing.


Guy Fawkes(Posted 2009) [#17]
step 1. way to cheesy.
step 2. i have a variation thats faster.
step 3. i have NO idea what u talkin about.

lol


Terry B.(Posted 2009) [#18]
take the x and y values from a CameraProject of the entity you want the bar over, subtract a few units from the y, then draw a rect there.


Guy Fawkes(Posted 2009) [#19]
thanks :)


Kryzon(Posted 2009) [#20]
.


Guy Fawkes(Posted 2009) [#21]
ok. so could u show me a demo using the red hp bar u have there?

and 1 w/o "c.character", im good, but not that good. hehe


Kryzon(Posted 2009) [#22]
.


Guy Fawkes(Posted 2009) [#23]
um, i need "Health_Counter.tga"

"Health_Counter_glare.tga"

"Health_Counter_burn.tga"

and "life.bmp"


Guy Fawkes(Posted 2009) [#24]
also, how would i turn that bar into light blue, green, yellow, and purple?


GIB3D(Posted 2009) [#25]
Make the texture white so then you can use EntityColor on it to make it any color.


Guy Fawkes(Posted 2009) [#26]
how do i make it white? im not a good photoshopist :P


Ross C(Posted 2009) [#27]
Goto paint, and draw a white rect?


GIB3D(Posted 2009) [#28]
Um.... heh.... :O Well... I use Paint Shop Pro Photo X2 so all I have to do is press the Greyscale button but I don't know about you. Or you could just remake it using black and white?


Guy Fawkes(Posted 2009) [#29]
um yea. i need to make sure it keeps the shine in the middle of the bar.


Ross C(Posted 2009) [#30]
The shine is a seperate element, from reading the file names anyway.


Guy Fawkes(Posted 2009) [#31]
it still needs to be a gradient though. and i sucks at gradients :P


Ross C(Posted 2009) [#32]
What about drawing the white bar rect. Then drawing a slightly darker gray for the gradient. Then just blur the whole thing.


Guy Fawkes(Posted 2009) [#33]
well the prob is. i dont have good programs. i only have paint. and again, i suck at paint. the ONLY thing i COULD do would be to make a gradient code using blitzbasic, but then again, idk how to fade rects yet, so yea..


Ross C(Posted 2009) [#34]



Ross C(Posted 2009) [#35]
Slap that one and use vertexcolor, or entitycolor to change the color.


Guy Fawkes(Posted 2009) [#36]
WOH! Howd u do that?!


Ross C(Posted 2009) [#37]
Draw a white rect. Draw a slightly grey rect. Blur it a little.


Guy Fawkes(Posted 2009) [#38]
ahh. what program? blitz?


Ross C(Posted 2009) [#39]
Photoshop old version. GIMP could do it. So could blitz. You could do it in paint, which would be more painstaking.


Guy Fawkes(Posted 2009) [#40]
im trying paintshop pro photo x2 ^^


Guy Fawkes(Posted 2009) [#41]
so i could use this?

IMAGES REMOVED BY ~DS~


Ross C(Posted 2009) [#42]
Yeah, just draw the bar beneath it, filling up.


Guy Fawkes(Posted 2009) [#43]
ok. can u tell me how i can make it shine EXACTLY like he did?


Guy Fawkes(Posted 2009) [#44]
can someone plz help me make this image transparent?

IMAGES REMOVED BY ~DS~

also, to all those out there who need a health bar or W/E kind of bar, here's the gradient for it, edited in paintshop pro photo x2, and hacked in paint :)

IMAGES REMOVED BY ~DS~

u may use either or. i dont mind. and i hope kryzon doesnt either. i DID edit it :P

~DS~


Guy Fawkes(Posted 2009) [#45]
also, here's the 2 ends. they also need transparent.

IMAGES REMOVED BY ~DS~

~DS~


Ross C(Posted 2009) [#46]
I don't see why the ends need to be transparent? It's only the shine image that needs to be see through. Personally, i'd just make the vertices transparent, rather than the texture :)


Guy Fawkes(Posted 2009) [#47]
um. i have NO idea how to do that.

can u help me plz?


Guy Fawkes(Posted 2009) [#48]
also, yes the ends need to be transparent also.

WHY? im gonna put the gradient in the middle, do a little math, and add the end points ;)


Guy Fawkes(Posted 2009) [#49]
unless theres a way u could make the whole thing transparent. i posted it above. just make it transparent somehow, and post back on here :)


Guy Fawkes(Posted 2009) [#50]
also, what am i doing wrong here?

EDIT: LINK REMOVED

code:

Const GW = 800
Const GH = 600

Graphics3D GW,GH,0,2
SetBuffer BackBuffer()

camera = CreateCamera()
ClearTextureFilters() 

barx# = 320
bary# = 240

Global Life_Vertex_X#,Life_Vertex_EndX#,Life_Vertex_PositiveY#,Life_Vertex_NegativeY#
Global Life_Vertex_StartX#
Global surf

sprite = LoadOverlay("leftbar_part.PNG",2)
;sprite = LoadOverlay("Health_Counter.tga",2)
ScaleSprite sprite,0.4,0.1
PositionSprite Sprite,barx,bary

CreateLifeBar(sprite,barx,bary)

sprite = LoadOverlay("right_barpart.png",2)
;sprite = LoadOverlay("Health_Counter_glare.tga",2)
ScaleSprite sprite, 0.4,0.1 
PositionSprite Sprite,barx,bary
EntityOrder sprite,-3

sprite = LoadOverlay("grad.png",2)
;sprite = LoadOverlay("Health_Counter_burn.tga",2)
b = GetEntityBrush(sprite)
PaintEntity sprite,b
ScaleSprite sprite, 0.4,0.1 
PositionSprite Sprite,barx,bary
EntityOrder sprite,-2

While Not KeyHit(1)

   RenderWorld()

   Life_Vertex_X = Life_Vertex_X + (KeyDown(203)*-0.01) + (KeyDown(205)*0.01)
   If Life_Vertex_X > Life_Vertex_EndX Then Life_Vertex_X = Life_Vertex_EndX
   If Life_Vertex_X < Life_Vertex_StartX Then Life_Vertex_X = Life_Vertex_StartX
   If KeyHit(57) Then Life_Vertex_X = Life_Vertex_EndX
   VertexCoords surf,1,Life_Vertex_X,Life_Vertex_PositiveY,1
   VertexCoords surf,3,Life_Vertex_X,Life_Vertex_NegativeY,1
   Text GW/2,GH/2-50,Int((Life_Vertex_X-Life_Vertex_StartX)/(Life_Vertex_EndX-Life_Vertex_StartX) * 100),True,True 

   Flip

Wend


Function ScreenXCoordinate#(X#)
   Return (((X*(GW*1.0/640)-GW/2)/GW)*2) 
End Function

Function ScreenYCoordinate#(Y#)
   Return ((GH/2-Y*(GH*1.0/480))/(GW/2))
End Function

Function LoadOverlay(File$,flags=1)
   sprite = LoadSprite(File,flags)
   Return sprite 
End Function

Function PositionSprite(Sprite,X#,Y#)
   PositionEntity Sprite,ScreenXCoordinate#(X),ScreenYCoordinate(Y),1
End Function

Function CreateLifeBar(lifesprite,X,Y)
   mesh = CreateMesh(lifesprite)
   surf = CreateSurface(mesh)

   v1 = AddVertex(surf,screenXcoordinate(X-184),screenYcoordinate(Y-24),1,0,0)
   v2 = AddVertex(surf,screenXcoordinate(X+185),screenYcoordinate(Y-24),1,1,0)
   v3 = AddVertex(surf,screenXcoordinate(X-184),screenYcoordinate(Y+24),1,0,1)
   v4 = AddVertex(surf,screenXCoordinate(X+185),screenYcoordinate(Y+24),1,1,1)
 
   AddTriangle(surf,v1,v2,v4) : AddTriangle(surf,v4,v3,v1) 
   EntityOrder mesh,-1
   EntityFX mesh,1+8

   Life_Vertex_StartX# = screenXcoordinate(X-184)
   Life_Vertex_EndX# = screenXcoordinate(X+185)
   Life_Vertex_X# = Life_Vertex_EndX
   If GraphicsHeight() = 480 Then add = 25 ;-------------;
   If GraphicsHeight() <> 480 Then add = 24 ;------------;
   Life_Vertex_PositiveY# = screenYcoordinate(Y-24) ;----;-----  Just because of some aliasing issue.
   Life_Vertex_NegativeY# = screenYcoordinate(Y+add) ;---;

   EntityTexture mesh,LoadTexture("life.bmp",1+32)

   Return mesh
End Function

End


~DS~


Ross C(Posted 2009) [#51]
Sorry man, i don't have enough free time to dedicate, and i don't know how to get alpha into a png image :(


Guy Fawkes(Posted 2009) [#52]
*sigh* kryzon, what about u?


fireshadow4126(Posted 2009) [#53]


did this in Macromedia Fireworkds MX 2004

so easy to do transparency. All u have to do is create a new file and set the canvas color to transparent

don't know how to do vertical gradients tho


Guy Fawkes(Posted 2009) [#54]
can u do that for this?

IMAGES REMOVED BY ~DS~


Kryzon(Posted 2009) [#55]
I don't want anybody to use the images in that demo; they are for my game and my game alone.

They are Copyright 2009 Rafael Navega.


Guy Fawkes(Posted 2009) [#56]
hey. BACKOFF. i didnt know ok? Gawd......


Guy Fawkes(Posted 2009) [#57]
ok. how about this. u tell me HOW u made it, and i wont use a modified version of urs.


Guy Fawkes(Posted 2009) [#58]
o. and fyi? i removed the images. your welcome. -.-


Guy Fawkes(Posted 2009) [#59]
and i ask that u remove that flame. i did u a favor by deleting ur graphics from the internet. now u do me the same favor in return.


Guy Fawkes(Posted 2009) [#60]
O. and fyi? i didnt SEE ANY copyright either in a README OR in OR ON the program.


Kryzon(Posted 2009) [#61]
.


Guy Fawkes(Posted 2009) [#62]
np. im sorry if i offended u... that wasnt any intention i had... :(

TEXT REMOVED BY: ~DS~


Kryzon(Posted 2009) [#63]
.


Guy Fawkes(Posted 2009) [#64]
Yes, please. i would like love if u could do that for me.

id be honored if u told me how :)

thanks again! :)

for editing the post, AND helping me again! :)

~DS~


LineOf7s(Posted 2009) [#65]
If I may borrow from Seinfeld for a moment, to make a personal observation about this thread:

"He is a loathsome, offensive brute, yet I can't look away."

[edit] For those confused by the reference, I'm talking about the thread itself, not DSW personally. I can't decide whether to shout "More! More!" or "For the love of God kill it! Kill it with fire!"


Guy Fawkes(Posted 2009) [#66]
btw, im a step-by-step sorta person.

as u have witnessed.

so if u could please explain step-by-step and maybe do a sample thats NOT copyright (optional), id REALLY appreciate it! :)

~DS~


Guy Fawkes(Posted 2009) [#67]
EXCUSE me, lineof7s? i take that as an offense..

u know DARN well i didnt mean to.

he DID have no copyright on it.

so i thought otherwise..

~DS~


Guy Fawkes(Posted 2009) [#68]
i have PROOF of copywriting my prog.

even i copyrighted my character creator.

;-------------------------------------------------------------------
;Chara Create - Version 1.0
;This header must remain INTACT at ALL times...
;---------------------------------------------------------------
;Created by: ~DarkShadowWing~ of: http://blitzbasic.com
;============================================================
;You may NOT steal this code and use it for your own personal usage without the authors written permission
;Any chance of doing so will automatically result in a copyright infringement...
;If you remove this header, you will be prosecuted to the fullest extent of the law...
;============================================================
;-------------------------------------------------------------------


~DS~


Kryzon(Posted 2009) [#69]
.


Guy Fawkes(Posted 2009) [#70]
thanks alot, kryzon. i will copy this to notepad so i can read it a bit later. i need to edit 2 more final bugs out of my character creator, then fuse it with my rpg, so yea.. :P

Thanks again!

for all your help!

~DS~


Guy Fawkes(Posted 2009) [#71]
o lineof7s was making fun of me. lol using a quote from seinfeld :P


Flemmonk(Posted 2009) [#72]
Can you really copyright code like that that you have simply copy and pasted from other people's helpful posts?


Ross C(Posted 2009) [#73]
I wouldn't copyright any of the code either. Considering most stuff posted on here is free to use by anyone, copyrighting it goes againnst the spirit of things. Plus, it's not exactly rocket science code.

You need to learn to calm down a bit man.


_PJ_(Posted 2009) [#74]
To bwe honest, piblished material is copyrighted unless specified otherwise.
However, with certain types of material (such as company logos for example), it is a requirement that ownership is enforced, otherwise the copyright will eb lost. So LineOf7's was well within his rights (indeed, legally required) to defend his ownership.

Copyrighting code itself is a bit of a grey area, seeing as nobody can own copyright to the individual wording, and the techniques applied may perhaps be patented but there's little chance it''s original.


LineOf7s(Posted 2009) [#75]
There's a difference between copyright and trademarks... and you're talking about trademarks.

And it wasn't me; that was Kryzon that was so unfortunately swept up into the maelstrom of terror that is a DSW thread.


Guy Fawkes(Posted 2009) [#76]
well excuuuuuuuuuuuuuuuuse me, princess. i was supposed to know that HOW?


Ross C(Posted 2009) [#77]
Why you so angry all the time?


Guy Fawkes(Posted 2009) [#78]
because i have problems of my own, and i dont need lineof7s giving me crap on top of it..


_PJ_(Posted 2009) [#79]
Sorry, LineOf7's and yes, trademarks. Though I mentioned company logos just as an example, it's by no means exclusive. I think the maelstrom current swept me off too ;)

DSW - It wasn;t an attack, just pointing out. There's a LOT of legislation around copyright and IP, made even more complex and confusing now the Internet has kindly globalised everybody's publishing and I doubt there's many non-legal-professionals that understand it all, however, if you intend to deal with copyright/piblishing and so on within a global forum (by forum, I mean its original definition, though it applies here anyway), then ideally you should check up and make sure you are aware of implications and restrictions, after all, ignorance is rarely legally acquitting.


Kryzon(Posted 2009) [#80]
that was Kryzon that was so unfortunately swept up into the maelstrom of terror that is a DSW thread.

God, a tear dropped out of my eye from the poetic magnificence of that sentence.