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/...

ความคิดเห็น • 46

  • @SAC.489
    @SAC.489 12 วันที่ผ่านมา +1

    thats so clear dude not like other videos that have 35 minutes to explain small thing

  • @user-vz2fw1et1h
    @user-vz2fw1et1h 6 หลายเดือนก่อน +1

    Большое спасибо, за то что регулярно делитесь рабочими связками!!!

  • @TheLastProgrammer
    @TheLastProgrammer ปีที่แล้ว +6

    I followed your combat game course and i learned how to create health bars. Keep it up!

    • @CodingWithRuss
      @CodingWithRuss  ปีที่แล้ว +1

      Nice! The code is mostly the same for those ones.

  • @garyonk
    @garyonk ปีที่แล้ว +12

    You rock man. Keep it up. Doing all your projects. You've taught me so much❤

  • @initdef6773
    @initdef6773 ปีที่แล้ว +3

    Hi from Brazil, man, I've been watching your videos for a while and I always learn something new, you're rock! 🔥🔥

  • @oKanekei
    @oKanekei 6 หลายเดือนก่อน +1

    thank you so much! i was working for like 40 minutes to get a health bar working and this fixed it

  • @artcadedev
    @artcadedev ปีที่แล้ว

    I love your style dude, subscribed

  • @minoroyale1226
    @minoroyale1226 ปีที่แล้ว +2

    loved your concise explanation

  • @SkyFly19853
    @SkyFly19853 ปีที่แล้ว +5

    Very clear explanation.

  • @holy_roman_emperor01
    @holy_roman_emperor01 ปีที่แล้ว +1

    Thanks for this. Its running

  • @takeaginshxt
    @takeaginshxt 8 หลายเดือนก่อน +1

    A great project to begin to with HTML CSS and JS also (even though it's in Python)

  • @prateek5497
    @prateek5497 ปีที่แล้ว +2

    Simplest explanation possibly. ❤

  • @Karou571
    @Karou571 ปีที่แล้ว +5

    how would i do it for a Platformer game.Should make a code so that when i fall to the ground i lose health ?

    • @CodingWithRuss
      @CodingWithRuss  ปีที่แล้ว +1

      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.

  • @AyodejiAdedayoAdeosun
    @AyodejiAdedayoAdeosun 3 หลายเดือนก่อน

    cool video)

  • @Orzech97
    @Orzech97 ปีที่แล้ว +1

    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?

    • @CodingWithRuss
      @CodingWithRuss  ปีที่แล้ว +2

      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

    • @Orzech97
      @Orzech97 ปีที่แล้ว

      @@CodingWithRuss thank you Russ

  • @shalevforfor5550
    @shalevforfor5550 5 หลายเดือนก่อน

    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

  • @toosuper5828
    @toosuper5828 6 วันที่ผ่านมา

    what IDE are u using?

  • @aaronjayanmathew6745
    @aaronjayanmathew6745 ปีที่แล้ว +2

    super

  • @ttrimnor
    @ttrimnor ปีที่แล้ว +1

    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.

    • @CodingWithRuss
      @CodingWithRuss  ปีที่แล้ว

      Hello, I use Sublime text editor

    • @ttrimnor
      @ttrimnor ปีที่แล้ว

      @@CodingWithRuss Tank you

  • @ARIADNARB
    @ARIADNARB ปีที่แล้ว

    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?

    • @CodingWithRuss
      @CodingWithRuss  ปีที่แล้ว

      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

  • @mysz705
    @mysz705 11 หลายเดือนก่อน +1

    nice, danke

  • @user-hn5iq1oh2t
    @user-hn5iq1oh2t 9 หลายเดือนก่อน

    Bro you always help us but why don't you provide this program on the message section.😂

  • @echikai1236
    @echikai1236 11 หลายเดือนก่อน

    idk what is a pygame, but this can work in renpy games?

    • @CodingWithRuss
      @CodingWithRuss  11 หลายเดือนก่อน

      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

  • @jothamstephens104
    @jothamstephens104 10 หลายเดือนก่อน

    What to do if on line 27 HealthBar takes no arguments.

  • @igribeiro_
    @igribeiro_ 5 หลายเดือนก่อน

    and with a circle? i want to do a health bar like diablo 4.

  • @PpPp-tl5li
    @PpPp-tl5li หลายเดือนก่อน +1

    I want you to be my coding teacher pls give my your number

  • @artcadedev
    @artcadedev ปีที่แล้ว +1

    I love your style dude, subscribed