Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make code for my Health bar????
- The_rag-_-
-
Scratcher
3 posts
How do I make code for my Health bar????
Yes i really need this plz help ill give u mod form my game
- GamesReinvented
-
New Scratcher
100+ posts
How do I make code for my Health bar????
What kind of healthbar are you looking for? Pen? Sprite? Could you be a bit more specific?
Last edited by GamesReinvented (Sept. 26, 2024 02:13:36)
- The_rag-_-
-
Scratcher
3 posts
How do I make code for my Health bar????
Its a health bar thats a seperate sprite
- EpicGhoul993
-
Scratcher
1000+ posts
How do I make code for my Health bar????
For a health bar, you can either go with a stack-based one or a smooth one.
Here's what a 10-stack health bar looks like if you make it into a scratch block:Boss name (s1 ::#ff0000)(s2 ::#ff0000)(s3 ::#ff0000)(s4)(s5)(s6 ::control)(s7 ::control)(s8 ::operators)(s9 ::operators)(s10 ::operators) ::#000000 hatIf you go with this, you can use 11 costumes (from 0hp->10hp) to cycle through, or use 10 clones to display each stack/segment (the original sprite can be used to make the bar's black part).
If you want to make a smooth health bar, you can make something similar to this:Boss name [------------(transparent part)-------------] ::#000000 hat //first layerThe second layer will move along the horizontal line, controlled by %hp of the boss. You will need a bit of math (and cleverly hiding the parts of the hp bar poking out) to do this though. link
------------[hp bar]------------- ::#aa0000 //second layer that can move
Boss name ---------------------------------------- ::#000000 hat //third layer for background
- NamePending_
-
Scratcher
100+ posts
How do I make code for my Health bar????
NO THIS ISN’T ADVERTISING
I made this project a while back which has a health bar in it similar to the one you seem to want. I made 50 costumes of the health bar, each one showing a different amount of health left. Then, it works by calculating what fraction of its health the player/sprite has left, and changes the costume accordingly. I also have some scripts for health bars in the monsters, although those might be a bit more confusing due to being buried under some other code. I honestly forgot how those ones work.
I made this project a while back which has a health bar in it similar to the one you seem to want. I made 50 costumes of the health bar, each one showing a different amount of health left. Then, it works by calculating what fraction of its health the player/sprite has left, and changes the costume accordingly. I also have some scripts for health bars in the monsters, although those might be a bit more confusing due to being buried under some other code. I honestly forgot how those ones work.
- invalidaccess
-
Scratcher
100+ posts
How do I make code for my Health bar????
i suggest you to watch griffpatch's healthbar tutorial
- Discussion Forums
- » Help with Scripts
-
» How do I make code for my Health bar????