Discuss Scratch

butterbar19
Scratcher
16 posts

How do I make an expandable Health Bar using clones?

I am trying to make a health bar using clones of a sliver, much like seen in this project.
However, I am trying to make a game much like Dark Souls, in which the health bar's maximum capacity can expand and shrink visibly depending on the player's stats.

I've been able to make a block to create the bar, but the biggest problem I've run into is deleting all of the clones to reset the bar. I still can't wrap my head around how to do this, or to make motion in the bar (not completely necessary.)

Does anyone know how to mass delete all of a sprite's clones, or even a better way to create an expandable health bar? (Pen is not an option.)

Thank you!
MrKingofScratch
Scratcher
100+ posts

How do I make an expandable Health Bar using clones?

Griffpatch has a great tutorial on this that you can check out here. To make the healthbar longer, just modify it so that it uses more clones.

Last edited by kaj (Tomorrow 00:00:00)
100th post!
NamePending_
Scratcher
100+ posts

How do I make an expandable Health Bar using clones?

You can use broadcasts to delete all clones of a sprite.
when I receive [delete clones of \(your sprite here\) v] // Put this in the sprite you want to delete the clones of.
delete this clone

Last edited by NamePending_ (April 5, 2024 01:43:55)


Welcome to my signature!
Was this post helpful? If so, please consider checking out my profile!
say pasta in it please
100 POSTS YESSIRRRRRRRR
butterbar19
Scratcher
16 posts

How do I make an expandable Health Bar using clones?

NamePending_ wrote:

You can use broadcasts to delete all clones of a sprite.
when I receive [delete clones of \(your sprite here\) v] // Put this in the sprite you want to delete the clones of.
delete this clone

This does not work, I believe it only deletes the furthest clone to the right.

I demonstrated my method (and this suggestion) on this test project.
butterbar19
Scratcher
16 posts

How do I make an expandable Health Bar using clones?

MrKingofScratch wrote:

Griffpatch has a great tutorial on this that you can check out here. To make the healthbar longer, just modify it so that it uses more clones.

While this is a helpful tutorial, I don't believe it works in making a health bar that can be expanded or shrunk due to variables.

And about the last part, making the health bar longer is no problem. Resetting it so that I can redraw it with more or less length is the main issue.
Koamodo975
Scratcher
500+ posts

How do I make an expandable Health Bar using clones?

butterbar19 wrote:

I am trying to make a health bar using clones of a sliver, much like seen in this project.
However, I am trying to make a game much like Dark Souls, in which the health bar's maximum capacity can expand and shrink visibly depending on the player's stats.

I've been able to make a block to create the bar, but the biggest problem I've run into is deleting all of the clones to reset the bar. I still can't wrap my head around how to do this, or to make motion in the bar (not completely necessary.)

Does anyone know how to mass delete all of a sprite's clones, or even a better way to create an expandable health bar? (Pen is not an option.)

Thank you!
YES I'VE DONE IT prefer to use pen but booya
You just gotta immediately delete the clones after a ‘wait 0 secs’ block.

Last edited by Koamodo975 (April 5, 2024 16:34:33)


“If a tree falls in the forest, and nobody hears the sound, did it really ever happen at all?
Did it really ever happen at all…?”
But… what about the bugs, and birds, and squirrels and rabbits and foxes and…
-Koamodo975, sometime in 2023
Hang around on the forums sometimes, try and make games without getting sidetracked.

butterbar19
Scratcher
16 posts

How do I make an expandable Health Bar using clones?

Koamodo975 wrote:

butterbar19 wrote:

I am trying to make a health bar using clones of a sliver, much like seen in this project.
However, I am trying to make a game much like Dark Souls, in which the health bar's maximum capacity can expand and shrink visibly depending on the player's stats.

I've been able to make a block to create the bar, but the biggest problem I've run into is deleting all of the clones to reset the bar. I still can't wrap my head around how to do this, or to make motion in the bar (not completely necessary.)

Does anyone know how to mass delete all of a sprite's clones, or even a better way to create an expandable health bar? (Pen is not an option.)

Thank you!
YES I'VE DONE IT prefer to use pen but booya
You just gotta immediately delete the clones after a ‘wait 0 secs’ block.

This works! Thank you so much, you're a lifesaver!
Koamodo975
Scratcher
500+ posts

How do I make an expandable Health Bar using clones?

butterbar19 wrote:

Koamodo975 wrote:

butterbar19 wrote:

I am trying to make a health bar using clones of a sliver, much like seen in this project.
However, I am trying to make a game much like Dark Souls, in which the health bar's maximum capacity can expand and shrink visibly depending on the player's stats.

I've been able to make a block to create the bar, but the biggest problem I've run into is deleting all of the clones to reset the bar. I still can't wrap my head around how to do this, or to make motion in the bar (not completely necessary.)

Does anyone know how to mass delete all of a sprite's clones, or even a better way to create an expandable health bar? (Pen is not an option.)

Thank you!
YES I'VE DONE IT prefer to use pen but booya
You just gotta immediately delete the clones after a ‘wait 0 secs’ block.

This works! Thank you so much, you're a lifesaver!
You're welcome! Gave me a bit of practice too, took me a quick sec to figure out

“If a tree falls in the forest, and nobody hears the sound, did it really ever happen at all?
Did it really ever happen at all…?”
But… what about the bugs, and birds, and squirrels and rabbits and foxes and…
-Koamodo975, sometime in 2023
Hang around on the forums sometimes, try and make games without getting sidetracked.

Koamodo975
Scratcher
500+ posts

How do I make an expandable Health Bar using clones?

I was just wondering, why was pen not an option?

“If a tree falls in the forest, and nobody hears the sound, did it really ever happen at all?
Did it really ever happen at all…?”
But… what about the bugs, and birds, and squirrels and rabbits and foxes and…
-Koamodo975, sometime in 2023
Hang around on the forums sometimes, try and make games without getting sidetracked.

MrKingofScratch
Scratcher
100+ posts

How do I make an expandable Health Bar using clones?

You can use pen, though pen is lower resolution than clones, which is why I suggested clones. However, the main issue with pen is it appears on the background layer, behind all of the sprites and clones, so you would have to make everything with pen. If you really want to make one with pen, it's actually quite simple

when green flag clicked//this is a bad way of triggering it bc everything has to be drawn at the same time
forever
set [%full v] to ((maxHealth) / (health))//max health = hp when bar is full, health = current hp
draw bar
end
define draw bar
//run without screen refresh
set pen size to (15)//thickness of healthbar "outline"
set pen color to [#bfbfbf]//bar empty color
clear//I think this block is called clear all now, you probably position this block in a different script for the final version
go to x: ((healthBarSize) * (.5)) y: (160)//you can mess with the y position
pen down
change x by ((0) - (healthBarSize))
pen up
set pen color to [#fa7a7a]//"filling" color
set pen size to (12)//thickness of filling (should be less than thickness of "outline")
pen down
change x by ((%full) * (healthBarSize))
pen up

Last edited by MrKingofScratch (April 10, 2024 22:53:40)


Last edited by kaj (Tomorrow 00:00:00)
100th post!
malicondii
Scratcher
100+ posts

How do I make an expandable Health Bar using clones?

MrKingofScratch wrote:

snip
They have an answer already, and they said pen isn't an option.

Powered by DjangoBB