Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize 100-tier games with Pygame

Shulou Source: shulou.com Published: 2022-06-03 10:00:35 09月21日 Update

< 0 or rect.left + SIDE >

= SCREEN_WIDTH: return False for ba in self.barrier: if rect.colliderect (ba.rect): return False self.body = rect return True def get_score (self) Ba): if self.body.top > ba.rect.top and not ba.score: self.score + = 1 ba.score = True def to_hell (self): self.body.top + = 2 for ba in self.barrier: if not self.body.colliderect (ba.rect): self.get_score (ba) Continue if ba.type = = DEADLY: self.show_end () return self.body.top = ba.rect.top-SIDE-2 if ba.type = = FRAGILE: ba.frag_touch = True elif ba.type = = BELT_LEFT or ba.type = = BELT_RIGHT: # self.body.left + = ba.belt_dire self.move_man (ba.belt_dire) break top = self.body.top if top

< 0 or top+SIDE >

= SCREEN_HEIGHT: self.show_end () def create_barrier (self): solid = list (filter (lambda ba: ba.type = = SOLID, self.barrier)) if len (solid)

< 1: self.barrier.append(Barrier(self.screen, SOLID)) else: self.barrier.append(Barrier(self.screen)) self.last = randint(3, 5) * SIDE def update(self, current_time): if self.end or self.is_pause: return self.last -= 1 if self.last == 0: self.create_barrier() for ba in self.barrier: if not ba.rise(): if ba.type == FRAGILE and ba.rect.top >

0: self.score + = 1 self.barrier.remove (ba) self.move_man (self.dire) self.move_man (self.dire) self.to_hell () def draw (self, current_time, end=False): if self.end or self.is_pause: return self.screen.fill (0x000000) self.draw_score ((0x3c 0x3c, 0x3c)) for ba in self.barrier: ba.draw () if not end: self.screen.fill (COLOR [BODY], self.body) else: self.screen.fill (COLOR [DEADLY], self.body) pygame.display.update () if _ _ name__ = ='_ main__': hell = Hell ("one hundred layers", (SCREEN_WIDTH) SCREEN_HEIGHT)) hell.run ()

The effect picture is as follows:

The above is all the content of the article "how to achieve 100-tier games in Pygame". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content articles learning help children effects effect drawings time easy to understand more organization text knowledge editing industry information information channels channels two parts research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Linux vpn Redmi Docker