Слияние кода завершено, страница обновится автоматически
import pygame
from setting import all_cc_labels
from Study import ChineseChar
class ShowCC:
"""
娱乐模式使用,答对后在上面的卡牌中显示相应的字
"""
def __init__(self, screen, cc_index, pos_x, pos_y):
self.screen = screen
self.pos_x = pos_x + 23
self.pos_y = pos_y + 7
self.cc_pos_x = pos_x - 18
self.cc_pos_y = pos_y - 18
self.cc_index = cc_index
self.question_image = pygame.image.load("./images/rest/question.png")
image_name = "./images/cc/zi/" + str(all_cc_labels[cc_index]) + ".png"
cc_image = pygame.image.load(image_name)
self.cc_image = pygame.transform.scale(cc_image,
(int(cc_image.get_width() / 3.5),
int(cc_image.get_height() / 3.5)))
self.is_show_cc = False
def show_cc(self):
self.is_show_cc = True
def hide_cc(self):
self.is_show_cc = False
def get_cc_index(self):
return self.cc_index
def update(self):
if self.is_show_cc:
self.screen.blit(self.cc_image, (self.cc_pos_x, self.cc_pos_y))
else:
self.screen.blit(self.question_image, (self.pos_x, self.pos_y))
# 根据game_level在卡牌中显示相应的一组(7个)汉字
class ShowCCGroup:
def __init__(self, screen, game_level):
self.current_cc_obj = None
self.screen = screen
self.all_show_cc_pos = [(151, 13), (248, 13), (342, 13), (435, 13), (530, 13), (625, 13), (719, 13)]
self.all_show_cc_list = []
self.game_level = game_level
self.play_text_sound = False
self.play_text_index = 0
self.text_sound_times = 0
cc_pos_index = 0
for cc_index in range(game_level * 7, game_level * 7 + 7):
cc_pos_x = self.all_show_cc_pos[cc_pos_index][0]
cc_pos_y = self.all_show_cc_pos[cc_pos_index][1]
show_cc_obj = ShowCC(screen, cc_index, cc_pos_x, cc_pos_y)
self.all_show_cc_list.append(show_cc_obj)
cc_pos_index += 1
def is_to_play_text(self):
return self.play_text_sound
def do_text_sound_play(self):
if self.is_to_play_text():
self.text_sound_times += 1
if self.text_sound_times >= 4:
self.text_sound_times = 0
self.play_text_sound = False
else:
current_text_index = self.play_text_index
if self.text_sound_times <= 2:
self.change_to_show_cc(current_text_index)
else:
self.change_to_hide_cc(current_text_index)
self.speak_current_cc()
def set_speak_cc(self, play_text_index):
self.text_sound_times = 0
self.play_text_sound = True
self.play_text_index = play_text_index
cc_label = all_cc_labels[play_text_index]
self.current_cc_obj = ChineseChar(cc_label)
def speak_current_cc(self):
self.current_cc_obj.play_sound()
def change_question_to_cc(self):
current_cc_index = self.play_text_index
self.change_to_show_cc(current_cc_index)
def change_to_show_cc(self, cc_index):
for show_cc_obj in self.all_show_cc_list:
if cc_index == show_cc_obj.get_cc_index():
show_cc_obj.show_cc()
break
def change_to_hide_cc(self, cc_index):
for show_cc_obj in self.all_show_cc_list:
if cc_index == show_cc_obj.get_cc_index():
show_cc_obj.hide_cc()
break
def update(self):
for show_cc_obj in self.all_show_cc_list:
show_cc_obj.update()
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )