Beispiel #1
0
def main():
    state_dict = {
        'main_menu': main_menu.MainMenu(),
        'load_screen': load_screen.LoadScreen(),
        'level': level.Level()
    }
    game = tools.Game(state_dict, 'main_menu')
    game.run()
Beispiel #2
0
def main():
    state_dict = {
        "main_menu": main_menu.MainMenu(),
        "load_sreen": load_screen.LoadScreen(),
        "level": level.Level()
    }
    game = tools.Game(state_dict, "main_menu")
    game.run(state)
Beispiel #3
0
def main():

    states = {
        'main_menu': main_menu.MainMenu(),
        'load_screen': load_screen.LoadScreen(),
        'level': level.Level(),
        'game_over': load_screen.GameOver()
    }
    game = tools.Game(states, 'main_menu')
    game.run()
Beispiel #4
0
def main():
    game = tools.Game() # 初始主控流程
    # 初始各个游戏阶段
    state_dict = {C.MAIN_MENU: main_menu.Menu(),
                  C.LOAD_SCREEN: load_screen.LoadScreen(),
                  C.LEVEL: level.Level(),
                  C.GAME_OVER: load_screen.GameOver(),
                  C.TIME_OUT: load_screen.TimeOut()
                  }
    # 启动主菜单
    game.setup_states(state_dict, C.MAIN_MENU)

    # 执行主控流程里的主函数
    game.run()
Beispiel #5
0
    def __init__(self, config, mode='agent'):
        # TODO - Fix so that the window does not show up while training (window=false)
        has_window = "window" in config and config["window"]
        fps = 60 if "fps" not in config else config["fps"]
        actions = COMPLEX_MOVEMENT if "actions" not in config else config[
            "actions"]

        if not has_window:
            os.environ['SDL_VIDEODRIVER'] = 'dummy'
        import pygame

        self.pg = pygame

        self.has_window = has_window
        self.done = False
        self.mario_x_last = c.DEBUG_START_X
        self.clock_last = c.GAME_TIME_OUT
        self.game = tools.Control()
        self.game.fps = fps
        state_dict = {
            c.MAIN_MENU: main_menu.Menu(),
            c.LOAD_SCREEN: load_screen.LoadScreen(),
            c.LEVEL: level.Level(),
            c.GAME_OVER: load_screen.GameOver(),
            c.TIME_OUT: load_screen.TimeOut()
        }
        self.game.setup_states(state_dict, c.MAIN_MENU)

        # a mapping of buttons to pygame values
        self._button_map = {
            'right': K_RIGHT,
            'left': K_LEFT,
            'down': K_DOWN,
            'up': K_UP,
            'start': K_RETURN,
            'select': K_RETURN,
            'B': K_s,
            'A': K_a,
            'NOOP': KMOD_NONE,
        }

        self._ACTION_TO_KEYS = {}
        self._TILE_MAP, self._CHAR_MAP = self.tokenize_tiles(c.TILES)
        # print("mario_env._TILE_MAP:")
        # self.print_dict(self._TILE_MAP)
        # print("mario_env._CHAR_MAP:")
        # self.print_dict(self._CHAR_MAP)
        self.setup_spaces(actions)
Beispiel #6
0
def run_game_main_and_exit():
    import sys
    from source import tools
    from source.states import main_menu, load_screen
    if c.GENERATE_MAP:
        from source.states import level_gen as level
    else:
        from source.states import level

    game = tools.Control()
    game.fps = 60
    state_dict = {
        c.MAIN_MENU: main_menu.Menu(),
        c.LOAD_SCREEN: load_screen.LoadScreen(),
        c.LEVEL: level.Level(),
        c.GAME_OVER: load_screen.GameOver(),
        c.TIME_OUT: load_screen.TimeOut()
    }
    game.setup_states(state_dict, c.MAIN_MENU)
    if c.SKIP_MENU:
        game.flip_state(force=c.LEVEL)
    game.main()
    sys.exit(0)
Beispiel #7
0
#游戏入口
import pygame
from source import tool ,setup
from source.states import main_manu,load_screen, level ,shop
from source import constants as c
from source.components import loginWindow as lw

import pygame as pg

if __name__=='__main__':
    loginwindow = lw.LoginWindow()
    print('start here')
    game = tool.Control()
    state_dict = {c.MAIN_MENU: main_manu.Menu(),
                  c.LOAD_SCREEN: load_screen.LoadScreen(),
                  c.LEVEL: level.Level(),
                  c.SHOP: shop.Shop(),
                  c.GAME_OVER: load_screen.GameOver(),
                  c.WANNA_EXIT: load_screen.ifExit(),
                  c.TIME_OUT: load_screen.TimeOut(),
                  c.WIN: load_screen.Win()}
    game.setup_states(state_dict, c.MAIN_MENU) #不停把statedict丢进来 game类的state_dict就包含以上7个状态,每一次都要查找标题,然后把相应的函数放进来
    #比如这个初始状态 下标就等于c.MAIN_MENU,因此game.state=main_manu.Menu()
    #下一次如果状态变为 c.SHOP,那么game.state=shop.Shop() 就是这么简单的逻辑
    game.main()
    pg.quit()