snake/settings.py

26 lines
785 B
Python
Raw Normal View History

2024-07-14 00:10:48 +08:00
import pygame
2024-07-14 00:46:17 +08:00
import sys
2024-07-14 00:10:48 +08:00
2024-07-15 01:07:37 +08:00
2024-07-14 00:10:48 +08:00
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 # 游戏得分
2024-07-18 16:48:01 +08:00
self.clock_frq = 3 # 刷新频率
2024-07-14 00:10:48 +08:00
self.my_clock = pygame.time.Clock()
2024-07-18 16:48:01 +08:00
2024-07-14 00:46:17 +08:00
if sys.platform.startswith("linux"):
self.font_name = pygame.font.match_font('wenquanyizenhei')
else:
2024-07-15 01:07:37 +08:00
self.font_name = pygame.font.match_font('simhei')