1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/python4fun-LearnCC

В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
Study.py 3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
猫姐 Отправлено 17.10.2021 06:50 753c35a
import pygame, sys
from Button import Button
from setting import all_cc_labels, total_cc_count
class ChineseChar:
def __init__(self, int_label):
self.cc_pos_x = 253
self.cc_pos_y = 88
label = str(int_label)
self.cc_image = pygame.image.load("./images/cc/zi/" + label + ".png")
# self.wu_image = pygame.image.load("./images/cc/wu/" + label + ".png")
self.cc_sound = pygame.mixer.Sound("./sounds/cc/" + label + ".wav")
self.cc_sound.set_volume(0.5)
def play_sound(self):
self.cc_sound.play()
def update(self, screen):
screen.blit(self.cc_image, (self.cc_pos_x, self.cc_pos_y))
# screen.blit(self.wu_image, (self.wu_pos_x, self.wu_pos_y))
class StudyModeEngine:
def __init__(self):
speaker_button = Button("speaker", 830, 115)
previous_button = Button("pre", 830, 311)
next_button = Button("next", 830, 500)
go_menu_button = Button("go_menu", 20, 14)
go_exit_button = Button("go_exit", 1156, 14)
self.study_mode_buttons = pygame.sprite.Group()
self.study_mode_buttons.add(speaker_button)
self.study_mode_buttons.add(previous_button)
self.study_mode_buttons.add(next_button)
self.study_mode_buttons.add(go_menu_button)
self.study_mode_buttons.add(go_exit_button)
self.current_cc_index = 0
current_cc_label = self.get_cc_label()
self.cc = ChineseChar(current_cc_label)
self.action = None
def do_buttons_click(self, x, y, up_or_down):
is_go_menu = False
for button in self.study_mode_buttons:
if button.rect.collidepoint(x, y):
button.revert_image()
if up_or_down == "UP":
self.action = button.name
break
if self.action == "go_menu":
return True
def decrease_cc_index(self):
self.current_cc_index = self.current_cc_index - 1
if self.current_cc_index < 0:
self.current_cc_index = 0
def increase_cc_index(self):
self.current_cc_index = self.current_cc_index + 1
if self.current_cc_index == total_cc_count:
self.current_cc_index = total_cc_count - 1
def get_cc_label(self):
return all_cc_labels[self.current_cc_index]
def update(self):
if self.action == "speaker":
self.cc.play_sound()
elif self.action == "pre":
self.decrease_cc_index()
cc_label = self.get_cc_label()
self.cc = ChineseChar(cc_label)
elif self.action == "next":
self.increase_cc_index()
cc_label = self.get_cc_label()
self.cc = ChineseChar(cc_label)
elif self.action == "go_exit":
sys.exit()
self.action = None
self.study_mode_buttons.update()
def draw(self, screen):
self.cc.update(screen)
self.study_mode_buttons.draw(screen)

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/python4fun-LearnCC.git
git@api.gitlife.ru:oschina-mirror/python4fun-LearnCC.git
oschina-mirror
python4fun-LearnCC
python4fun-LearnCC
master