How To Create Health Bars | Pygame Tutorial
ฝัง
- เผยแพร่เมื่อ 20 มิ.ย. 2024
- In this video I will explain the how to create a simple health bar in pygame.
I'll show how the health bar is setup, explain the logic and create a class that can be re-used to create multiple health bars.
For the full source code and step by step explanation head over to my website: www.codingwithruss.com/pygame/...
thats so clear dude not like other videos that have 35 minutes to explain small thing
Большое спасибо, за то что регулярно делитесь рабочими связками!!!
I followed your combat game course and i learned how to create health bars. Keep it up!
Nice! The code is mostly the same for those ones.
You rock man. Keep it up. Doing all your projects. You've taught me so much❤
Thanks, glad to hear it!
Hi from Brazil, man, I've been watching your videos for a while and I always learn something new, you're rock! 🔥🔥
Thanks! Glad you like the videos
thank you so much! i was working for like 40 minutes to get a health bar working and this fixed it
Glad it helped!
I love your style dude, subscribed
loved your concise explanation
Thanks!
Very clear explanation.
Cheers!
@@CodingWithRuss
So much so. ✅✅✅
Thanks for this. Its running
Glad it helped
A great project to begin to with HTML CSS and JS also (even though it's in Python)
Simplest explanation possibly. ❤
Thanks :)
how would i do it for a Platformer game.Should make a code so that when i fall to the ground i lose health ?
Yes you could add these health bars into that game and make it so instead of instantly dying when hitting an enemy, you lose health instead.
cool video)
Could you please explain if drawing such a health bar constantly is heavy on performance? In my project i am caching the surf and rect of the hp bar and when player suffers a hp loss, then I am invoking a function to update hp bar and cache a new one. Is this approach considered as optimized?
I haven't noticed any performance issues from using these, but what you suggest makes sense as you can reduce the amount of times the health bar is updated to the times when the health actually changes
@@CodingWithRuss thank you Russ
0:29 or you can create a 3 one Grey one green and one red then the red is I n the same width as the green when you got hit first the green go and then animation for the red
what IDE are u using?
super
Thanks
Hello iam Trimnor. i'm learning python but i dont now on what app to make games. Can you tell me on what app you make games, by the way you are the best.
Hello, I use Sublime text editor
@@CodingWithRuss Tank you
I've trying to use this Class as separate py file and import in Main and method draw doesn't work for me. So can this be used by screen.blit drawing tool? And if so, how to do this?
If you create a game window in your main file, then you will need to pass it into the draw method of this health bar, otherwise it won't know it exists and will throw an error. Put the screen as an argument into .draw() and it should work from there
nice, danke
Glad you like it
Bro you always help us but why don't you provide this program on the message section.😂
idk what is a pygame, but this can work in renpy games?
I haven't used renpy games but the health bar logic can be applied anywhere, it would just need to be coded using the relevant syntax
What to do if on line 27 HealthBar takes no arguments.
and with a circle? i want to do a health bar like diablo 4.
I want you to be my coding teacher pls give my your number
I love your style dude, subscribed
Thanks! Appreciate it.