修复模式切换bug
This commit is contained in:
parent
5911f10f1b
commit
dc259579ce
@ -32,7 +32,7 @@ class Level(tool.State):
|
|||||||
def loadMap(self):
|
def loadMap(self):
|
||||||
modeList = ['adventure', 'littleGame']
|
modeList = ['adventure', 'littleGame']
|
||||||
if c.LITTLEGAME_BUTTON in self.game_info:
|
if c.LITTLEGAME_BUTTON in self.game_info:
|
||||||
map_file = 'littleGame_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
map_file = 'littleGame_' + str(self.game_info[c.LITTLEGAME_NUM]) + '.json'
|
||||||
mode = 'littleGame'
|
mode = 'littleGame'
|
||||||
else:
|
else:
|
||||||
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
||||||
@ -64,9 +64,9 @@ class Level(tool.State):
|
|||||||
elif self.game_info[c.LEVEL_NUM] in {3}: # 夜晚关卡
|
elif self.game_info[c.LEVEL_NUM] in {3}: # 夜晚关卡
|
||||||
bgm = 'nightLevel.opus'
|
bgm = 'nightLevel.opus'
|
||||||
elif mode == modeList[1]: # 小游戏模式
|
elif mode == modeList[1]: # 小游戏模式
|
||||||
if self.game_info[c.LEVEL_NUM] in {1}: # 传送带大战
|
if self.game_info[c.LITTLEGAME_NUM] in {1}: # 传送带大战
|
||||||
bgm = 'battle.opus'
|
bgm = 'battle.opus'
|
||||||
elif self.game_info[c.LEVEL_NUM] in {2}: # 坚果保龄球
|
elif self.game_info[c.LITTLEGAME_NUM] in {2}: # 坚果保龄球
|
||||||
bgm = 'bowling.opus'
|
bgm = 'bowling.opus'
|
||||||
pg.mixer.music.stop()
|
pg.mixer.music.stop()
|
||||||
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", bgm))
|
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", bgm))
|
||||||
@ -320,8 +320,8 @@ class Level(tool.State):
|
|||||||
elif self.checkMainMenuClick(mouse_pos):
|
elif self.checkMainMenuClick(mouse_pos):
|
||||||
self.done = True
|
self.done = True
|
||||||
self.next = c.MAIN_MENU
|
self.next = c.MAIN_MENU
|
||||||
#self.persist = {c.CURRENT_TIME:0.0, c.LEVEL_NUM:c.START_LEVEL_NUM} # 应该不能用c.LEVEL_NUM:c.START_LEVEL_NUM
|
#self.persist = {c.CURRENT_TIME:0, c.LEVEL_NUM:c.START_LEVEL_NUM} # 应该不能用c.LEVEL_NUM:c.START_LEVEL_NUM
|
||||||
self.persist = {c.CURRENT_TIME:0.0, c.LEVEL_NUM:self.persist[c.LEVEL_NUM], c.LITTLEGAME_NUM:self.persist[c.LITTLEGAME_NUM]}
|
self.persist = {c.CURRENT_TIME:0, c.LEVEL_NUM:self.persist[c.LEVEL_NUM], c.LITTLEGAME_NUM:self.persist[c.LITTLEGAME_NUM]}
|
||||||
pg.mixer.music.stop()
|
pg.mixer.music.stop()
|
||||||
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.opus"))
|
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.opus"))
|
||||||
pg.mixer.music.play(-1, 0)
|
pg.mixer.music.play(-1, 0)
|
||||||
|
|||||||
@ -9,8 +9,8 @@ from . import constants as c
|
|||||||
# an abstract class, one state of automata
|
# an abstract class, one state of automata
|
||||||
class State():
|
class State():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.start_time = 0.0
|
self.start_time = 0
|
||||||
self.current_time = 0.0
|
self.current_time = 0
|
||||||
self.done = False # false 代表未做完
|
self.done = False # false 代表未做完
|
||||||
self.next = None # 表示这个状态退出后要转到的下一个状态
|
self.next = None # 表示这个状态退出后要转到的下一个状态
|
||||||
self.persist = {} # 在状态间转换时需要传递的数据
|
self.persist = {} # 在状态间转换时需要传递的数据
|
||||||
@ -42,7 +42,7 @@ class Control():
|
|||||||
self.state_dict = {}
|
self.state_dict = {}
|
||||||
self.state_name = None
|
self.state_name = None
|
||||||
self.state = None
|
self.state = None
|
||||||
self.game_info = {c.CURRENT_TIME:0.0,
|
self.game_info = {c.CURRENT_TIME:0,
|
||||||
c.LEVEL_NUM:c.START_LEVEL_NUM,
|
c.LEVEL_NUM:c.START_LEVEL_NUM,
|
||||||
c.LITTLEGAME_NUM:c.START_LITTLE_GAME_NUM}
|
c.LITTLEGAME_NUM:c.START_LITTLE_GAME_NUM}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user