Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Health Bars
- Coolbee14
-
13 posts
Health Bars
How do I make Amy health bars? I have a game that uses lots of enemies and it has the mall on the same screen at a time. So I want to make it like a regular health bar or if you hit it it goes down automatically. How would I make that? Is it possible to use a list of variables? I think I could but I'm just wondering if I have to put in every single detail at to work. I know there's a few videos out there but it's kind of hard to find a good one. Can you guys send a video link or something?
Thank you- Coolbee
Thank you- Coolbee
- red-fox-codes
-
43 posts
Health Bars
How do I make Amy health bars? I have a game that uses lots of enemies and it has the mall on the same screen at a time. So I want to make it like a regular health bar or if you hit it it goes down automatically. How would I make that? Is it possible to use a list of variables? I think I could but I'm just wondering if I have to put in every single detail at to work. I know there's a few videos out there but it's kind of hard to find a good one. Can you guys send a video link or something?
Thank you- Coolbee
Create a list of all enemy health.
Create a list of all enemy x positions.
Create a list of all enemy y positions.
This allows up to 20,000 enemies at a time.
Create a sprite and name it “Pen” or “hpRenderer” or something.
Add the following code:
Pen up.
Change pen color to black.
Go to x: (enemyX + (hpBarSize / 2))
Pen down.
Go to x: (enemyX - (hpBarSize / 2))
Pen up.
Change pen color to green.
Go to x: (enemyX + (hpBarSize / 2))
Pen down.
Go to x: ((enemyX + (hpBarSize / 2)) - enemyHealth)
Pen up.
If that was confusing I could make a demo for you, which would be easier to follow.
- Coolbee14
-
13 posts
Health Bars
Ok, that makes sense. Also lol I just realized I forgot to overlook it before sending it. I used speech to text… How would I make the enemy health variable? I saw you said a list, do I put the enemy name or something to classify them and then their health or how should I make it?
Last edited by Coolbee14 (April 17, 2023 23:48:35)
- --Dovahkiin--
-
100+ posts
Health Bars
Just put the health amount in the list and use the numbers on the side to match health to the right enemies.
Then you can use this block thing for finding the amount of it
It also could help to make a comment inside your project naming the enemies and what number they are
They will add in order so the 1st one here matches to the weaker enemy. Hope this helps
(also you can use this to see if they are dead)
Note: The comments don't actually do anything but help you figure out and keep track of the lists and enemies, so make sure to put code under the right enemies and stuff. (I keep editing this so much lol)
Then you can use this block thing for finding the amount of it
It also could help to make a comment inside your project naming the enemies and what number they are
They will add in order so the 1st one here matches to the weaker enemy. Hope this helps
(also you can use this to see if they are dead)
and item one is the Basic enemy as stated above. (But you can have it in any way, this is just how I wrote out the list)
Note: The comments don't actually do anything but help you figure out and keep track of the lists and enemies, so make sure to put code under the right enemies and stuff. (I keep editing this so much lol)
Last edited by --Dovahkiin-- (April 18, 2023 00:04:07)
- Dinosaurguy77
-
500+ posts
Health Bars
To do this you must make a sprite with 5 costumes. Make the first 1 full hp.
The second one should have 3 fourths of hp.
The 3rd one should be 1 half hp left.
The 4th one should have 1 fourth hp left.
And the 5th costume should be no hp left.
Welcome.
-Dinosaurguy77
The second one should have 3 fourths of hp.
The 3rd one should be 1 half hp left.
The 4th one should have 1 fourth hp left.
And the 5th costume should be no hp left.
Welcome.
-Dinosaurguy77
- kkidslogin
-
1000+ posts
Health Bars
Here's my fancy pen code, usually in a separate sprite:
Don't let health_max change unless the maximum health for the sprite changes as well. The “clear” block is actually the “Erase All” block in Scratch 3.
Don't let health_max change unless the maximum health for the sprite changes as well. The “clear” block is actually the “Erase All” block in Scratch 3.
- Coolbee14
-
13 posts
Health Bars
How do I make Amy health bars? I have a game that uses lots of enemies and it has the mall on the same screen at a time. So I want to make it like a regular health bar or if you hit it it goes down automatically. How would I make that? Is it possible to use a list of variables? I think I could but I'm just wondering if I have to put in every single detail at to work. I know there's a few videos out there but it's kind of hard to find a good one. Can you guys send a video link or something?
Thank you- Coolbee
Create a list of all enemy health.
Create a list of all enemy x positions.
Create a list of all enemy y positions.
This allows up to 20,000 enemies at a time.
Create a sprite and name it “Pen” or “hpRenderer” or something.
Add the following code:
Pen up.
Change pen color to black.
Go to x: (enemyX + (hpBarSize / 2))
Pen down.
Go to x: (enemyX - (hpBarSize / 2))
Pen up.
Change pen color to green.
Go to x: (enemyX + (hpBarSize / 2))
Pen down.
Go to x: ((enemyX + (hpBarSize / 2)) - enemyHealth)
Pen up.
If that was confusing I could make a demo for you, which would be easier to follow.
How do I make a system so the enemies know what item number they are? If all of the enemies are one sprite, and I just have multiple clones, what should I do to keep everything organized?
Last edited by Coolbee14 (April 24, 2023 19:09:45)
- yvin
-
1 post
Health Bars
How do I make Amy health bars? I have a game that uses lots of enemies and it has the mall on the same screen at a time. So I want to make it like a regular health bar or if you hit it it goes down automatically. How would I make that? Is it possible to use a list of variables? I think I could but I'm just wondering if I have to put in every single detail at to work. I know there's a few videos out there but it's kind of hard to find a good one. Can you guys send a video link or something?
Thank you- Coolbee
Create a list of all enemy health.
Create a list of all enemy x positions.
Create a list of all enemy y positions.
This allows up to 20,000 enemies at a time.
Create a sprite and name it “Pen” or “hpRenderer” or something.
Add the following code:
Pen up.
Change pen color to black.
Go to x: (enemyX + (hpBarSize / 2))
Pen down.
Go to x: (enemyX - (hpBarSize / 2))
Pen up.
Change pen color to green.
Go to x: (enemyX + (hpBarSize / 2))
Pen down.
Go to x: ((enemyX + (hpBarSize / 2)) - enemyHealth)
Pen up.
If that was confusing I could make a demo for you, which would be easier to follow.
How do I make a system so the enemies know what item number they are? If all of the enemies are one sprite, and I just have multiple clones, what should I do to keep everything organized?
Not sure what you need it for exactly, but here's an idea. You need to maintain a list of enemies' IDs. It should be placed in a common place, like the stage. Adding a unique clone ID should be performed by the clone itself. And the ID should be stored in the clone as well:
- booger_and_moose
-
1 post
Health Bars
Have you made a health bar sprite yet? If you have, do this:
- Discussion Forums
- » Help with Scripts
-
» Health Bars