PyGame Beginner Tutorial in Python - 3D Background Effect with Parallax Scrolling

Поделиться
HTML-код
  • Опубликовано: 6 окт 2024
  • In this video I will explain how to use parallax background to create a 3D background effect.
    I am going to show how to setup the different layers correctly and how to control their individual scroll speeds to give the impression of depth to the background.
    Code and assets on github:
    github.com/rus...
    Check out my other PyGame tutorials:
    Space Invaders coding tutorial: • Pygame Space Invaders ...
    Flappy Bird coding tutorial: • PyGame Flappy Bird Beg...
    Credits for background images:
    jesse-m.itch.i...

Комментарии • 52

  • @2MSTennis
    @2MSTennis 2 года назад +16

    I think this would be really cool for a turn based rpg. Have the character enter the instance and when a mob approaches it enters a battle sequence!! Cheers!

  • @drewnash132
    @drewnash132 Год назад +6

    Thanks a lot. Amazing tutorial.
    I am a new in pygame, but not in python. So I implemented the Parallax logic to my code and it looks terrific.
    I decreased scroll step from 5 to 0.8 and increased x range for the endless effect.
    P.S. found nice background images on craftpix.

  • @ToujoursIris
    @ToujoursIris 2 года назад +8

    A nice way for creating a 3D effect. Was a bit hard for me to do it myself, but I followed the tutorial and got the required output. (still waiting for the discord server)

    • @CodingWithRuss
      @CodingWithRuss  2 года назад

      Thanks! And good to see you again :)

    • @ToujoursIris
      @ToujoursIris 2 года назад

      @@CodingWithRuss Yea, we have summer break now so I can watch your videos :)

    • @atharvkumar2564
      @atharvkumar2564 2 года назад

      Yeah

    • @xaviergo9645
      @xaviergo9645 Год назад

      where can i copy the code?

  • @SkyFly19853
    @SkyFly19853 2 года назад +3

    Wow...
    Python has so much potential...

  • @ghazalareeba126
    @ghazalareeba126 Год назад +2

    Just what I needed ❤

  • @floridaadventurediving144
    @floridaadventurediving144 Год назад +1

    Great tutorial Russ!

  • @UnleashedEntomber
    @UnleashedEntomber 2 года назад +1

    I hope you will be back soon, you are making great staff.

    • @CodingWithRuss
      @CodingWithRuss  2 года назад +2

      I've been working on a new game, it should be ready soon :)

  • @ferasalatrash7372
    @ferasalatrash7372 2 года назад +1

    I found your channel recently and your content is amazing!
    Could you please do a game with full screen so we can learn how to handle that every user might have a different screen size 😅

    • @CodingWithRuss
      @CodingWithRuss  2 года назад

      Thanks! Glad you like it. Yes that's something I'd like to look at because I've noticed sometimes the games I make are too big or too small on other people's screens

  • @coderunner743
    @coderunner743 2 года назад +1

    Super explanation and awesome effect

  • @plexus2000
    @plexus2000 2 года назад +1

    Oh that looks great

  • @fbushphone
    @fbushphone 3 месяца назад +1

    Elegant thanks for sharing

  • @DineshVaidyaOfficial
    @DineshVaidyaOfficial 2 года назад

    Really Awesome. Thank You very much...

  • @SorachiEte-r5m
    @SorachiEte-r5m 11 месяцев назад

    Actually I tried to apply the endless scrolling with this parallex logic, but its not continous as compared to a single image

  • @alexany4619
    @alexany4619 7 месяцев назад

    Hi, how would you locate and move sprites behind the first layer?

  • @uthmanjimmy1377
    @uthmanjimmy1377 3 месяца назад

    I notice a bit of jitter while scrolling. Have you found a solution for this? Perhaps this approach might not be the best way of doing parallax effects?

    • @CodingWithRuss
      @CodingWithRuss  3 месяца назад

      I've noticed jittering in a few of my pygame projects where I have continuously moving images and spent a while trying to troubleshoot them but could never figure it out. Not really sure what causes it.

    • @uthmanjimmy1377
      @uthmanjimmy1377 3 месяца назад

      @@CodingWithRuss Good to know! Thanks for your speedy reply!

  • @xavierbourguignon37220
    @xavierbourguignon37220 11 месяцев назад

    How would one do an endless scroller? Currently when we hit the last image in the list, we get nothing else. I guess there is a way to wrap these images around

    • @CodingWithRuss
      @CodingWithRuss  11 месяцев назад

      To achieve that, you can combine the parallax logic with the endless scrolling logic from this video: ruclips.net/video/ARt6DLP38-Y/видео.html

    • @frazomania
      @frazomania 6 месяцев назад +1

      @@CodingWithRuss wow great so helpful, do you not understand that it has a delay like it doesnt work like that

  • @AG06_GabryGunner
    @AG06_GabryGunner Год назад

    i see that it draws 5 times, i do wonder if it can loop infinately
    for x in range(5):

    • @CodingWithRuss
      @CodingWithRuss  Год назад

      Yes it would be possible to do. I have another video where I explain how to create an infinite scrolling background so the method in there can be combined with this one to give an infinitely scrolling parallax background. This is the other video: ruclips.net/video/ARt6DLP38-Y/видео.html

  • @anameter4715
    @anameter4715 2 года назад

    Hi. Do you have a snake game in pygame?

  • @onr28
    @onr28 Год назад +1

    Is there a way to make this infinite?

    • @CodingWithRuss
      @CodingWithRuss  Год назад

      Yes, you can combine it with this video to create an infinite parallax background: ruclips.net/video/ARt6DLP38-Y/видео.html

  • @ghguyrur7
    @ghguyrur7 Год назад

    So I make this, do I also code my game in here? I’m still not sure if I’m supposed to use one box of code for my whole game or if I’m breaking it into parts

    • @CodingWithRuss
      @CodingWithRuss  Год назад +1

      You can split your project into different files and this background effect can be one of those parts. You can then import it into your main game and use it there.

    • @ghguyrur7
      @ghguyrur7 Год назад

      @@CodingWithRussyou’re amazing and you’ve me helped so much

  • @evagok3698
    @evagok3698 Год назад

    Completed!
    jehhueeheyy!

    • @CodingWithRuss
      @CodingWithRuss  Год назад +1

      Wow you're getting through them quick. I will need to make more :)

    • @evagok3698
      @evagok3698 Год назад +1

      @@CodingWithRuss I will be doing your all videos about python because I think they are really nice and you are very good at sharing your knowledge. Thanks a lot. Ohh also after making that platform game some people tried it and 6 years old a child like it very much and I felt super proud. I just followed all your tutorials and I had change to write the code and I learn a bit of course. Thank you for me feeling good. I really appreciate that.

  • @half-eye3006
    @half-eye3006 Год назад

    you guys know how to make the image in a infinit loop.

    • @CodingWithRuss
      @CodingWithRuss  Год назад

      This video shows how to make an infinite background, so you can apply the same logic here by modifying the code a little bit: ruclips.net/video/ARt6DLP38-Y/видео.html

    • @half-eye3006
      @half-eye3006 Год назад

      @@CodingWithRuss i managed to make it, thank you brother

    • @CodingWithRuss
      @CodingWithRuss  Год назад

      @@half-eye3006 Nice one

    • @shadowace159
      @shadowace159 Год назад

      @@half-eye3006 Hello, I'm trying to make the same thing. Did you have to make a scroll variable for each background? Or is there a less redundant way to do things?

    • @half-eye3006
      @half-eye3006 Год назад

      @@shadowace159 scroll variable for each background i did that

  • @walti3202
    @walti3202 Год назад

    peak

  • @idiedlastmonth
    @idiedlastmonth Год назад +1

    Absolutely wonderful!

  • @Doubletrouble192
    @Doubletrouble192 2 года назад

    Hello! I am new to programming and am attempting to code a something in Pygame, however I am struggling a lot. Would it be possible if I could contact you somehow and ask for some help?