class Button:
def __int__(self,screen,text,x,y,color,enable):
=screen
=button_w
=button_h
self.button_color=color
self.text_color=(255,255,255)
=enable
=(None,button_h*2//3)
=(0,0,,)
=(x,y)
=text
self.init_msg()
#重写pygame函数,初始化按钮
def init_msg(self):
if :
self.msg_iamge=(,True,self.text_color,self.button_color[0])
else:
self.msg_iamge=(,True,self.text_color,self.button_color[1])
self.msg_iamge_rect=self.msg_iamge.get_rect()
self.msg_iamge_rect.center=
#根据按钮的enable状态填色,具体颜色在后续子类控制
def draw(self):
if :
(self.button_color[0],)
else:
(self.button_color[1],)
(self.msg_iamge,self.msg_iamge_rect)