Introduction:
“Show you the stars
Good?” “Good”
This sentence is really special romantic, starry sky, is you, the rest of my life is you, is you ~
All the gloom is left to the past
Since I met you, the winter is over and the stars are bright
Through the ages, taking you to see the stars has been the representative of romance.
♥♥ Do you feel like time has been wasted and life has been betrayed? Has has
Take your date to the stars sometime! He/she will be happy and you will forget your troubles.
Na ~ today xiaobian take you to see the stars, to a romantic starry journey!
The body of the
(1) All over the Sky Window Settings.
Def main(self): # 1. Select Pygame.display. Set_caption (" Babel ") # 2. Self.screen.fill ((0, 0, 0)) "for I in range(0, 100): self.screen.fill((0, 0, 0))" for I in range(0, 100): R = random.randint(0, 255) G = random.randint(0, 255) B = random.randint(0, 255) self.screen.fill((R, G, B)) ''' # 5. Self.action () # 6. Draw self.paint() # 7. Pygame.time.delay (10) # 3. Refresh the screen pygame.display.update()Copy the code
(2) Draw graphs.
def paint(self): # draw circle # screen --> where to draw # (255, 255, 0) --> Color value # (100, 100) --> circle center point # 50 --> circle radius # 0 --> Circle is filled with 0 fill other numbers: Pygame.draw. Circle (self.screen,(255, 255, 0),(100,100), 50, Pygame.draw. Circle (self.screen,(0, 0, 0),(80,80), 50, 0) # aline(self.screen,(255, 255, 0) # aline(self.screen,(255, 255, 0) 0),(300,300),(200,200)) # set the font ft = pygame.font. Blit (wd, (100,100)) for I in range(0, 100): self.screen.blit(wd, (100,100)) for I in range(0, 100): R = random.randint(0, 255) G = random.randint(0, 255) B = random.randint(0, 255) wd = ft. Render ("★", True, (R,G,B)) self.screen.blit(wd, (self.xx[i], self.yy[i]))Copy the code
(3) The movement of stars, cycle.
Def action(self): if event == pygame.event.get(): if event == pygame.quit: Self. Xx [I] += 1 self. Xx [I] += 1 self. self.xx[i] = 0 if self.yy[i] > 600: self.yy[i] = 0Copy the code
Effect:
Here is a screenshot of the static, in fact, the code effect is the star has been shining, has been moving down to the right replacement oh!
conclusion
Take us to see the stars ~
If you need a new installation package activation code, complete project + source notes, and more Python materials
Source code base: # private xiaobian 06# can be free to receive this article complete code.
Production is not easy, remember one key three even oh!!