Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to put a health bar up in scratch
- Shadow844
- New to Scratch
2 posts
How to put a health bar up in scratch
I need help with putting a health bar up in scratch and i have already tried many things PLZ HELP ME!
- elias_the_dank
- New to Scratch
9 posts
How to put a health bar up in scratch
There are multiple ways to create a “health bar” in Scratch. You can create a variable for your character's health and just change it whenever it gets “hit” like this:
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!
when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
end
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!
- -alexjai1
- Scratcher
19 posts
How to put a health bar up in scratch
Use a variable for the number of health you have, (e.g.
This is quite a wordy explanation, but I hope it helps.
set [health v] to [10]and make a health bar sprite, and make ten different costumes, for when you lose 1 health, it switches to a costume with a health bar showing 9/10 full. Then you keep losing health, every one health lost the costume switches. 0/10 health bar health = 0). Name each costume with the number of health that costume represents e.g. name the 9/10 one “9”. Have something like this to continuously switch to the correct costume.
foreverBy the way, put the health variable oval in the costume slot (where “(health)” is)
switch costume to [(health) v]
end
This is quite a wordy explanation, but I hope it helps.
Last edited by -alexjai1 (Dec. 19, 2017 20:43:29)
- hirsh001
- Scratcher
100+ posts
How to put a health bar up in scratch
You can use pen to draw the health bar(Pen size equals diameter). That way, you can have is display an any(not really cause pixles) number of health. If you need help, I can provide the code, but you would need to share the project.
Last edited by hirsh001 (Dec. 24, 2017 23:54:25)
- sabas_ll
- Scratcher
1 post
How to put a health bar up in scratch
how do i make a sprite make a different sprite lose health
- hirsh001
- Scratcher
100+ posts
How to put a health bar up in scratch
just create different health bars how do i make a sprite make a different sprite lose health
- KalicatKatico
- Scratcher
14 posts
How to put a health bar up in scratch
So my basic health bar is I make a “health bar” sprite with 4 costumes: “full”, “75%”, “50%”, and “25%”. I also make a “Health” variable. The bar sprite is linked to the variable so it changes depending on the variable's value. The code goes something like this:
when green flag clicked
if (Health = 100) then
switch costume to [costume1 v]
end
if (Health <[100] and Health > [75]) then
switch costume to [costume2 v]
end
if (Health < [75] and Health > [50]) then
switch costume to [costume3 v]
end
if (Health < [50] and Health > [25]) then
switch costume to [costume4 v]
end
if (Health < [25] and Health > [0]) then
switch costume to [costume5 v]
end
Last edited by KalicatKatico (Dec. 30, 2018 00:57:21)
Cats don't need signatures.
- BereketY
- Scratcher
500+ posts
How to put a health bar up in scratch
I would recommend using a sprite rather than a pen render if you are dealing with layers.
Arrays speak to me on a spiritual level.
- TerraisLife
- New to Scratch
1 post
How to put a health bar up in scratch
_
Last edited by TerraisLife (April 8, 2019 20:15:53)
- ipaddude
- Scratcher
100+ posts
How to put a health bar up in scratch
sorry, did you mean There are multiple ways to create a “health bar” in Scratch. You can create a variable for your character's health and just change it whenever it gets “hit” like this:when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
end
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!
when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
end
Last edited by ipaddude (April 8, 2019 20:28:27)
- Kraken_Games
- Scratcher
100+ posts
How to put a health bar up in scratch
Don't spam or necropost - you are doing both. _
sorry, did you mean There are multiple ways to create a “health bar” in Scratch. You can create a variable for your character's health and just change it whenever it gets “hit” like this:when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
end
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
end
Please don't necropost
KRAKEN_GAMES
I live in the depths
.)
- IPlayGames_101
- New to Scratch
1 post
How to put a health bar up in scratch
idc if this is necro posting but this helps alot
- codeman1044
- Scratcher
1000+ posts
How to put a health bar up in scratch
Glad it helps but yes, you're necroposting, so please refrain from doing it. idc if this is necro posting but this helps alot
Last edited by codeman1044 (Oct. 16, 2019 00:23:31)
This is my signature, which shows up every time I post and is automatic. To make a signature of your own, locate the “Change your signature” option in the bottom left of the Discussion Home.
I am nothing if not consistently inconsistent.
Snap! is a website that offers block coding like Scratch, but also offers the creation of your own blocks and writing JavaScript functions. The adventurous should consider checking it out!
Potentially useful tutorials and topic coverage
If you want to see a new tutorial added to this, feel free to leave a suggestion on my profile.
- CrazyCoolV
- Scratcher
1 post
How to put a health bar up in scratch
how would you make your sprite ‘die’ after the health bar is empty?
- PersRufaro
- Scratcher
100+ posts
How to put a health bar up in scratch
Please don't necropost. It's when you post on an old topic. Thank you efdfsefse
This is my signature. It appears under all my posts.
- FoofJr
- Scratcher
100+ posts
How to put a health bar up in scratch
when green flag clicked
set [health v] to [10]
forever
if <touching [something bad v]> then
change [health v] by [-1]
end
end
Why hello there! Wonder why you are checking out my signature. While you're at it, why not check out my Gradient generator?
- Discussion Forums
- » Help with Scripts
- » How to put a health bar up in scratch