Ejemplo n.º 1
0
    def __init__(self, fps: int, game_over_score: int, record_progress):
        """
        Constructor

        @param fps The fps of the game
        @param game_over_score The game will stop when either side reaches this score
        @param record_progress Whether to record the game process or not
        """
        self._ml_1P = "ml_1P"
        self._ml_2P = "ml_2P"
        self._ml_execute_time = 1.0 / fps
        self._frame_delayed = [0, 0]  # 1P, 2P
        self._score = [0, 0]  # 1P, 2P
        self._game_over_score = game_over_score
        self._cmd_receiver = CommandReceiver( \
            GameCommand, {
                "command": PlatformAction
            }, GameCommand(-1, PlatformAction.NONE))

        self._record_handler = get_record_handler(
            record_progress,
            {"status": (GameStatus.GAME_1P_WIN, GameStatus.GAME_2P_WIN)},
            get_log_dir())

        self._init_display()
        self._scene = Scene()
Ejemplo n.º 2
0
    def __init__(self, fps: int, level: int, record_progress, one_shot_mode):
        self._init_pygame()

        self._fps = fps
        self._scene = Scene(level)
        self._keyboard = KeyCommandMap({
                pygame.K_LEFT:  PlatformAction.MOVE_LEFT,
                pygame.K_RIGHT: PlatformAction.MOVE_RIGHT,
            }, PlatformAction.NONE)

        self._record_handler = get_record_handler(record_progress, {
                "status": (GameStatus.GAME_OVER, GameStatus.GAME_PASS)
            }, get_log_dir())
        self._one_shot_mode = one_shot_mode
Ejemplo n.º 3
0
    def __init__(self, fps: int, level: int, \
        record_progress: bool, one_shot_mode: bool):
        self._ml_name = "ml"
        self._ml_execute_time = 1.0 / fps
        self._frame_delayed = 0
        self._instruct_receiver = CommandReceiver( \
            GameInstruction, { "command": \
                [PlatformAction.MOVE_LEFT, PlatformAction.MOVE_RIGHT, PlatformAction.NONE], \
            }, GameInstruction(-1, PlatformAction.NONE))

        self._record_handler = get_record_handler(record_progress, { \
                "status": (GameStatus.GAME_OVER, GameStatus.GAME_PASS) \
            }, get_log_dir())
        self._one_shot_mode = one_shot_mode

        self._init_display()
        self._scene = gamecore.Scene(level, True)
Ejemplo n.º 4
0
    def __init__(self, fps: int, level: int, \
        record_progress: bool, one_shot_mode: bool):
        self._ml_name = "ml"
        self._ml_execute_time = 1.0 / fps
        self._frame_delayed = 0
        self._cmd_receiver = CommandReceiver( \
            GameCommand, {
                "command": PlatformAction
            }, GameCommand(-1, PlatformAction.NONE))

        self._record_handler = get_record_handler(record_progress, { \
                "status": (GameStatus.GAME_OVER, GameStatus.GAME_PASS) \
            }, get_log_dir())
        self._one_shot_mode = one_shot_mode

        self._init_display()
        self._scene = Scene(level)
Ejemplo n.º 5
0
    def __init__(self, fps, one_shot_mode, record_progress):
        self._init_pygame()

        self._scene = Scene()

        self._ml_name = "ml"
        self._ml_execution_time = 1 / fps
        self._frame_delayed = 0
        self._cmd_receiver = CommandReceiver( \
            GameCommand, {
                "command": SnakeAction,
            }, GameCommand(-1, SnakeAction.NONE))

        self._one_shot_mode = one_shot_mode
        self._record_handler = get_record_handler(
            record_progress, {"status":
                              (GameStatus.GAME_OVER, )}, get_log_dir())
Ejemplo n.º 6
0
    def __init__(self, fps, one_shot_mode, record_progress):
        self._init_pygame()

        self._scene = Scene()

        self._fps = fps
        self._keyboard_action = KeyCommandMap(
            {
                pygame.K_UP: SnakeAction.UP,
                pygame.K_DOWN: SnakeAction.DOWN,
                pygame.K_LEFT: SnakeAction.LEFT,
                pygame.K_RIGHT: SnakeAction.RIGHT,
            }, SnakeAction.NONE)

        self._one_shot_mode = one_shot_mode
        self._record_handler = get_record_handler(
            record_progress, {"status":
                              (GameStatus.GAME_OVER, )}, get_log_dir())
Ejemplo n.º 7
0
    def __init__(self, fps: int, game_over_score: int, record_progress: bool):
        self._init_pygame()

        self._fps = fps
        self._score = [0, 0]  # 1P, 2P
        self._game_over_score = game_over_score
        self._scene = gamecore.Scene(True)
        self._keyboard_action_1P = KeyCommandMap(
            {
                pygame.K_LEFT: PlatformAction.MOVE_LEFT,
                pygame.K_RIGHT: PlatformAction.MOVE_RIGHT,
            }, PlatformAction.NONE)
        self._keyboard_action_2P = KeyCommandMap(
            {
                pygame.K_a: PlatformAction.MOVE_LEFT,
                pygame.K_d: PlatformAction.MOVE_RIGHT,
            }, PlatformAction.NONE)

        self._record_handler = get_record_handler(
            record_progress,
            {"status": (GameStatus.GAME_1P_WIN, GameStatus.GAME_2P_WIN)},
            get_log_dir())