import os
import sys
import pygame
import cfg
from modules import *
'''游戏主程序'''
def main():
pygame.init()
screen = pygame.display.set_mode(cfg.SCREENSIZE)
pygame.display.set_caption('Gemgem —— 九歌')
# 加载背景音乐
pygame.mixer.init()
pygame.mixer.music.load(os.path.join(cfg.ROOTDIR, "resources/audios/bg.mp3"))
pygame.mixer.music.set_volume(0.6)
pygame.mixer.music.play(-1)
ws001@WSdeMacBook-Pro Desktop % python3 demo01.py
pygame 2.1.0 (SDL 2.0.16, Python 3.10.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/Users/ws001/Desktop/demo01.py", line 67, in <module>
main()
File "/Users/ws001/Desktop/demo01.py", line 11, in main
screen = pygame.display.set_mode(cfg.SCREENSIZE)
AttributeError: module 'cfg' has no attribute 'SCREENSIZE'
https://ask.csdn.net/questions/7917189
不知道你这个问题是否已经解决, 如果还没有解决的话: