Beispiel #1
0
 def __init__(self, frames_map, raw=True):
     if raw:
         for frames_tag, frames_path in frames_map.items():
             # Convert paths in matrix set
             frames_map[frames_tag] = read_matrix_from_file(frames_path)
     self.frames_map = frames_map
     self.renderer_object = RendererObject()
     self.center_hor = False
     self.parent_screen_object = None
Beispiel #2
0
class ScreenObjectModel(object):
    def __init__(self, frames_map, raw=True):
        if raw:
            for frames_tag, frames_path in frames_map.items():
                # Convert paths in matrix set
                frames_map[frames_tag] = read_matrix_from_file(frames_path)
        self.frames_map = frames_map
        self.renderer_object = RendererObject()
        self.center_hor = False
        self.parent_screen_object = None

    def on_render(self):
        if self.center_hor:
            self.parent_screen_object.pos_x = int(
                (self.parent_screen_object.screen.size_x / 2) - (self.renderer_object.size_x / 2))

    def set_current_frames(self, key):
        self.renderer_object.model_matrix_frames = self.frames_map[key]
        self.renderer_object.reset_animation_frame_counter()

    def get_renderer_object(self):
        return self.renderer_object
Beispiel #3
0
        print("#", end="")
        for drawer in range(self.screen_x):
            print("-", end="")
        print("#")

    def update_screen(self):
        self.screen_matrix.clear()


if __name__ == "__main__":
    frames_matrix_go_right = read_matrix_from_file("models/example_right.model")
    frames_matrix_go_left = read_matrix_from_file("models/example_left.model")

    renderer = Renderer()

    demo_object = RendererObject(0, 0)
    renderer.renderer_objects.append(demo_object)
    go_right = True
    while True:
        # Walk logic
        if demo_object.pos_x == 0:
            go_right = True
            demo_object.set_model_matrix_frames(frames_matrix_go_right)
        if demo_object.pos_x == renderer.screen_x - 19:
            go_right = False
            demo_object.set_model_matrix_frames(frames_matrix_go_left)

        if go_right:
            demo_object.pos_x += 1
        else:  # go left
            demo_object.pos_x -= 1