Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Im a beginer can someone make a code for a health bar?

Author
Message
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 26th Oct 2006 23:37
Hi can somone please place a code snippet on this thread so I can use for my project? Im a beginner and I dont know how to start making one.

Bach Tran
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Oct 2006 00:45
You will get a much better response if you post information on how you have tried to do this yourself first, and the specific problems you are trying to resolve.



Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 27th Oct 2006 00:56
If you have DBPro, I suggest you search the forums for "Healthbar". If not than like BatVink said, try to figure it out yourself, it's not that hard, all you really have to do is set up a variable, maybe add some sprites to make it fancy, and set it so if you collide with something dec the variable. It's a little more complicated than what I just said, but you should be able to figure it out after experimenting a little(plus you can always ask for help here at the forum)

Cocacola and Pepsi aren't that differnt. Deal with it.
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 27th Oct 2006 01:06 Edited at: 27th Oct 2006 01:07
I won't give you code, but I'll explain how you'd do it. If you still can't figure it out, then I'll try to help you some more.

Ok, so, a health bar. What is a health bar? It's a box, more specifically a rectangle. What can we use in DBP that allows us to create a health bar? Well, fortunately for you, there happens to be a "box" command . It's code is: "box left position, top position, right position, bottom position". Try it. Play around with it, until you get what you want.

Health bars aren't normally white. So we'll make it red. There just happens to be code for changing the color of things you write and draw. It's called "ink". Now the code for this is: "ink foreground color, background color". But the computer doesn't read the colors just if you type "red" or "blue", you have to give it a number, but since there are something like 16 million posibilities, the chances that you'll guess the right one are slim. So there's another command that lets the computer calculate the number for you, called "rgb". RedGreenBlue. You give it a red value, a blue value, and a greeen value in this order: "rgb( red, green, blue )", just like it says. The value has to be between 0 and 255, don't ask me why, but that's how the computer reads it . 0 is the darkest version of that color (black), and 255 the lightest version. So if you give it an rgb value of (100, 0, 100), it will give you what color? Medium red and medium blue combined gives you...medium purple . So give it whatever color you want, it doesn't have to be red, so it'd look something like this: "ink rgb( 200, 0, 0 ), 0" (background color doesn't matter). Now you have a simple health bar . If you want me to go into more detail (adding it into 3D and decreasing/increasing it) then tell me, but I don't want to waste time telling you if you don't want to know.

Pirates of Port Royale
Live the life of a pirate.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Oct 2006 01:33
Plain and simple if you cant be bothered reading:



Julius Caesar
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 27th Oct 2006 15:25 Edited at: 27th Oct 2006 15:25
and to change the colour as your health goes down:




Bouncing Physics... How do?
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 27th Oct 2006 23:41
thanks and i use darkbasic classic.

Bach Tran

Login to post a reply

Server time is: 2024-09-25 11:31:49
Your offset time is: 2024-09-25 11:31:49