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

Поділитися
Вставка
  • Опубліковано 17 вер 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)

  • @SkyFly19853
    @SkyFly19853 2 роки тому +3

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

  • @ghazalareeba126
    @ghazalareeba126 Рік тому +2

    Just what I needed ❤

  • @coderunner743
    @coderunner743 2 роки тому +1

    Super explanation and awesome effect

  • @floridaadventurediving144
    @floridaadventurediving144 Рік тому +1

    Great tutorial Russ!

  • @plexus2000
    @plexus2000 2 роки тому +1

    Oh that looks great

  • @idiedlastmonth
    @idiedlastmonth Рік тому +1

    Absolutely wonderful!

  • @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 :)

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

    Elegant thanks for sharing

  • @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

  • @DineshVaidyaOfficial
    @DineshVaidyaOfficial 2 роки тому

    Really Awesome. Thank You very much...

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

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

  • @SorachiEte-r5m
    @SorachiEte-r5m 10 місяців тому

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

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

    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  2 місяці тому

      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 2 місяці тому

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

  • @xavierbourguignon37220
    @xavierbourguignon37220 10 місяців тому

    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  10 місяців тому

      To achieve that, you can combine the parallax logic with the endless scrolling logic from this video: ua-cam.com/video/ARt6DLP38-Y/v-deo.html

    • @frazomania
      @frazomania 5 місяців тому +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: ua-cam.com/video/ARt6DLP38-Y/v-deo.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.

  • @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: ua-cam.com/video/ARt6DLP38-Y/v-deo.html

  • @anameter4715
    @anameter4715 2 роки тому

    Hi. Do you have a snake game in pygame?

  • @walti3202
    @walti3202 Рік тому

    peak

  • @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: ua-cam.com/video/ARt6DLP38-Y/v-deo.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

  • @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?