Exemplo n.º 1
0
 def registering(self):
     Base.clearTime()
     while self.controller.state == self.controller.STATE_FIRST:
         events = pygame.event.get()
         for e in events:
             if e.type == pygame.QUIT:
                 self.close()
                 return
             if e.type == pygame.KEYDOWN:
                 if e.key == pygame.K_SPACE:
                     self.controller.startGame()
                     return
                 if e.key == pygame.K_ESCAPE:
                     self.close()
                     return
                 if e.key == pygame.K_F11:
                     self.fullScreen()
             if e.type == pygame.VIDEORESIZE:
                 if Con.FullScreen:  # 全屏不缩放
                     continue
                 if Con.ScreenSize[0] != e.size[0]:  # 横改变
                     width = e.size[0]
                     height = int(e.size[0] / Con.ScreenSizeRatio)
                 else:  # 纵改变
                     height = e.size[1]
                     width = int(e.size[1] * Con.ScreenSizeRatio)
                 size = max(width, Con.MinSize[0]), max(height, Con.MinSize[1])
                 self.resize(size, pygame.RESIZABLE)
         self.controller.holdConnection()
         self.flush()
         self.clock.tick(Con.FPS)
Exemplo n.º 2
0
 def __init__(self):
     Base.clearTime()
     Base.CurrentUserFacer = self
     self.clock = pygame.time.Clock()
     self.buttonColorGenerator = Anima.ButtonToggleColor(
         (Con.LocalButtonColor, Con.OnlineButtonColor),
         Con.ColorToggleTime
     )
     self.startSize = Con.ScreenSize
     self.fontSize = lambda: int(Base.CurrentScreen.get_width() / Con.FontRelation)  # 根据屏幕大小更改字体大小
     self.Font: pygame.font.Font = Base.getFont(Con.Font, self.fontSize())
     self.fontColor = Con.TextColor
     self.background = Con.BackGround
     self.ifOnline = False
     self.playerNum = 1
     self.min_enemy_num = Con.LeastEnemy  # 最小敌人数
     self.max_enemy_num = Con.MostEnemy  # 最大敌人数
     self.last_enemy_num = 0  # 可忽视
     self.settingKey = [pygame.K_LALT]
     self.startKey = [pygame.K_RETURN]
     self.refreshKey = [pygame.K_r]
     self.quitKey = [pygame.K_ESCAPE, pygame.K_q]
     self.fullKey = [pygame.K_F11]
     self.upPlayerKey = [pygame.K_UP]
     self.downPlayerKey = [pygame.K_DOWN]
     self.toggleOnlineKey = [pygame.K_SPACE]
     Con.ButtonSize = sum(Con.ScreenSize) // 2 // 6
     self.clickRect = pygame.Rect([0, 0, 0, 0])  # 点击开始游戏区域
     self.settingClickRect = pygame.Rect([0, 0, 0, 0])  # 点击设置区域
Exemplo n.º 3
0
 def __init__(self):
     Base.clearTime()  # 重置游戏计时
     self.clock = pygame.time.Clock()
     self.fullScreen = Con.FullScreen
     # noinspection PyTypeChecker
     self.manager: Controller.LocalManager = None
     self.frame = Base.MyFrame()
     self.running = False
     self.caption = f'Escape_Rect Version:{Con.Version}'
     self.enemy_num = 1
     self.Font = None
Exemplo n.º 4
0
 def gaming(self):
     Base.clearTime()
     Base.CurrentScreen = pygame.display.set_mode(Con.ScreenSize)
     self.controller.initEnemy(random.randint(Con.LeastEnemy, Con.MostEnemy))  # 创建敌人
     while self.controller.state == self.controller.STATE_GAMING:
         events = pygame.event.get()
         for e in events:
             if e.type == pygame.QUIT:
                 self.close()
                 return
             if e.type == pygame.KEYDOWN:
                 if e.key == pygame.K_ESCAPE:
                     self.close()
                     return
         self.controller.holdConnection()
         self.controller.updateSituation()
         self.flush()
         self.clock.tick(Con.FPS)
     self.controller.close()
Exemplo n.º 5
0
 def __init__(self, target: Base.MyFrame = None):
     Base.clearTime()
     self.controller = Controller.ServerManager(target)
     Base.CurrentScreen = pygame.display.set_mode(Con.ScreenSize, pygame.RESIZABLE)
     self.clock = pygame.time.Clock()
     self.alive = True