PyGame Beginner Tutorial in Python - Infinite Scrolling Background

Поделиться
HTML-код
  • Опубликовано: 6 окт 2024
  • In this video I will explain how to easily create an endless scrolling background in PyGame, which you can use in a sidescroller style game.
    I am going to explain how to use one background image to create an infinite scrolling 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...

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

  • @nazr763
    @nazr763 Год назад +22

    I am Japanese. There are not many people in Japan who are uploading videos on making games in python, so this video is very helpful. Thanks a lot for your clear and detailed explanations!

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

    Good to see new content again. You do have some of the best python tutorials out here. Thanks!

  • @GamingGuruImMortaL
    @GamingGuruImMortaL 2 года назад +6

    Finally pygame content is back!🤣🤣
    Bro you make one of the best pygame tutorials, please continue to do so in future.

  • @Dexjet
    @Dexjet 2 года назад +6

    Exceptional Tutorial as always. Thanks so much.

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

    YES great to see your back i did all of the platformer

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

    Wow! nice to see you back sir! Also Liked!!

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

    Nice to see you again !!! i try to make smoothless the scroll downsizing the fps, but with no result ...

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

      Thanks! Yes I had this problem as well, and when I looked into it online it seems to be one of the limitations of pygame. Normally in the game you would have more things on the screen so the background won't be as noticeable, but when it is the only thing on the screen it does look like it is a little jittery.

  • @ElaineFlorMS
    @ElaineFlorMS 2 года назад +4

    Thanks so much for your tutorials. They are helping me a lot.
    Can you please maybe teach how to do a main menu with two different backgrounds? For example 1 bg in menu with buttons play, credits and exit and when the credits button been clicked another bg appears with the button to back to main menu. It will help me a lot with my game to college 😁

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

      Glad to hear the tutorials are helping.
      I have a tutorial in my shooter game which has a main menu. It has play and exit, so you will need to add the credits option yourself but the tutorial explains the logic for the menu so you will be able to figure out how to add more options: ruclips.net/video/wWLDUb71mFo/видео.html

  • @CharlieAngel-vy5zi
    @CharlieAngel-vy5zi Месяц назад +1

    Thanks very useful I am searching how to do parallax now

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

    Next video, i hope you will do st about effect and shader

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

    bro you are the best 😢 love from india can you me playlist on pythone 3d games ❤

  • @BRO...21
    @BRO...21 2 года назад +1

    Thank you very much, I like it and this is the best tutorial i have

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

    Thanks for the video helped me a lot!

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

    How do I make the background move with my player?

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

    This helped me a lot
    I'll surely send you the Game I'm working one ❤️

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

    Thanks Russ! Thanks

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

      You're welcome!

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

      @@CodingWithRuss am learning so fast i need to slow down!

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

    Russ, can you make a tutorial on a background which follows the player?

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

      look at the parallax background tutorial, that shows the background moving with controls of the user

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

    Thanks so much, love the content.
    I've figured how to do this vertically but would it be possible to do it in the opposite direction

    • @satyre5844
      @satyre5844 9 месяцев назад

      how did you make it vertical?

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

    Thank you know I can tell my father how to create a scrolling background

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

    thank you so much!

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

    How can you change the Y coordinate of each individual image so each one is at a different height

  • @JaJ-w3b
    @JaJ-w3b Год назад +1

    I know you can scroll the opposite way by scroll += but it doesn't load the new image near as smoothly on the left, any tips? Thanks

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

    nice to see you again are you okay tho? your voice seems different stay healthy :D

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

      Yea I'm all good, thanks! I don't know why it sounded different...I must be out of practice :)

  • @khaledhaouam2182
    @khaledhaouam2182 27 дней назад

    thanks from Algeria

  • @Nightmare-dd4bp
    @Nightmare-dd4bp 2 года назад +2

    Thanks

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

    Wow thanks alot for this awesome tutorial

  • @AdylKadyraliev
    @AdylKadyraliev 11 месяцев назад +1

    Hello quick question, if i need to do it for clouds for example like in stardew valley menu interface. Can i use only 1 image with 5-6 clouds and move it like in the video but ofcourse slowly. Ty for the video

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

      Hello. Yes sure that would work as well and you could even have different clouds move at different speeds if you wanted to.

  • @KalifSSJ
    @KalifSSJ 8 месяцев назад

    I from Polan
    bro Zajebista Robota🙂

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

    or use modulus operator for the position

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

    is there a way or tut how to add ground on this scrolling bcgr that ground would scroll slower , or how to implement 2 or 3 different scrolling surface or assets?

    • @paleo_ferns
      @paleo_ferns 10 месяцев назад

      did you figure out a solution?

    • @krentor1
      @krentor1 День назад

      I lost my code all ness gonna start all over🎉thanks

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

    Any chance this is doable with height as well as width?

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

      Yea it can be applied vertically in the same way

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

    hello, how do you make the screen scroll gradually faster

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

      Instead of scroll -= 5 you could do something like scroll -= scroll_speed. Then you can gradually increase the scroll_speed variable using a timer or a counter so your scrolling will be sped up

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

      @@CodingWithRuss thank you!

  • @Floffffff
    @Floffffff 9 месяцев назад

    I am trying to make my program working but the -= operator isn't doing anything. How can I fix?

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

    which programm do u use?

  • @ganth881
    @ganth881 10 месяцев назад

    Hi! Apparently I am trying to combine this endless scrolling with your parallax scrolling. However I can't seem to get it work properly, it fails to blit the background layer in on time and keeps glitching

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

    It worked

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

    how can i add words, bgm or other img on it? the bg still looping but the words and img on it are still

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

    trying to do this to get it to scroll vertically but it jus scrolls horizontally...

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

      To scroll vertically you would need to change it to move along the y axis instead of the x axis

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

    Understood complete

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

    After writing entire code on VSCODE it is showing fault about bg = pygame.image.load(" BG.png").convert()
    Please Sir if possible solve my problem.....Thanks a lot.

  • @scratchasmr-yash4958
    @scratchasmr-yash4958 Год назад

    It is only scrolling perfectly towards right but not towards left 🤔

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

      It will scroll left as well but you have to adjust the code so the background images are drawn on the left otherwise you will get a smudging looking effect

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

    hi, thank you for you for this tutorial. I attempted to implement it for Y-axis scrolling, but it only functions in one direction (scrolling upwards). However, when I tried it for the opposite direction, it appears as if the image is being dragged (similar to what happens at the 9:13 mark in the video). Do you have any advice to offer that could assist me?

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

      The problem is likely to be the same as what I demonstrated in the video. It's just happening on the vertical axis instead of horizontal. It sounds like the second image isn't coming in behind the first and you end up with this dragging effect. Check that you're passing the right coordinates for the second image to come in at the right location.

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

      thanks for answer. it was just a " - " what I needed hahaha xD

    • @AxXis--
      @AxXis-- 4 месяца назад

      @@yurabohm2561 Where? haha

  • @Floffffff
    @Floffffff 9 месяцев назад

    What if i want to make it scroll vertically? Should I just swap width with height?

    • @CodingWithRuss
      @CodingWithRuss  9 месяцев назад +1

      Yea pretty much. Same logic but on the y axis instead

    • @Floffffff
      @Floffffff 9 месяцев назад

      @@CodingWithRuss perfect, thank you so much

    • @AxXis--
      @AxXis-- 4 месяца назад

      @@Floffffff How did you do that?

  • @lsmaelvascon.
    @lsmaelvascon. 9 месяцев назад

    Your videos are great, could you leave your codes written here, hugs.

  • @shafiullahptm909
    @shafiullahptm909 4 месяца назад

    sir sir pls tell me why the buttonmodule is not downloading using pip sir pls tell me sir i have less time pls pls sir a humble request from me

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

    Is it possible to somehow impement it in def function ?

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

      Yes, sure. You could put it into a function or even a class if you like.

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

    Cool😂

  • @h3l_l
    @h3l_l 4 месяца назад +1

    good

    • @CodingWithRuss
      @CodingWithRuss  4 месяца назад +1

      thanks

    • @h3l_l
      @h3l_l 4 месяца назад

      @@CodingWithRuss hi man you've helped me a lot i didn't expect you to see my comment really thank you for your effort really appreciate your content

  • @dongiannisiliadis9018
    @dongiannisiliadis9018 8 месяцев назад

    Hold that like

  • @official_Liume
    @official_Liume 10 месяцев назад

    9:24

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

    BAD tutorial, now I perfectly understand why you have a few likes. IT says Beginner tutorial but then you just assume we already know what frames rates and clocks are and what they do. Really bad....

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

      that's basic knowledge of computers buddy. those arent necessarily coding terms.

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

      if you only know the basics you are a beginner so if you dont know it you just nothing not even a beginner