HP Bar above head?
Blitz3D Forums/Blitz3D Programming/HP Bar above head?
| ||
Can someone show me an example of how to put ANY kind of HP, MP, magic, w/e bar above a players head? |
| ||
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$) |
| ||
Thanks alot! :D |
| ||
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. |
| ||
sp = LoadSprite("img.bmp") Entityparent sp, player PositionEntity sp, 0, 5, 0? |
| ||
That LabelEntity code was posted over 7 years ago! Wow Blitz is old. |
| ||
Do you know trigonometry? |
| ||
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? :) |
| ||
Yes, make sprites for all the HPs (or every 5) Parent it to the player. Trigonometry would make it work too. |
| ||
um. how do i turn a rectangle into a sprite? i need to see examples. i learn by example man :) |
| ||
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% |
| ||
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 |
| ||
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? |
| ||
^^ 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 :) |
| ||
ok, thanks :) |
| ||
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. |
| ||
step 1. way to cheesy. step 2. i have a variation thats faster. step 3. i have NO idea what u talkin about. lol |
| ||
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. |
| ||
thanks :) |
| ||
. |
| ||
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 |
| ||
. |
| ||
um, i need "Health_Counter.tga" "Health_Counter_glare.tga" "Health_Counter_burn.tga" and "life.bmp" |
| ||
also, how would i turn that bar into light blue, green, yellow, and purple? |
| ||
Make the texture white so then you can use EntityColor on it to make it any color. |
| ||
how do i make it white? im not a good photoshopist :P |
| ||
Goto paint, and draw a white rect? |
| ||
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? |
| ||
um yea. i need to make sure it keeps the shine in the middle of the bar. |
| ||
The shine is a seperate element, from reading the file names anyway. |
| ||
it still needs to be a gradient though. and i sucks at gradients :P |
| ||
What about drawing the white bar rect. Then drawing a slightly darker gray for the gradient. Then just blur the whole thing. |
| ||
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.. |
| ||
|
| ||
Slap that one and use vertexcolor, or entitycolor to change the color. |
| ||
WOH! Howd u do that?! |
| ||
Draw a white rect. Draw a slightly grey rect. Blur it a little. |
| ||
ahh. what program? blitz? |
| ||
Photoshop old version. GIMP could do it. So could blitz. You could do it in paint, which would be more painstaking. |
| ||
im trying paintshop pro photo x2 ^^ |
| ||
so i could use this? IMAGES REMOVED BY ~DS~ |
| ||
Yeah, just draw the bar beneath it, filling up. |
| ||
ok. can u tell me how i can make it shine EXACTLY like he did? |
| ||
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~ |
| ||
also, here's the 2 ends. they also need transparent. IMAGES REMOVED BY ~DS~ ~DS~ |
| ||
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 :) |
| ||
um. i have NO idea how to do that. can u help me plz? |
| ||
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 ;) |
| ||
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 :) |
| ||
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~ |
| ||
Sorry man, i don't have enough free time to dedicate, and i don't know how to get alpha into a png image :( |
| ||
*sigh* kryzon, what about u? |
| ||
![]() 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 |
| ||
can u do that for this? IMAGES REMOVED BY ~DS~ |
| ||
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. |
| ||
hey. BACKOFF. i didnt know ok? Gawd...... |
| ||
ok. how about this. u tell me HOW u made it, and i wont use a modified version of urs. |
| ||
o. and fyi? i removed the images. your welcome. -.- |
| ||
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. |
| ||
O. and fyi? i didnt SEE ANY copyright either in a README OR in OR ON the program. |
| ||
. |
| ||
np. im sorry if i offended u... that wasnt any intention i had... :( TEXT REMOVED BY: ~DS~ |
| ||
. |
| ||
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~ |
| ||
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!" |
| ||
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~ |
| ||
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~ |
| ||
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~ |
| ||
. |
| ||
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~ |
| ||
o lineof7s was making fun of me. lol using a quote from seinfeld :P |
| ||
Can you really copyright code like that that you have simply copy and pasted from other people's helpful posts? |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
well excuuuuuuuuuuuuuuuuse me, princess. i was supposed to know that HOW? |
| ||
Why you so angry all the time? |
| ||
because i have problems of my own, and i dont need lineof7s giving me crap on top of it.. |
| ||
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. |
| ||
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. |