-
Notifications
You must be signed in to change notification settings - Fork 1
/
game.py
36 lines (27 loc) · 924 Bytes
/
game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# encoding=utf-8
import logging
import pygame
from config.game_config import GameConfig
from fsm.fsm_machine import FSMMachine
from game_event.game_event import GameEvent
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def start_game(fsm: FSMMachine):
clock = pygame.time.Clock()
while True:
clock.tick(GameConfig.fps)
fsm.update_machine()
# 初始化游戏界面
def init_game():
pygame.init()
pygame.font.init()
pygame.display.set_caption("plane fight")
game_display = pygame.display.set_mode(GameConfig.screen.size)
# 敌机出场定时器
pygame.time.set_timer(GameEvent.enemy_enter, GameConfig.enemy_enter_speed)
return FSMMachine(game_display)
# 程序入口
if __name__ == "__main__":
game = init_game()
start_game(game)
logger.info('游戏启动...')