![]() Scores = font_small.render(str(SCORE), True, BLACK)ĭISPLAYSURF.blit(entity.image, entity. Self.bgimage = ('AnimatedStreet.png')ĭISPLAYSURF.blit(self.bgimage, (self.bgX1, self.bgY1))ĭISPLAYSURF.blit(self.bgimage, (self.bgX2, self.bgY2)) ![]() Self.rect = _rect(center = (random.randint(40,SCREEN_WIDTH-40) Game_over = font.render("Game Over", True, BLACK)ĭISPLAYSURF = _mode((400,600)) If you examine each line of the code carefully, you’ll understand how background scrolling works.Ī horizontal scrolling version of our code is available at the very end of this article.įont = ("Verdana", 60)įont_small = ("Verdana", 20) If this doesn’t make sense, take a good long look at the code we’ll be showing below. This way, if the first background has been moved half way down, the other background which will be right behind it and will cover that 50% gap. The solution that our approach takes is to create two copies of the background, with no overlap. ![]() However, the problem is that moving the background 10 pixels in any direction will result in a gap of 10 pixels in that very spot. However, the problem is that moving the background 10 pixels in any direction will result in a gap of 10 pixels in that very spot. The common principle behind background scrolling is simply to move the background in the direction you want it to move. The common principle behind background scrolling is simply to move the background in the direction you want it to move. It easily bypasses many common issues that arise, while also having the ability to scroll vertically as well as horizontally (with a few tweaks). The method we’ll be following is what I consider to be one of the best. Now obviously there are many different methods that can be used to create the scrolling background effect in Pygame. The concepts behind scrolling backgrounds
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |