Beispiel #1
0
    def __init__(self, window, model, start_game_callback, debug=False):
        self.window = window
        self.model = model
        self.state = 'menu'

        SaveComponent.load()

        self.debug = debug

        self.start_game_callback = start_game_callback

        self.window.screen_offset = 0, 0

        self.page_name = None
        self.page = None
        self.page_res = None
        self.pos_hdlrs = None
        self.panels = None
        self.menu_objects = None
        self.action_manager = None
        self.classic_buttons = None
        self.viewer_page = None
        self.y_offset = 0

        self.window.set_page(self.window.menu_page)

        self.texts = None

        self.init_page('MainMenu')

        self.window.update = self.update
Beispiel #2
0
        class BasePlayerData(DataContainer):
            height = 50
            width = 35
            name = "player"
            pos_x = SaveComponent(2)
            pos_y = SaveComponent(3)

            max_lives = 3
            current_lives = SaveComponent(7)

            jump_y_impulse = 500
            walking_max_velocity = 50
            running_max_velocity = 132
            air_control_max_velocity = 100
            acceleration = 33
            air_control_acceleration = 50
            dash_speed = 2000
            dash_length = 6  # in ticks

            on_death_trigger_id = 99000

            class StateDuration(DataContainer):
                idle = 0.034
                fall = 0.017
                jump = 0.017
                dash = 7 / 60
                land = 0.14
Beispiel #3
0
    def __init__(self, window, model, return_to_main_menu, loading_finished_check, current_save_id, debug=False):

        self.window = window

        self.model = model
        self.state = 'idle'
        self.return_to_main_menu = return_to_main_menu
        self.loading_finished_check = loading_finished_check
        self.debug_draw = False

        self.level_cache = dict()

        self.dash_particles = []

        self.debug = debug

        self.current_save_id = current_save_id

        self.t1 = self.count = self.number_of_space_updates = self.space = \
            self.player = self.entities = self.structures = self.triggers = self.ag = self.action_manager = None
        self.constraints = None
        self.kinematic_structures = None
        self.checkpoints = None
        self.camera_handler = None
        self.is_player_dead = False
        self.is_camera_handler_activated = True
        self.sprites_to_delete = []
        self.already_hidden = []
        self.scheduled_func = dict()

        self.dynamic_structures = dict()

        self.player_lives = 3

        self.additional_commands = []

        self.current_map_id = -1

        self.draw_options = None

        self.viewer_page = None

        self.player_debug_values = None

        self._paused = False
        self.debug_draw_activated = False

        self.should_inversion_handler_record = False
        self.inverted_space = False
        self.inversion_handler = None

        self.hearts = []

        SaveComponent.load()
        self.level = self.load_map_file(self.model.Game.current_map_id.get(self.current_save_id))

        self.level_res = self.level['background_data']['res']

        self.window.reset_event_manager()
Beispiel #4
0
    def __init__(self, label, dtype, save_component_id, save_id):
        super().__init__()
        uic.loadUi('.\\qt_templates\\acp_save_component_widget.ui', self)

        self.label.setText(str(save_component_id))

        self.save = SaveComponent(save_component_id)
        self.save_id = save_id

        self.label_lineedit.setText(label)

        self._data_type = 'integer'

        self.dtype2frame = dict(booleans=self.checkboxes_frame,
                                shorts=self.double_spinbox_frame,
                                integer=self.spinbox_frame)

        self.checkboxes_frame.setHidden(True)
        self.double_spinbox_frame.setHidden(True)
        self.spinbox_frame.setHidden(True)

        self.type_combobox.currentTextChanged.connect(self._set_data_type)

        self.data_type = dtype
Beispiel #5
0
def get_model(path, default_save=False):
    sys.path.append(path)
    from data.data_ import Data
    if default_save:
        SaveComponent.init(os.path.normpath(Data.default_save_path),
                           Data.menu_save_length,
                           Data.game_save_length,
                           no_dump_mode=True)
    else:
        SaveComponent.init(os.path.normpath(Data.save_path),
                           Data.menu_save_length, Data.game_save_length)
    SaveComponent.load()
    return Data
Beispiel #6
0
 class Controls(DataContainer):
     actions = 'left', 'right', 'run', 'dash', 'jump', 'menu', 'interact'
     left = (SaveComponent(6), SaveComponent(13))
     right = (SaveComponent(7), SaveComponent(14))
     run = (SaveComponent(8), SaveComponent(15))
     dash = (SaveComponent(9), SaveComponent(16))
     jump = (SaveComponent(10), SaveComponent(17))
     menu = (SaveComponent(11), SaveComponent(18))
     interact = (SaveComponent(12), SaveComponent(19))
Beispiel #7
0
 class Gameplay(DataContainer):
     deadzones = SaveComponent(4)
     invert_axis = SaveComponent(5)
Beispiel #8
0
 class Video(DataContainer):
     display_mode = SaveComponent(0)
     width = SaveComponent(1)
     height = SaveComponent(2)
     resolution = width + height
     luminosity = SaveComponent(3)
Beispiel #9
0
    class Options(DataContainer):
        option_types = ('Video', 'Gameplay', 'Controls')
        default_values = ((SaveComponent(0), 1), (SaveComponent(1), 1280),
                          (SaveComponent(2), 720), (SaveComponent(3), 0),
                          (SaveComponent(4),
                           (50, 50)), (SaveComponent(5),
                                       (0, 0)), (SaveComponent(6), 113),
                          (SaveComponent(7), 100), (SaveComponent(8), 65505),
                          (SaveComponent(9), 122), (SaveComponent(10), 32),
                          (SaveComponent(11), 65307), (SaveComponent(12), 101),
                          (SaveComponent(13),
                           (0, -1)), (SaveComponent(14),
                                      (0, 1)), (SaveComponent(15), (10, 5)),
                          (SaveComponent(16),
                           (10, 2)), (SaveComponent(17),
                                      (10, 0)), (SaveComponent(18),
                                                 (10, 7)), (SaveComponent(19),
                                                            (10, 1)))

        class Video(DataContainer):
            display_mode = SaveComponent(0)
            width = SaveComponent(1)
            height = SaveComponent(2)
            resolution = width + height
            luminosity = SaveComponent(3)

        class Gameplay(DataContainer):
            deadzones = SaveComponent(4)
            invert_axis = SaveComponent(5)

        class Controls(DataContainer):
            actions = 'left', 'right', 'run', 'dash', 'jump', 'menu', 'interact'
            left = (SaveComponent(6), SaveComponent(13))
            right = (SaveComponent(7), SaveComponent(14))
            run = (SaveComponent(8), SaveComponent(15))
            dash = (SaveComponent(9), SaveComponent(16))
            jump = (SaveComponent(10), SaveComponent(17))
            menu = (SaveComponent(11), SaveComponent(18))
            interact = (SaveComponent(12), SaveComponent(19))
Beispiel #10
0
 class BaseBGData(DataContainer):
     camera_pos_x = SaveComponent(0)
     camera_pos_y = SaveComponent(1)
Beispiel #11
0
 def cancel(self):
     if self.current_panel:
         SaveComponent.load()
         self.close_options()
Beispiel #12
0
 class ControlsPanel:
     typ = 'structure'
     res = 'panels/options_controls_panel.obj'
     pos = (70, 220 * 1000)
     buttons_order = (
         ('kb_left', 'con_left', 'kb_menu', 'con_menu'),
         ('kb_right', 'con_right', 'kb_interact',
          'con_interact'),
         ('kb_run', 'con_run', None, None),
         ('kb_dash', 'con_dash', None, None),
         ('kb_jump', 'con_jump', None, None),
         ('apply_button', 'cancel_button', None,
          'reset_button'),
     )
     additional_buttons = dict(
         kb_left=dict(pos=(205, 500 * 1000),
                      action='set_kbkey',
                      arg='left',
                      font=('nkb', 40, SaveComponent(6),
                            "#eeeeee", "#888888", 100, 35, 3)),
         kb_right=dict(pos=(205, 440 * 1000),
                       action='set_kbkey',
                       arg='right',
                       font=('nkb', 40, SaveComponent(7),
                             "#eeeeee", "#888888", 100, 35, 3)),
         kb_run=dict(pos=(205, 380 * 1000),
                     action='set_kbkey',
                     arg='run',
                     font=('nkb', 40, SaveComponent(8),
                           "#eeeeee", "#888888", 100, 35, 3)),
         kb_dash=dict(pos=(205, 320 * 1000),
                      action='set_kbkey',
                      arg='dash',
                      font=('nkb', 40, SaveComponent(9),
                            "#eeeeee", "#888888", 100, 35, 3)),
         kb_jump=dict(pos=(205, 260 * 1000),
                      action='set_kbkey',
                      arg='jump',
                      font=('nkb', 40, SaveComponent(10),
                            "#eeeeee", "#888888", 100, 35, 3)),
         kb_menu=dict(pos=(790, 500 * 1000),
                      action='set_kbkey',
                      arg='menu',
                      font=('nkb', 40, SaveComponent(11),
                            "#eeeeee", "#888888", 100, 35, 3)),
         kb_interact=dict(pos=(790, 440 * 1000),
                          action='set_kbkey',
                          arg='interact',
                          font=('nkb', 40, SaveComponent(12),
                                "#eeeeee", "#888888", 100, 35,
                                3)),
         con_left=dict(pos=(430, 500 * 1000),
                       action='set_conkey',
                       arg='left',
                       font=('ncon', 40, SaveComponent(13),
                             "#eeeeee", "#888888", 100, 35, 3)),
         con_right=dict(pos=(430, 440 * 1000),
                        action='set_conkey',
                        arg='right',
                        font=('ncon', 40, SaveComponent(14),
                              "#eeeeee", "#888888", 100, 35,
                              3)),
         con_run=dict(pos=(430, 380 * 1000),
                      action='set_conkey',
                      arg='run',
                      font=('ncon', 40, SaveComponent(15),
                            "#eeeeee", "#888888", 100, 35, 3)),
         con_dash=dict(pos=(430, 320 * 1000),
                       action='set_conkey',
                       arg='dash',
                       font=('ncon', 40, SaveComponent(16),
                             "#eeeeee", "#888888", 100, 35, 3)),
         con_jump=dict(pos=(430, 260 * 1000),
                       action='set_conkey',
                       arg='jump',
                       font=('ncon', 40, SaveComponent(17),
                             "#eeeeee", "#888888", 100, 35, 3)),
         con_menu=dict(pos=(1025, 500 * 1000),
                       action='set_conkey',
                       arg='menu',
                       font=('ncon', 40, SaveComponent(18),
                             "#eeeeee", "#888888", 100, 35, 3)),
         con_interact=dict(pos=(1025, 440 * 1000),
                           action='set_conkey',
                           arg='interact',
                           font=('ncon', 40, SaveComponent(19),
                                 "#eeeeee", "#888888", 100, 35,
                                 3)),
     )
     panel_name = 'Controls'
Beispiel #13
0
 def dump_save():
     SaveComponent.dump()
Beispiel #14
0
    def reload(self):
        SaveComponent.load()

        for w in self.save_component_widgets:
            w.refresh_value()
Beispiel #15
0
    def save(self):

        for w in self.save_component_widgets:
            w.apply_on_save_component()

        SaveComponent.dump()
Beispiel #16
0
class SaveComponentWidget(QtWidgets.QWidget):
    def __init__(self, label, dtype, save_component_id, save_id):
        super().__init__()
        uic.loadUi('.\\qt_templates\\acp_save_component_widget.ui', self)

        self.label.setText(str(save_component_id))

        self.save = SaveComponent(save_component_id)
        self.save_id = save_id

        self.label_lineedit.setText(label)

        self._data_type = 'integer'

        self.dtype2frame = dict(booleans=self.checkboxes_frame,
                                shorts=self.double_spinbox_frame,
                                integer=self.spinbox_frame)

        self.checkboxes_frame.setHidden(True)
        self.double_spinbox_frame.setHidden(True)
        self.spinbox_frame.setHidden(True)

        self.type_combobox.currentTextChanged.connect(self._set_data_type)

        self.data_type = dtype

    def _set_data_type(self, value):
        self.data_type = str(value)

    @property
    def data_type(self):
        return self._data_type

    @data_type.setter
    def data_type(self, value):
        assert value in {'integer', 'shorts', 'booleans'}

        self.dtype2frame[self.data_type].setHidden(True)
        self.dtype2frame[value].setHidden(False)

        self._data_type = value
        combobox_value = self.type_combobox.currentText()
        if combobox_value != value:
            self.type_combobox.setCurrentText(value)

        self.refresh_value()

    def refresh_value(self):
        if self.data_type == 'integer':
            self.int_spinbox.setValue(self.save.get(self.save_id))

        elif self.data_type == 'shorts':
            a, b = self.save.get_bytes(self.save_id)
            self.s_spinbox_1.setValue(a)
            self.s_spinbox_2.setValue(b)

        elif self.data_type == 'booleans':
            unformated_name = 'checkBox_{}'
            booleans = self.save.get_booleans(self.save_id)
            for i, value in enumerate(booleans):
                getattr(self, unformated_name.format(i + 1)).setChecked(value)

    def apply_on_save_component(self):
        if self.data_type == 'integer':
            value = self.int_spinbox.value()
            self.save.set(value, self.save_id)

        elif self.data_type == 'shorts':
            v1 = self.s_spinbox_1.value()
            v2 = self.s_spinbox_2.value()

            self.save.set_bytes(v1, v2, self.save_id)

        elif self.data_type == 'booleans':
            booleans = []
            unformated_name = 'checkBox_{}'
            for i, value in enumerate(booleans):
                booleans.append(
                    getattr(self, unformated_name.format(i + 1)).isChecked())

            self.save.set_booleans(booleans, self.save_id)

    def update_label(self, label_dict):
        label_dict[str(hash(
            (self.save.i, self.save_id)))] = self.label_lineedit.text()

    def update_dtype(self, dtypes_dict):
        dtypes_dict[str(hash((self.save.i, self.save_id)))] = self.data_type
Beispiel #17
0
    class Game(DataContainer):

        fade_out_transition_when_starting_game = False

        current_map_id = SaveComponent(4)
        last_checkpoint = SaveComponent(5)
        last_checkpoints_map = SaveComponent(6)
        default_checkpoint_pos = (200, 300)

        heart_resource = 'special_objects/heart.obj'
        full_heart_state = 'full'
        empty_heart_state = 'empty'

        _x_offset = 30
        _y = 670
        _spacing = 40
        _number = 3

        heart_positions = [
            (x_offset + spacing * i, y)
            for (i, x_offset, spacing,
                 y) in zip(range(_number), [_x_offset] * _number, [_spacing] *
                           _number, [_y] * _number)
        ]

        maps = additional_data['game']['maps']

        death_screen_res_path = 'special_objects/death_screen.obj'

        class Triggers:
            ON_PLAYER_DEATH = 99000
            PREVIOUS_LEVEL = 98000
            NEXT_LEVEL = 98001
            BOTTOM_OF_WORLD_KILLBOX = 97000
            LOCK_CAMERA = 97001
            MOVE_CAMERA = 97002

        class PlayerDebugData(DataContainer):
            pos = [1100, 690]
            text = ("x velocity: {}\n" + "y velocity: {}\n" +
                    "x coordinate: {}\n" + "y coordinate: {}\n" +
                    "camera x: {}\n" + "camera y: {}\n" + "framerate: {}\n" +
                    "map id: {}\n" + "ground collisions: {}")

            values = [['player', 'position_handler', 'body', 'velocity', 'x'],
                      ['player', 'position_handler', 'body', 'velocity', 'y'],
                      ['player', 'position_handler', 'body', 'position', 'x'],
                      ['player', 'position_handler', 'body', 'position', 'y'],
                      ['camera_handler', 'x'], ['camera_handler', 'y'],
                      ['window', 'current_framerate'], ['current_map_id'],
                      [
                          'player', 'physic_state_updater',
                          'ground_collision_counter'
                      ]]

            color = "#ffffff"
            size = 18

        class BasePlayerData(DataContainer):
            height = 50
            width = 35
            name = "player"
            pos_x = SaveComponent(2)
            pos_y = SaveComponent(3)

            max_lives = 3
            current_lives = SaveComponent(7)

            jump_y_impulse = 500
            walking_max_velocity = 50
            running_max_velocity = 132
            air_control_max_velocity = 100
            acceleration = 33
            air_control_acceleration = 50
            dash_speed = 2000
            dash_length = 6  # in ticks

            on_death_trigger_id = 99000

            class StateDuration(DataContainer):
                idle = 0.034
                fall = 0.017
                jump = 0.017
                dash = 7 / 60
                land = 0.14

        class BaseBGData(DataContainer):
            camera_pos_x = SaveComponent(0)
            camera_pos_y = SaveComponent(1)
Beispiel #18
0
 def apply(self):
     for action_type, args in self.apply_additional_actions.items():
         getattr(self, action_type)(*args)
     self.apply_additional_actions = {}
     SaveComponent.dump()
     self.close_options()