I need help creating a health-bar. I already created the health-bar image, now I just need help how to give this image a numerical value (I think thats right). I’m fairly new to this, not even a year, so any help will be appreciated.
If you look in EXTENSIONS You’ll see STATUS-BARS.
Status bars Are mainly used as HEALTH BARS.
Oh yes, I am well aware of the extension. The problem is I want to create this health-bar without the use of extensions
I agree with @PixelDoodle this does mean you will have to delete all of your code for health bars, but a bright side is the health bar extension does almost all of the work for you😄.
I would much rather do the work myself.
I want to be able to link maxHp to total health in some way where if maxHp were to decrease part of the health-bar will turn red.
There was this one video on youtube where @richard and the rest of the makecode team were making a survival game and they made health bars from scratch. I think that could help with what your planning on doing.
yes you can, use the status bar extension
calculate the width of the green rectangle according to maxHP and totalhealth instead of using mySprite.width
If you have two rectangles/sprites overlapping each other you could set the fill color z(depth) to be greater than the other damaging health bar. When you lose health you could you the sprite scaling extension and shrink the fill rectangle using the change mysprite horizontally/vertically/uniformly. Probably the horizontally.