增加BMG
This commit is contained in:
parent
4eea5c5431
commit
b0b119aba9
BIN
resources/music/battle.ogg
Normal file
BIN
resources/music/battle.ogg
Normal file
Binary file not shown.
BIN
resources/music/bowling.ogg
Normal file
BIN
resources/music/bowling.ogg
Normal file
Binary file not shown.
BIN
resources/music/chooseYourSeeds.ogg
Normal file
BIN
resources/music/chooseYourSeeds.ogg
Normal file
Binary file not shown.
BIN
resources/music/dayLevel.ogg
Normal file
BIN
resources/music/dayLevel.ogg
Normal file
Binary file not shown.
BIN
resources/music/intro.ogg
Normal file
BIN
resources/music/intro.ogg
Normal file
Binary file not shown.
BIN
resources/music/nightLevel.ogg
Normal file
BIN
resources/music/nightLevel.ogg
Normal file
Binary file not shown.
@ -26,10 +26,13 @@ class Level(tool.State):
|
|||||||
self.initState()
|
self.initState()
|
||||||
|
|
||||||
def loadMap(self):
|
def loadMap(self):
|
||||||
|
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.LEVEL_NUM]) + '.json'
|
||||||
|
mode = 'adventure'
|
||||||
else:
|
else:
|
||||||
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
||||||
|
mode = 'littleGame'
|
||||||
file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file)
|
file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file)
|
||||||
# 最后一关之后应该结束了
|
# 最后一关之后应该结束了
|
||||||
try:
|
try:
|
||||||
@ -42,12 +45,31 @@ class Level(tool.State):
|
|||||||
self.map_data = json.load(f)
|
self.map_data = json.load(f)
|
||||||
self.done = True
|
self.done = True
|
||||||
self.next = c.MAIN_MENU
|
self.next = c.MAIN_MENU
|
||||||
|
pg.mixer.music.stop()
|
||||||
|
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.ogg"))
|
||||||
|
pg.mixer.music.play(-1, 0)
|
||||||
return
|
return
|
||||||
if self.map_data[c.SHOVEL] == 0:
|
if self.map_data[c.SHOVEL] == 0:
|
||||||
self.hasShovel = False
|
self.hasShovel = False
|
||||||
else:
|
else:
|
||||||
self.hasShovel = True
|
self.hasShovel = True
|
||||||
|
|
||||||
|
# 同时播放音乐
|
||||||
|
global bgm
|
||||||
|
if mode == modeList[1]: # 冒险模式
|
||||||
|
if self.game_info[c.LEVEL_NUM] in {0, 1, 2}: # 白天关卡
|
||||||
|
bgm = 'dayLevel.ogg'
|
||||||
|
elif self.game_info[c.LEVEL_NUM] in {3}: # 夜晚关卡
|
||||||
|
bgm = 'nightLevel.ogg'
|
||||||
|
elif mode == modeList[0]: # 小游戏模式
|
||||||
|
if self.game_info[c.LEVEL_NUM] in {1}: # 传送带大战
|
||||||
|
bgm = 'battle.ogg'
|
||||||
|
elif self.game_info[c.LEVEL_NUM] in {2}: # 坚果保龄球
|
||||||
|
bgm = 'bowling.ogg'
|
||||||
|
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.play(-1, 0)
|
||||||
|
|
||||||
def setupBackground(self):
|
def setupBackground(self):
|
||||||
img_index = self.map_data[c.BACKGROUND_TYPE]
|
img_index = self.map_data[c.BACKGROUND_TYPE]
|
||||||
self.background_type = img_index
|
self.background_type = img_index
|
||||||
@ -256,17 +278,25 @@ class Level(tool.State):
|
|||||||
def play(self, mouse_pos, mouse_click):
|
def play(self, mouse_pos, mouse_click):
|
||||||
# 如果暂停
|
# 如果暂停
|
||||||
if self.showLittleMenu:
|
if self.showLittleMenu:
|
||||||
|
pg.mixer.music.pause() # 暂停播放音乐
|
||||||
if mouse_click[0]:
|
if mouse_click[0]:
|
||||||
if self.checkReturnClick(mouse_pos):
|
if self.checkReturnClick(mouse_pos):
|
||||||
# 暂停 显示菜单
|
# 暂停 显示菜单
|
||||||
self.showLittleMenu = False
|
self.showLittleMenu = False
|
||||||
|
pg.mixer.music.unpause()
|
||||||
elif self.checkRestartClick(mouse_pos):
|
elif self.checkRestartClick(mouse_pos):
|
||||||
self.done = True
|
self.done = True
|
||||||
self.next = c.LEVEL
|
self.next = c.LEVEL
|
||||||
|
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.play(-1, 0)
|
||||||
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}
|
self.persist = {c.CURRENT_TIME:0.0, c.LEVEL_NUM:c.START_LEVEL_NUM}
|
||||||
|
pg.mixer.music.stop()
|
||||||
|
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.ogg"))
|
||||||
|
pg.mixer.music.play(-1, 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.zombie_start_time == 0:
|
if self.zombie_start_time == 0:
|
||||||
|
|||||||
@ -205,3 +205,8 @@ SCREEN = pg.display.set_mode(c.SCREEN_SIZE) # 设置初始屏幕
|
|||||||
GFX = load_all_gfx(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,os.path.join("resources","graphics")))
|
GFX = load_all_gfx(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,os.path.join("resources","graphics")))
|
||||||
ZOMBIE_RECT = loadZombieImageRect()
|
ZOMBIE_RECT = loadZombieImageRect()
|
||||||
PLANT_RECT = loadPlantImageRect()
|
PLANT_RECT = loadPlantImageRect()
|
||||||
|
|
||||||
|
# 播放音乐
|
||||||
|
pg.mixer.init()
|
||||||
|
pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,"resources", "music", "intro.ogg"))
|
||||||
|
pg.mixer.music.play(-1, 0)
|
||||||
Loading…
x
Reference in New Issue
Block a user