snake/settings.py
2024-07-15 01:07:37 +08:00

25 lines
776 B
Python

import pygame
import sys
class Settings:
def __init__(self):
self.bg_color = (0, 0, 0) # 背景颜色
self.width = 400
self.height = 400
self.cell_size = 20 # 格子大小
self.cell_w = int(self.width / self.cell_size) # 一行的格子数
self.cell_h = int(self.height / self.cell_size) # 一列的格子数
self.num = self.cell_w * self.cell_h
self.game_mode = 0 # 游戏状态
self.score = 0 # 游戏得分
self.clock_frq = 5 # 刷新频率
self.my_clock = pygame.time.Clock()
if sys.platform.startswith("linux"):
self.font_name = pygame.font.match_font('wenquanyizenhei')
else:
self.font_name = pygame.font.match_font('simhei')