我不确定为什么这不起作用。我需要上课吗?
只是对于一个随机项目,我已经尝试过制作一个类,但是不确定是否需要使用(self)或其他东西
我知道其他人也有这个问题,但是他们都上过课,我不确定我是否需要这个问题或我该怎么做。
from pygame_functions import *
import pygame
import random
def Menu():
screenSize(1280, 755)
setBackgroundColour( [93, 173, 226] )
PlayButton = makeSprite("filename") # put in file from photoshop
# MoveSprite()
showSprite(PlayButton)
SettingsButton = makeSprite("filename") # put in setting button
# MoveSprite()
showSprite(SettingsButton)
if spriteClicked(PlayButton):
Difficulty()
hideSprite(PlayButton)
hideSprite(SettingsButton)
if spriteClicked(SettingsButton):
Settings()
hideSprite(PlayButton)
hideSprite(SettingsButton)
else:
showSprite(PlayButton)
showSprite(SettingsButton)
def Settings():
drawRect(440, 65, 400, 600, "Black")
SoundButton = makeSprite("filename")
SoundIcon = makeImage("filename") # On
ScreenRes = makeSprite("filename")
ScreenResIcon = makeImage("filename") # 1280x755
List = int(0)
if spriteClicked(SoundButton):
changeSpriteImage(SoundIcon, "filename") # Off
if spriteClicked(ScreenRes):
if List == 4:
List = 0
else:
if List == 0:
changeSpriteImage(ScreenResIcon, "Filename") # 1280x755
List = List + 1
elif List == 1:
changeSpriteImage(ScreenResIcon, "Filename") # 1366x768
List = List + 1
elif List == 2:
changeSpriteImage(ScreenResIcon, "Filename") #1920x1080
List = List + 1
elif List == 3:
changeSpriteImage(ScreenResIcon, "Filename") # 320x568
List = List + 1
def Difficulty(Range):
Hard = makeSprite("FileName") # hard button
showSprite(Hard)
Medium = makeSprite("Filename")
showSprite(Medium)
Easy = makeSprite("Filename")
showSprite(Easy)
range = int(0)
if spriteClicked(Hard):
Game()
Range = int(51)# 50
elif spriteClicked(Medium):
Game()
Range = int(26)# 25
elif spriteClicked(Easy):
Game()
Range = int(11)# 10
range = Range
def Game(Range):
setBackgroundColour("Blue")
# after all the visual stuff
random.randint(1, Range)
endWait()
答案 0 :(得分:0)
我认为您的导入语句应来自pygame.locals import*
,而不是pygame.functions import*