• python pygame黑客帝国的简单实现


    #coding=utf-8
    import pygame
    import random
    class gameSprite(pygame.sprite.Sprite):
     def __init__(self, image_name, speed=1):
      super().__init__()
      
      
      font = pygame.font.SysFont('Consolas',40)
      rtext = font.render(bytes(image_name, encoding='utf-8'), False, (random.randint(1, 254), random.randint(0, 255), random.randint(0, 255)))
      self.image = rtext
      self.speed = speed
      self.rect  = self.image.get_rect()
     def update(self, *args):
      self.rect.y += self.speed
     
     def setSpeed(self, speed):
      self.speed = speed
    显示字符类
    #coding=utf-8
    import pygame
    import random
    from plane_sprites import *
    pygame.init()
    clock = pygame.time.Clock()
    screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN)
    
    listSprite = []
    for nIndex in range(1000):
     
     spriteTemp = gameSprite(chr(random.randint(48, 122)),random.randint(5, 100))
     spriteTemp.rect.x = random.randint(0, 1920)
     listSprite.append(spriteTemp)
     
    char_group = pygame.sprite.Group(listSprite)
    while True:
     for event in pygame.event.get():
       if event.type == pygame.QUIT:
        pygame.quit()
       if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_ESCAPE:
         pygame.quit()
         
     
      
     for nIndex in range(1000):
      spriteTemp = listSprite[nIndex]
      if spriteTemp.rect.y > 1080 :
       spriteTemp.rect.x = random.randint(0, 1920)
       spriteTemp.rect.y = 0
       spriteTemp.setSpeed(random.randint(5, 100))
       
     screen.fill((0, 0, 0))
     
     char_group.update()
     
     char_group.draw(screen)
     
     pygame.display.update()
     
     clock.tick(60)
    循环主函数

     

  • 相关阅读:
    14.2.3 InnoDB Redo Log
    14.2.3 InnoDB Redo Log
    14.2.2 InnoDB Multi-Versioning InnoDB 多版本
    mysql union ,UNION RESULT
    mysql union ,UNION RESULT
    mysql 查询优化案例
    视图上无法创建索引
    视图上无法创建索引
    /etc/security/limits.conf 设置
    14.2.1 MySQL and the ACID Model
  • 原文地址:https://www.cnblogs.com/anyechuxue/p/11263104.html
Copyright © 2020-2023  润新知