OOP with Pygame - Object Oriented Programming Exercise

Поділитися
Вставка
  • Опубліковано 20 січ 2025

КОМЕНТАРІ • 94

  • @Qlii256
    @Qlii256 8 місяців тому +8

    You are declaring instance attributes outside of the __init__ method, which is not ideal. You can just create them with a value of None, and then set them in the draw method. If you never call the draw method, that means the attributes will never be initialized (set) and thus, do not exist.

    • @PythonSimplified
      @PythonSimplified  8 місяців тому +8

      100%!!! Thank you for the awesome tip! 😀😀😀

    • @Qlii256
      @Qlii256 8 місяців тому +2

      @@PythonSimplified Python does not really care however and lets you do all of these things. You can declare variables anywhere you want, without specifying a type even. But it's very prone to errors. I've had to deal with something like this myself where it took me a while until I figured out why my attribute was not declared even though I did declare it. It was not in the __init__ method...

    • @leahnjr
      @leahnjr 7 місяців тому

      I would also create getter methods for any property you want to be public to the consumer of the class. This is also not a place where Python excels because it doesn't have access modifiers and pretty much everything is public. But it is customary to prefix an underscore to show a property or method should be private.

  • @tangled55
    @tangled55 14 днів тому

    You are seriously one of the greatest teachers I've ever seen for programming languages. Thank you so much.

  • @awelege
    @awelege 7 місяців тому +4

    Thank you so much. That replacing "self" with "vehicle" really cleared a lot of things

  • @VinnyRN07
    @VinnyRN07 8 місяців тому +7

    Visuals are very important when learning, for a lot of people. This was a great way to show off classes and although I have been using Python a while, I feel a lot more comfortable with some things I did not know before (like the super required in inheritance!) Fantastic video!

    • @PythonSimplified
      @PythonSimplified  8 місяців тому +7

      Thank you so much Vinny!!! So happy you liked this tutorial, and I agree with you 100%! 😀
      Initially I was planning to start this exercise in a fully functional car game. The red car image would have been the enemy vehicle, and we would have implemented changes in speed and associating different audio files with different vehicle classes. I realized eventually that it's a bit too much so I decided to keep it simple. (We might still do it in a live stream though! 😉)
      Cheers! and thanks for the comment! :)

    • @Yachid
      @Yachid 8 місяців тому +1

      Agrē! "Visuals are very important when learning", &
      'PythonSimplified' cŕtainLy bring'z the "visuals"
      w/hŕ evŕ rādiant smile

    • @VinnyRN07
      @VinnyRN07 8 місяців тому +1

      @@PythonSimplified Cannot wait to see what you create next then!

  • @kjlw99
    @kjlw99 8 місяців тому +2

    Thank you! You're a great explainer! You seem like you test your tutorials ahead, so you don't get tripped up on small details like many do when doing tutorials.

  • @MichaelSwartout
    @MichaelSwartout 7 місяців тому +1

    You are such a perfect teacher. So easy to understand you. Even though I am more of a Java, c and c++ developer.

  • @papatangovictor
    @papatangovictor 8 місяців тому +3

    Pure teaching talent.

  • @paulocoelho558
    @paulocoelho558 8 місяців тому +1

    Good morning! I'm enjoying learning from such a skilled little snake charmer. Please feel free to keep sending those homework assignments my way - practice makes python! Thank you Mariya! 😊😃😛😉

  • @ivansmirnov9589
    @ivansmirnov9589 8 місяців тому

    Спасибо, Маша! Отлично обхяснила. Даже я что-то понял из ООП. Пожалуй вернусь к этому упражнению после прохождения курса по ООП на степике!

  • @mecrayavcin
    @mecrayavcin 7 місяців тому +1

    Woow best OOP lesson that i have ever seen. 🥰

  • @hodoros7255
    @hodoros7255 8 місяців тому

    Thank you for continued content. Would love a video that goes over how how to self-learn new python modules! Ideas would include how to get used to reading python module documentation, what to google, how to find examples etc.., how to start playing with a new module etc..
    Hope you respond whether you think this is a good or bad idea/or any thoughts in general. Thanks!

  • @lyzersports4335
    @lyzersports4335 7 місяців тому +2

    Got yourself a new subscriber.

  • @AwesomeCameras
    @AwesomeCameras 8 місяців тому +2

    This is great! Going to rewatch later when I get on my computer...

    • @PythonSimplified
      @PythonSimplified  8 місяців тому

      I hope you have lots of fun and this video will give you a bunch of cool ideas for personal projects! 😀

  • @AirzGamingTTV
    @AirzGamingTTV 8 місяців тому +1

    I really love your content- you have a gift for teaching thank you for sharing

  • @SilentGamingDad
    @SilentGamingDad 8 місяців тому

    Drop the mic girl , this content is gold , thanks !

  • @felipegaeteroman
    @felipegaeteroman 8 місяців тому

    Thank you Mariya for another great content!!!

  • @mrpro7737
    @mrpro7737 8 місяців тому

    i miss you so much ❤️
    please stay active 🙏 we love your content 😍

  • @xEndless11
    @xEndless11 8 місяців тому

    In pygame or python ursina or cave engine it is more effective to write the classes like "class MY_CLASS(WHAT_MY_IS):". The reason: Game engines like Ursina, PyGame or Cave call predefined instances such as “Entity”, “Text”, “Animation” or simple “Scene”. This means that if you write larger code, sooner or later type problems will arise when recognizing and reading the instances if this is not stated directly. At the same time, these are able to use the update definition with the delta time and update themselves. If you don't specify anything there, the update function will only work to a limited extent there or at least only if you integrate it somewhere else, which will end up eating up a lot of performance and Python is a bit slower in gaming anyway. It would also make the code easier to understand and read if you use variables or values ​​that are as short as possible than the actual string or value itself. Example: plc_t='police_car_texture0.png' instead of police_car_texture='police_car_texture0.png'.

  • @cram000
    @cram000 7 місяців тому

    I think I found the channel I'll be using to research Python 👀suddenly it's far easier to pay attention and learn

  • @tokenizedgameplay
    @tokenizedgameplay 8 місяців тому

    Thanks Maria, i think i have to go over again.
    Keep it up🙂

  • @edupgarciati
    @edupgarciati 8 місяців тому

    I personally couldn't have made it a better explanation Maryia

  • @glenneric1
    @glenneric1 8 місяців тому

    Thank you for the amazing content! Love's me some pygame.

  • @WMcLovin
    @WMcLovin 6 місяців тому +1

    you make learning fun

  • @raphisteve
    @raphisteve 8 місяців тому +1

    Hey dear!
    I just wanted to ask if you could provide us with your opinion about the new function of Windows 11
    It is called "Recall" or something else. It screenshots your screen every 5 seconds...
    Have a great time!

    • @PythonSimplified
      @PythonSimplified  8 місяців тому +3

      It's probably just another way for Bill Gates to spy on you 😉 hahaha
      But on a deeper level, I believe they try to model your computer usage and learn your behavior. If they collect enough data, they can estimate you next move quite accurately. They also know that most people will let them do so, because installing and maintaining Linux is complex for most individuals. If they had an "apples to apples" competition - they wouldn't do something that shady 🙃

  • @abQUINTON1
    @abQUINTON1 6 місяців тому

    Thanks for posting!

  • @AgaAga-of6ii
    @AgaAga-of6ii 8 місяців тому

    cool, but is there a simple way of making them not touch or cover each other?

  • @chrisray1567
    @chrisray1567 8 місяців тому +1

    You down with OOP? Yea, you inherit me!

  • @BikerBoyz7
    @BikerBoyz7 6 місяців тому

    Hi can you make a video for python selenium?

  • @milikest
    @milikest 8 місяців тому

    Thank you for such an informative video. But everyone is talking about OOP, I wish we could see a functional programming exercise. I wish you could talk about paradigms and create a functional programming tutorial. I don't want peace, I want trouble!

  • @amit12000
    @amit12000 8 місяців тому +1

    Waiting for great upcoming session

    • @PythonSimplified
      @PythonSimplified  8 місяців тому

      I hope you enjoyed it! (or will enjoy it! 😀)

    • @amit12000
      @amit12000 8 місяців тому

      Yea you always teach us exceptional thing in very simplified

  • @hamoudimaghoul3407
    @hamoudimaghoul3407 8 місяців тому

    helpful 10x Mariya. 😉. Let's rolllll

  • @PAOLOHAON
    @PAOLOHAON 8 місяців тому

    Nice intro music!

  • @TamilCoder.
    @TamilCoder. 8 місяців тому

    Can you explain about abstraction?

  • @shivamsahu4388
    @shivamsahu4388 8 місяців тому

    Great Video 🙂

  • @worc974
    @worc974 8 місяців тому

    thanks for the video!!

  • @СеменХеруимов
    @СеменХеруимов 8 місяців тому

    Спасибо за видео :)

  • @mehdismaeili3743
    @mehdismaeili3743 8 місяців тому

    Excellent .

  • @gunawanwibisono5084
    @gunawanwibisono5084 2 місяці тому +1

    I don't have money more for lesson python

  • @PakistanAnonymous
    @PakistanAnonymous 6 місяців тому +1

    ❤ 😍

  • @Sinke_100
    @Sinke_100 8 місяців тому +1

    Colour is brittish, cool 🙂

    • @PythonSimplified
      @PythonSimplified  8 місяців тому +2

      Yup! and also Canadian! 🍁🫎

    • @Sinke_100
      @Sinke_100 8 місяців тому

      @@PythonSimplified hm, I didn't acually know that Mariya

    • @cerealport2726
      @cerealport2726 8 місяців тому +1

      and Australian.

  • @takisbezaitis7741
    @takisbezaitis7741 8 місяців тому

    Hello from Greece!
    Thanks for the tutorial!! One question: is pygame worth it or is it outdated? What about Python Arcade or similar frameworks?
    Thanks again!

    • @sstfpv8651
      @sstfpv8651 8 місяців тому

      The latest version of pygame, called 'pygame-ce' for Community Edition is still being updated while the original pygame seems not so much anymore

    • @takisbezaitis7741
      @takisbezaitis7741 8 місяців тому

      @@sstfpv8651 Thank you!

    • @takisbezaitis7741
      @takisbezaitis7741 8 місяців тому

      @@sstfpv8651 Thank you!

  • @Rob-147
    @Rob-147 7 місяців тому

    LETS GO!!!

  • @john9908
    @john9908 2 місяці тому +1

    Omg that hair 🤤🤤🤤 single? Haha

  • @--AnonymousUser--
    @--AnonymousUser-- 7 місяців тому

    Simplification Pythonified!

  • @siddhartha5875
    @siddhartha5875 6 місяців тому

    Ohh .I wish somebody bothered to explain it to me as from where I could start the journey! Or the sequence it would save me so much time and frustration 😦😔
    UA-cam is bombarded with so many videos 😭

  • @treedigital346
    @treedigital346 7 місяців тому

    forgive me the only reason to subscribe this chanel and watching it your smile ,slang and your laugh not your coding

  • @prabhatadvait
    @prabhatadvait 2 місяці тому

    Thanks it was amazing ,love from india

  • @reef2005
    @reef2005 6 місяців тому

    The super function is redundant for most of the code.

  • @JafarH-ip5qh
    @JafarH-ip5qh 6 місяців тому

    🎉🎉

  • @СергейДружинин-н7ы
    @СергейДружинин-н7ы 2 місяці тому +1

    Isn't Object-Oriented Programming actually Class-Oriented?
    What do you think about that?

    • @PythonSimplified
      @PythonSimplified  2 місяці тому

      Classes create objects, so I don't think it really matters 🙂

  • @AliAkbarNemati-v5x
    @AliAkbarNemati-v5x 7 місяців тому +3

    She left Sublime Text 😢

  • @JessWLStuart
    @JessWLStuart 8 місяців тому

    Why do chicken coups only have two doors? Because if they had four doors, we'd have to call them chicken sedans!

  • @Serge-r4k
    @Serge-r4k 7 місяців тому

    ❤❤

  • @awelege
    @awelege 7 місяців тому

    4:30

  • @carsonjamesiv2512
    @carsonjamesiv2512 8 місяців тому

    😃👍🎉

  • @sstfpv8651
    @sstfpv8651 8 місяців тому

    I'd like to introduce you to the pygame.sprite.Sprite and .Group classes

  • @hassanal8321
    @hassanal8321 3 місяці тому

    Yay 😅

  • @jed6265
    @jed6265 6 місяців тому

    Truck and Police will call draw() twice

  • @absurdshortz
    @absurdshortz 6 місяців тому

    ma'am number please for studying purpose

  • @SaiSai-advertiser
    @SaiSai-advertiser 7 місяців тому

    I love you pretty and very clever girl😍

  • @vurmyr
    @vurmyr 8 місяців тому

    Composition > Inheritance

  • @Tobs_
    @Tobs_ 8 місяців тому +1

    stuck in work.. practicing OOP in real life.

    • @PythonSimplified
      @PythonSimplified  8 місяців тому +1

      Making tons of money while the rest of us slack off at home, wearing pajamas and watching UA-cam 😉

    • @Tobs_
      @Tobs_ 8 місяців тому

      @@PythonSimplified got 3 day weekend now so going to get some "happy" coding done in C ☺

  • @SaiSai-advertiser
    @SaiSai-advertiser 7 місяців тому

    pretty girl and you are very clever

  • @raja_uma1r
    @raja_uma1r 8 місяців тому +1

    Well python is good at functional programming but it sucks at OOP. Too much boilerplate and unnecessarily complex.

    • @PythonSimplified
      @PythonSimplified  8 місяців тому

      I personally find it much more intuitive than C++ and C#... I guess I'm not a big fan of Header files, declaring stuff and figuring out why the code won't compile if the info in .cpp and .h files don't match 🙃
      I think the only downside in the Python way, as mentioned by Badger in the live chat, is that Python private members are not really private. Other than that, I'm a happy camper 😀

    • @raja_uma1r
      @raja_uma1r 8 місяців тому +1

      @@PythonSimplified yeah, you may be right, everyone have their preference, I started my journey with Python and I used to love it, now I'm a Kotlin/Android developer and trust me I would never like to return to python.

    • @PythonSimplified
      @PythonSimplified  8 місяців тому

      Hey, at least it's not Java! 😅😅😅 hahaha
      My uncle has been in the Kotlin/Android sphere for years! It's a great choice of career! 😀

    • @raja_uma1r
      @raja_uma1r 8 місяців тому

      @@PythonSimplified well, kotlin is modern Java and it has replaced java in all manners. "Write once, run anywhere." was a slogan for Java but now It's the Kotlin era. Have you heard about Kotlin/Compose Multiplatform?

  • @cerealport2726
    @cerealport2726 8 місяців тому

    How did you know about my French girls....?

  • @Yachid
    @Yachid 6 місяців тому +1

    Hey Py~Lady!
    shout-Out fr~ @MI
    i jst watchD yr 'Next Wave' show
    (radiant & composed az ever )
    'With AI, Are Coding Jobs at Risk? ft. Python Simplified'
    i coMentD 2U there 2:
    Hiya 'Py Lady'! (Mariya Sha)

  • @_isDev
    @_isDev 7 місяців тому

    The word self is a reference to the instance (object) of a class, not to the class itself. The reserved word for this is class

  • @awelege
    @awelege 7 місяців тому +1

    Thank you so much. That replacing "self" with "vehicle" really cleared a lot of things

    • @PythonSimplified
      @PythonSimplified  7 місяців тому

      That's awesome! Super happy to help! 😀😀😀