コード例 #1
0
ファイル: crash_results.py プロジェクト: numberQ/icarus
 def __init__(self):
     self.regular_font = pygame.font.Font(
         find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"),
         42)
     self.huge_font = pygame.font.Font(
         find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"),
         80)
コード例 #2
0
def _create_image(image_path, text, is_disabled, btn_image):
    font = pygame.font.Font(None, 30)
    # create a sprite from the given image path
    # and create the rect to blit the text onto
    # if this is for the pressed button, move the rect down to keep the text aligned
    sprite = pygame.sprite.Sprite()
    sprite.image = pygame.image.load(find_data_file(image_path))
    sprite.rect = sprite.image.get_rect()
    if "press" in image_path:
        sprite.rect.move_ip(0, 4)

    # render the text once here instead of every frame
    if text != "":
        if is_disabled:
            text_surf = font.render(text, 1, pygame.Color("gray"))
        else:
            text_surf = font.render(text, 1, pygame.Color("white"))
        # again, see how easy it is to center stuff using Rect's attributes like 'center'
        text_rect = text_surf.get_rect(center=sprite.rect.center)
        sprite.image.blit(text_surf, text_rect)

    if btn_image is not None:
        image = pygame.image.load(find_data_file(btn_image))
        rect = image.get_rect()
        rect.move_ip(-1, -4)
        sprite.image.blit(image, rect)
    return sprite.image
コード例 #3
0
ファイル: victory.py プロジェクト: numberQ/icarus
    def render(self, world):
        context = world.find_component("context")
        screen = context["screen"]

        # Draw a nice background
        screen.blit(
            pygame.image.load(find_data_file("resources/bg_space.png")),
            (0, 0))
        screen.blit(
            pygame.image.load(find_data_file("resources/bg_space.png")),
            (0, 500))

        # Moon's hot
        moon_sprite = pygame.sprite.Sprite()
        moon_sprite.image = pygame.image.load(
            find_data_file("resources/object_moon.png"))
        moon_sprite.rect = moon_sprite.image.get_rect()
        moon_sprite.rect.centerx = screen.get_width() / 2
        moon_sprite.rect.centery = screen.get_height() / 2 + 30
        screen.blit(moon_sprite.image, moon_sprite.rect)

        # Sub text backing box
        pygame.draw.rect(
            screen,
            (10, 10, 10),
            [
                screen.get_width() // 2 - 300,
                190 - 15 - 10,  # text y position - half font height - buffer
                600,
                50,
            ],
        )

        # Text
        self.victory_screen.draw(screen)

        # Icarus himself
        radius = 145
        radians = math.radians(self.angle)
        icarus_sprite = pygame.sprite.Sprite()
        icarus_sprite.image = pygame.image.load(
            find_data_file("resources/icarus_body.png"))
        rotated_image = pygame.transform.rotate(icarus_sprite.image,
                                                self.angle * -1 - 90)
        icarus_sprite.rect = rotated_image.get_rect()
        icarus_sprite.rect.centerx = (moon_sprite.rect.centerx +
                                      math.cos(radians) * radius)
        icarus_sprite.rect.centery = (moon_sprite.rect.centery +
                                      math.sin(radians) * radius)
        screen.blit(rotated_image, icarus_sprite.rect)

        # Rotate Icarus
        self.angle += 1
        self.angle %= 360

        # Display the buttons
        render_all_buttons(screen, world)
コード例 #4
0
ファイル: equip.py プロジェクト: octotep/icarus
 def __init__(self):
     self.font = pygame.font.Font(
         find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"), 36
     )
     self.big_font = pygame.font.Font(
         find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"), 58
     )
     self.icarus_offset = 0
     self.icarus_offset_increment = 1
コード例 #5
0
ファイル: victory.py プロジェクト: numberQ/icarus
    def __init__(self):
        self.victory_font = pygame.font.Font(
            find_data_file(
                "resources/atari-font/AtariFontFullVersion-ZJ23.ttf"), 100)
        self.regular_font = pygame.font.Font(
            find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"),
            30)
        self.victory_screen = pygame.sprite.Group()

        self.angle = 270
コード例 #6
0
ファイル: credits.py プロジェクト: numberQ/icarus
    def __init__(self):
        self.font = pygame.font.Font(
            find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"),
            36)
        self.atari_font = pygame.font.Font(
            find_data_file(
                "resources/atari-font/AtariFontFullVersion-ZJ23.ttf"), 20)
        self.arcade_font = pygame.font.Font(
            find_data_file(
                "resources/arcade-classic-font/ArcadeClassic-ov2x.ttf"), 26)

        self.scroll_offset = 0
コード例 #7
0
ファイル: title.py プロジェクト: octotep/icarus
 def __init__(self):
     self.title_font = pygame.font.Font(
         find_data_file(
             "resources/atari-font/AtariFontFullVersion-ZJ23.ttf"), 180)
     self.subtitle_font = pygame.font.Font(
         find_data_file(
             "resources/arcade-classic-font/ArcadeClassic-ov2x.ttf"), 52)
     self.regular_font = pygame.font.Font(
         find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"),
         36)
     self.icarus_offset = 0
     self.icarus_offset_increment = 1
コード例 #8
0
    def __init__(self):
        super().__init__()
        self.subscribe("sound")

        with open(find_data_file("resources/audio.json"), "r") as f:
            self.audio_table = json.load(f)

        self.audio_files = {}
        for (key, value) in self.audio_table.items():
            self.audio_files[key] = pygame.mixer.Sound(find_data_file(value))

        self.started_sounds = []
        self.previously_paused = False
        self.reduced_volume = 0.7
コード例 #9
0
    def reload(self):
        if not path.exists(find_data_file(self.motd_path)):
            warning(
                _("No MOTD file for {} found, pulling from web admin!").format(
                    self.server.name
                )
            )

            with open(self.motd_path, "w+") as motd_file:
                motd_file.write(self.server.web_admin.get_motd())

        motd_f = open(find_data_file(self.motd_path))
        motd = motd_f.read()
        motd_f.close()
        self.motd = motd
コード例 #10
0
def run(target=None):
    if args.target or target:
        server_path = args.target or target
    else:
        info(
            _("Please open your server's install folder in the file "
              "dialogue"))
        server_path = ask_dir()

    if not server_path:
        die(_("User cancelled installation"), pause=True)
    if not test_dir(server_path):
        die(_("Killing Floor 2 server not found in path:\n\t{}").format(
            server_path),
            pause=True)

    info(_("Validating files..."))
    target_path = path.join(server_path, "KFGame/Web/ServerAdmin")
    if not validate_files(target_path):
        die(_("Server file validation failed, possible reasons:"
              "\n\t - Game update"
              "\n\t - User mods"
              "\n\t - Patches already applied"),
            pause=True)

    info(_("Patching files..."))
    patches_path = find_data_file(PATCHES_PATH)

    if not patch_files(target_path, patches_path):
        die(_("Patching failed"), pause=True)
    else:
        print()  # \n
        info(_("Patches installed successfully!\n"))
コード例 #11
0
 def __init__(self, image_path, y):
     metadata = {
         "image": pygame.image.load(find_data_file(image_path)),
         "x": 0,
         "y": y,
     }
     Component.__init__(self, "background", metadata)
コード例 #12
0
ファイル: capturebasic.py プロジェクト: Kieleth/behave
    def __init__(self):
        self.timer = CvTimer()
        self.work_timer = CountdownTimer()
        #TODO:this should be configurable from gui
        self.frame_counter = FPSCounter(every=5)

        self.capturer = Capturer()
        self.frame_size = frame_width, frame_heigth = self.capturer.get_camera_width_heigth()
        #TODO: check the way to reduce the capture.
        print('capturing %sx%s' % (frame_width, frame_heigth)) 

        self.face_enforcer = enforcers.EnforceFaceLimits(say_warning)
        self.face_classifier = classifiers.CascadeClassifier(find_data_file('cascades/haarcascade_frontalface_alt.xml'))

        #Initialize GUI:
        self.gui = CX_Gui(window_name='behave', frame_size=self.frame_size, callback_obj=self)
        self.gui.initialize_gui()

        #Event hooks, they control the flow of the main loop:
        self._event_debug = False
        self._event_enforcing = True
        self._event_quit = False
        self._event_auto_limit = False
        self._event_image_show = True
        #_msg is used to get output from events
        self._event_msg = None

        #Auto-adjust protocol needs:
        self._auto_faces = []
        self._auto_num_faces = 5 #TODO: gui configurable
        self._auto_tilt = 10
コード例 #13
0
def main():
    # Initialize pygame before we do anything else
    pygame.init()

    programIcon = pygame.image.load(
        find_data_file("resources/icarus_icon.png"))
    pygame.display.set_icon(programIcon)

    # Initialize global systems in the game world
    if pygame.mixer.get_init() is not None:
        WORLD.register_system(AudioSystem())
    WORLD.register_system(ButtonSystem())

    # Load game metadata and store it in an entity
    settings = Component.load_from_json("settings")
    WORLD.gen_entity().attach(settings)

    # Set up the pygame window
    flags = pygame.SCALED
    screen = pygame.display.set_mode((settings["height"], settings["width"]),
                                     flags=flags,
                                     vsync=1)
    pygame.display.set_caption(settings["title"])

    # Store our dynamic resources that are created at runtime in the game world
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((200, 200, 200))

    context = ContextComponent(screen, pygame.time.Clock(), background)
    game = WORLD.gen_entity()
    game.attach(context)

    # Create a new Title screen object
    title_screen = TitleScene()

    # Initialize a SceneManager with our title screen
    manager = SceneManager(title_screen, WORLD)

    # BIG GAME LOOP
    while game["context"]["running"]:
        game["context"]["clock"].tick(60)

        # Process game wide events, most likely only QUIT
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                game["context"]["running"] = False

        # Update the current scene
        switch_event = manager.update(events, WORLD)

        # Render the current scene
        manager.render(WORLD)
        pygame.display.flip(
        )  # Double buffers whatever was on the screen object to the actual display

        # Finally switch scenes in the scene manager
        manager.switch(switch_event, WORLD)
コード例 #14
0
ファイル: game.py プロジェクト: numberQ/icarus
def create_plane(entity, position):
    entity.attach(CollectableComponent(300))
    entity.attach(PositionComponent(position[0], position[1]))
    entity.attach(RotationComponent(0))
    sprite = pygame.sprite.Sprite()
    sprite.image = pygame.image.load(find_data_file("resources/object_plane.png"))
    sprite.rect = sprite.image.get_rect(x=position[0], y=position[1])
    entity.attach(GraphicComponent(sprite))
コード例 #15
0
    def run_init(self):
        init_path = find_data_file("conf/scripts/" + self.server_name +
                                   ".init")

        if not path.exists(init_path):
            with open(init_path, 'w+') as script_file:
                script_file.write(INIT_TEMPLATE)

        self.execute_script(init_path)
コード例 #16
0
    def load_file(self, filename):
        path = find_data_file(self.folder + "/" + filename)
        if not os.path.isfile(path):
            return False

        with open(path) as file:
            lines = file.readlines()

        self.marquee = [line.strip() for line in lines]
        return True
コード例 #17
0
    def build_schema(self):
        info(_("Building new database..."))

        conn = sqlite3.connect(self.sqlite_db_file, isolation_level=None)
        cur = conn.cursor()

        with open(find_data_file('database/schema.sql')) as schema_file:
            lock.acquire(True)
            cur.executescript(schema_file.read())
            lock.release()

        conn.close()
コード例 #18
0
ファイル: title.py プロジェクト: octotep/icarus
    def render(self, world):
        context = world.find_component("context")

        screen = context["screen"]

        # Draw a nice background
        screen.blit(
            pygame.image.load(find_data_file("resources/bg_sky-space.png")),
            (0, 0))
        screen.blit(
            pygame.image.load(find_data_file("resources/bg_cityscape.png")),
            (0, 500))

        # Icarus himself
        sprite = pygame.sprite.Sprite()
        sprite.image = pygame.image.load(
            find_data_file("resources/icarus_body.png"))
        sprite.rect = sprite.image.get_rect()
        sprite.rect.centerx = 180
        sprite.rect.centery = screen.get_height() // 2 + 70 + (
            self.icarus_offset // 3)
        screen.blit(sprite.image, sprite.rect)

        # Moon's hot
        sprite = pygame.sprite.Sprite()
        sprite.image = pygame.image.load(
            find_data_file("resources/object_moon.png"))
        sprite.rect = sprite.image.get_rect()
        sprite.rect.centerx = screen.get_width()
        sprite.rect.centery = 20
        screen.blit(sprite.image, sprite.rect)

        # Blit the text to the screen over top of the background surface
        self.title_screen.draw(screen)

        self.icarus_offset = self.icarus_offset + self.icarus_offset_increment

        if abs(self.icarus_offset) > 10:
            self.icarus_offset_increment = self.icarus_offset_increment * -1
コード例 #19
0
    def __init__(self, name):
        self.sqlite_db_file = find_data_file(name + ".sqlite")

        if not path.exists(self.sqlite_db_file):
            self.build_schema()
        self.conn = sqlite3.connect(self.sqlite_db_file,
                                    check_same_thread=False)

        # Assemble rows into dicts (col->val) rather than tuples
        self.conn.row_factory = lambda c, r: \
            dict([(col[0], r[idx]) for idx, col in enumerate(c.description)])

        self.cur = self.conn.cursor()
コード例 #20
0
def patch_files(target_path, patches_path):
    for filename in os.listdir(target_path):
        if filename not in ORIG_MD5.keys():
            continue
        patch_path = find_data_file(
            os.path.join(patches_path, filename + ".patch")
        )

        info(_("Applying {}").format(filename + ".patch"))

        patch = fromfile(patch_path)
        success = patch.apply(0, target_path)
        if not success:
            warning(_("Patch failed to apply successfully"))
    return True
コード例 #21
0
    def execute(self, username, args, user_flags):
        args, err = self.parse_args(username, args, user_flags)
        if err:
            return err
        elif args.help:
            return self.format_response(self.help_text, args)

        if not args.file:
            return self.format_response("No script was specified", args)

        args.file = " ".join(args.file)
        script_path = find_data_file(self.scripts_folder + "/" + args.file)
        if not path.exists(script_path):
            return self.format_response("Script not found", args)

        self.chatbot.execute_script(script_path)
コード例 #22
0
ファイル: ecs.py プロジェクト: aforry/icarus
    def load_from_json(cls, filename) -> "Component":
        """
        Allows loading a Component from a JSON file.
        MUST contain a string "metatype" field, and an object "metadata" field.

        Example:
        {
            "metatype": "player",
            "metadata": {
                "name": "Craigory",
                "ac": 1000,
                ...
            }
        }

        :param filename: name of the JSON file, without the .json
        :return: a new Component instance using the usual construtor
        """
        with open(find_data_file(filename + ".json"), "r") as f:
            loaded_json = json.load(f)
            metatype = loaded_json["metatype"]
            metadata = loaded_json["metadata"]
            return Component(metatype, metadata)
コード例 #23
0
    def __init__(self, server, greeter_enabled=True, name=None):
        self.server_name = server.name
        if name:
            self.name = name
        else:
            self.name = "Unnamed"

        self.chat = server.web_admin.chat
        self.chat.add_listener(self)

        self.scheduler = CommandScheduler(server, self)
        self.chat.add_listener(self.scheduler)

        self.commands = CommandMap(server, self)
        self.silent = False
        self.greeter_enabled = True

        init_path = find_data_file(server.name + ".init")

        if path.exists(init_path):
            self.execute_script(init_path)
        else:
            with open(init_path, 'w+') as script_file:
                script_file.write(INIT_TEMPLATE)
コード例 #24
0
    def __init__(self, image_path):
        Sprite.__init__(self)

        self.image = pygame.image.load(find_data_file(image_path))
        self.rect = self.image.get_rect()
コード例 #25
0
ファイル: proc_capturer.py プロジェクト: Kieleth/behave
def cam_loop(q_frames, q_control, FPS, verboseprint):

    FRAME_TIME = 1.0 / FPS
    CAP = FPS

    capturer = Capturer(cam_width=200, cam_height=150)
    counter = circular_counter(CAP)

    face_classifier = classifiers.CascadeClassifier(find_data_file('cascades/haarcascade_frontalface_alt.xml'))
    face_classifier.set_params(minSize=(30,30), maxSize=(100,100))

    def detect_face_in_frame(a_frame):
        a_frame_prepared = equalize(a_frame)
        # watch out for detect_multiscale and the size of capture!
        faces_list = face_classifier.detect_multiscale(a_frame_prepared)

        return faces_list[0] if len(faces_list) == 1 else None

    def prepare_frame():
        frame = capturer.get_frame()
        if frame is not None:
            frame = flip_frame(frame)
            return convert_to_gray(frame)

    def send_frame_and_face():
        face = None
        frame = prepare_frame()
        # detect only every CAP'th frame
        if counter.next() == CAP:
            face = detect_face_in_frame(frame)
        q_frames.put((frame, face))

    def send_face():
        if counter.next() == CAP:
            face = None
            frame = prepare_frame()
            face = detect_face_in_frame(frame)
            q_frames.put((None, face))

    def delay_to_fps(start_time):
        # delay in the frame so the while runs at FPS-speed
        end_time = time.time()
        loop_took = end_time - start_time
        if loop_took < FRAME_TIME:
            verboseprint('frame delayed %s' % str(FRAME_TIME - loop_took))
            time.sleep(FRAME_TIME - loop_took)
 
    def main_loop():
        send_frame = True
        is_working = True

        while True:
            start_time = time.time()

            if not q_control.empty():
                control = q_control.get()
                if control == 'show_hide_camera':
                    verboseprint( 'show_hide received from gui')
                    send_frame = not send_frame
                if control == 'start_stop':
                    verboseprint( 'received start_stop from gui')
                    is_working = not is_working

            if is_working:
                if send_frame:
                    send_frame_and_face()
                else:
                    send_face()

            delay_to_fps(start_time)

    main_loop()
    print( 'cam_loop process is stopping...')
コード例 #26
0
    def __init__(self, server):
        self.server = server
        self.motd_path = find_data_file("conf/" + server.name + ".motd")

        self.motd = ""
        self.reload()
コード例 #27
0
ファイル: simulation_r3.py プロジェクト: lbkelly/j_acezero
    def default_scenario():

        return {
            'name': 'default',
            'tmin': 0.0,
            'umpire': {
                'triggers': [{
                    'class': 'umpires.triggers.MaxTimeElapsed',
                    'parameters': {
                        "max_time": 250.0
                    }
                }],
                "critics": [{
                    "class": "umpires.critics.GunScore",
                    "parameters": {
                        "name": "Viper Gun Score",
                        "subject": "viper",
                        "object": "cobra",
                        "min_range": 500,
                        "max_range": 3000.0,
                        "max_altitude": 500,
                        "max_speed": 100,
                        "max_angle": 30.0
                    }
                }, {
                    "class": "umpires.critics.GunScore",
                    "parameters": {
                        "name": "Cobra Gun Score",
                        "subject": "cobra",
                        "object": "viper",
                        "min_range": 500,
                        "max_range": 3000.0,
                        "max_altitude": 500,
                        "max_speed": 100,
                        "max_angle": 30.0
                    }
                }]
            },
            'dt': 0.1,
            # Basic Park ECU agent for transition evolution experiments
            # 'blue': {
            #     'initial': os.path.dirname(__file__) + r"\data\blue.json",
            #     'agent_class': 'agents.fsm_agent.ecu_stern_basic.EcuSternBasicAgent',
            #     'agent_parameters': os.path.dirname(__file__) + r"\data\ecu_basic_blue_tactics.json"},

            # ECU stern agent for transition evolution experiments
            # 'blue': {
            #     'initial': os.path.dirname(__file__) + r"\data\blue.json",
            #     'agent_class': 'agents.fsm_agent.ecu_stern_conversion.EcuSternConversionAgent',
            #     'agent_parameters': os.path.dirname(__file__) + r"\data\ecu_blue_tactics.json"},

            # Park ECU pure pursuit hardcoded agent
            # 'blue': {
            #     'initial': os.path.dirname(__file__) + r"\data\blue.json",
            #     'agent_class': 'agents.fsm_agent.park_ecu_pure.ParkEcuPure',
            #     'agent_parameters': None},

            # 'blue': {
            #     # 'initial': os.path.dirname(__file__) + r"\data\blue.json",
            #     # 'initial': os.path.dirname(sys.executable) + r"\blue.json",
            #     'initial': find_data_file("blue.json"),
            #     'agent_class': 'agents.fsm_agent.stern_conversion.SternConversionAgent',
            #     # 'agent_parameters': os.path.dirname(__file__) + r"\data\blue_tactics.json"},
            #     'agent_parameters': find_data_file("blue_tactics.json")},
            #
            # # Straight red
            # 'red': {
            #     # {'initial': os.path.dirname(__file__) + r"\data\red.json",
            #     'initial': find_data_file("red.json"),
            #     'agent_class': 'agents.fsm_agent.stern_conversion.SternConversionAgent',
            #     # 'agents.agent.Agent',
            #     # 'agent_parameters': os.path.dirname(__file__) + r"\data\red_tactics.json"}}
            #     'agent_parameters': find_data_file("red_tactics.json")}}

            # --------------------------ROUND One-----------------------------------

            # 'blue': {
            #     'initial': find_data_file("blue.json"),
            #     'agent_class': 'agents.fsm_agent.stern_conversion.SternConversionAgent',
            #     'agent_parameters': find_data_file("blue_tactics.json")},
            #
            # # Straight red
            # 'red': {
            #     'initial': find_data_file("red.json"),
            #     'agent_class': 'agents.fsm_agent.stern_conversion.SternConversionAgent',
            #     'agent_parameters': find_data_file("red_tactics.json")}}
            # --------------------------ROUND TWO-----------------------------------

            # 'blue': {
            #     'initial': find_data_file("blue.json"),
            #     'agent_class': 'agents.fsm_agent.ecu_stern_conversion.EcuSternConversionAgent',
            #     'agent_parameters': find_data_file("blue_tactics.json")},
            #
            # 'red': {
            #       'initial': find_data_file("red.json"),
            #         'agent_class': 'agents.fsm_agent.ecu_stern_conversion.EcuSternConversionAgent',  # 'agents.agent.Agent',
            #         'agent_parameters': find_data_file("red_tactics.json")}}

            # --------------------------ROUND THREE--------------------------------
            'blue': {
                'initial': find_data_file("blue.json"),
                'agent_class':
                'agents.fsm_agent.ecu_stern_basic_output.EcuSternBasicAgent',
                'agent_parameters': find_data_file("blue_tactics.json")
            },
            'red': {
                'initial': find_data_file("red.json"),
                'agent_class':
                'agents.fsm_agent.ecu_stern_basic.EcuSternBasicAgent',  #'agents.agent.Agent',
                'agent_parameters': find_data_file("red_tactics.json")
            }
        }
コード例 #28
0
ファイル: game.py プロジェクト: numberQ/icarus
    def setup(self, world):
        context = world.find_component("context")
        screen = context["screen"]

        # Create a sprite for the title
        self.help_message = pygame.sprite.Sprite()
        self.help_message.image = self.font.render(
            "Press space to start flying", 1, (240, 240, 240)
        )
        self.help_message.rect = self.help_message.image.get_rect(
            centerx=screen.get_width() // 2, centery=screen.get_height() // 2
        )

        # Player entity setup
        player_entity = world.gen_entity()
        player_entity.attach(
            GraphicComponent(PlayerSprite("resources/icarus_body.png"))
        )
        player_entity.attach(PositionComponent(160, 486))
        player_entity.attach(PhysicsComponent())
        player_entity.attach(RotationComponent(-20))
        player_entity.attach(PlayerComponent())
        player_entity.attach(GlidingComponent())
        player_entity.attach(GravityComponent())

        # Scrolling background - layers defined by the y coord
        world.gen_entity().attach(BackgroundComponent("resources/bg_space.png", -2540))
        world.gen_entity().attach(BackgroundComponent("resources/bg_space.png", -2040))
        world.gen_entity().attach(
            BackgroundComponent("resources/bg_sky-space.png", -1540)
        )
        world.gen_entity().attach(BackgroundComponent("resources/bg_sky.png", -1040))
        world.gen_entity().attach(BackgroundComponent("resources/bg_sky.png", -540))
        world.gen_entity().attach(BackgroundComponent("resources/bg_sky.png", -40))
        world.gen_entity().attach(
            BackgroundComponent("resources/bg_cityscape.png", 460)
        )

        # Create the camera
        camera_entity = world.gen_entity()
        camera_entity.attach(CameraComponent(player_entity.id))

        # Spawn the moon
        moon_entity = world.gen_entity()
        moon_entity.attach(PositionComponent(screen.get_width() - 100, -2500))
        moon_entity.attach(RotationComponent(0))
        moon_sprite = pygame.sprite.Sprite()
        moon_sprite.image = pygame.image.load(
            find_data_file("resources/object_moon.png")
        )
        moon_sprite.image.get_rect().x = moon_entity.position.x
        moon_sprite.image.get_rect().y = moon_entity.position.y
        moon_sprite.rect = moon_sprite.image.get_rect()
        moon_entity.attach(GraphicComponent(moon_sprite))
        moon_entity.attach(MoonComponent())

        # System registration
        self.systems = [
            PhysicsFrameResetSystem(),
            ForceSystem(),
            MovementSystem(),
            GlidingSystem(),
            CameraSystem(),
            CollectableSystem(),
            MoonSystem(),
        ]
        for sys in self.systems:
            world.register_system(sys)
コード例 #29
0
ファイル: game.py プロジェクト: numberQ/icarus
 def __init__(self):
     self.font = pygame.font.Font(
         find_data_file("resources/dpcomic-font/DpcomicRegular-p3jD.ttf"), 36
     )
コード例 #30
0
import configparser
import os
from getpass import getpass

from utils import die, fatal, find_data_file, info
from utils.net import resolve_address

CONFIG_PATH = find_data_file("./magicked_admin.conf")

SETTINGS_DEFAULT = {
    'server_name': 'server_one',
    # address = 127.0.0.1:8080
    # username = Admin
    # password = 123
    'game_password': '******',
    'motd_scoreboard': 'False',
    'scoreboard_type': 'Kills',
    'max_players': "6",
    'enable_greeter': "True",
    'dosh_threshold': "0",
}

SETTINGS_REQUIRED = [
    'address', 'password', 'motd_scoreboard', 'scoreboard_type',
    'dosh_threshold', 'max_players', 'enable_greeter'
]

CONFIG_DIE_MESG = "Please correct this manually  or delete '{}' to create a clean config next run.".format(
    CONFIG_PATH)

コード例 #31
0
gettext.bindtextdomain('magicked_admin', 'locale')
gettext.textdomain('magicked_admin')
gettext.install('magicked_admin', 'locale')

init()

parser = argparse.ArgumentParser(
    description=_('Killing Floor 2 Magicked Administrator')
)
parser.add_argument('-s', '--skip_setup', action='store_true',
                    help=_('Skips the guided setup process'))
args = parser.parse_args()

banner()

REQUESTS_CA_BUNDLE_PATH = find_data_file("./certifi/cacert.pem")

if hasattr(sys, "frozen"):
    import certifi.core

    os.environ["REQUESTS_CA_BUNDLE"] = REQUESTS_CA_BUNDLE_PATH
    certifi.core.where = REQUESTS_CA_BUNDLE_PATH

    import requests.utils
    import requests.adapters

    requests.utils.DEFAULT_CA_BUNDLE_PATH = REQUESTS_CA_BUNDLE_PATH
    requests.adapters.DEFAULT_CA_BUNDLE_PATH = REQUESTS_CA_BUNDLE_PATH


class MagickedAdmin:
コード例 #32
0
ファイル: equip.py プロジェクト: octotep/icarus
    def render(self, world):
        context = world.find_component("context")
        settings = world.find_component("settings")
        screen = context["screen"]

        player_entity = world.find_entity("player")

        # Draw a nice background
        screen.blit(pygame.image.load(find_data_file("resources/bg_sky.png")), (0, 0))
        screen.blit(pygame.image.load(find_data_file("resources/bg_sky.png")), (0, 500))

        # text
        text = self.font.render(
            f"Money for upgrades: ${player_entity.player.currency}",
            True,
            (245, 245, 245),
        )
        screen.blit(text, (50, 50))

        text = self.big_font.render("Legs:", True, (245, 245, 245))
        screen.blit(text, (120, 480))
        pygame.draw.line(screen, (245, 245, 245), (120, 531), (223, 531), width=8)

        text = self.font.render("Jet Booster", True, (245, 245, 245))
        screen.blit(text, (180, 572))
        if player_entity.player.hasJetBoots == 1:
            text = self.font.render("Owned", True, (245, 245, 245))
        else:
            text = self.font.render(
                f"Cost: ${settings['jetBootsCost']}", True, (245, 245, 245)
            )
        screen.blit(text, (180, 605))

        text = self.big_font.render("Arms:", True, (245, 245, 245))
        screen.blit(text, (640, 480))
        pygame.draw.line(screen, (245, 245, 245), (640, 531), (763, 531), width=8)

        text = self.font.render("Cloud Sleeves", True, (245, 245, 245))
        screen.blit(text, (700, 572))
        if player_entity.player.hasCloudSleeves == 1:
            text = self.font.render("Owned", True, (245, 245, 245))
        else:
            text = self.font.render(
                f"Cost: ${settings['cloudSleevesCost']}", True, (245, 245, 245)
            )
        screen.blit(text, (700, 605))

        text = self.font.render("Bird Wings", True, (245, 245, 245))
        screen.blit(text, (700, 672))
        if player_entity.player.hasWings == 1:
            text = self.font.render("Owned", True, (245, 245, 245))
        else:
            text = self.font.render(
                f"Cost: ${settings['wingsCost']}", True, (245, 245, 245)
            )
        screen.blit(text, (700, 705))

        # Icarus himself
        sprite = pygame.sprite.Sprite()
        sprite.image = pygame.image.load(find_data_file("resources/icarus_body.png"))
        sprite.image = pygame.transform.scale(sprite.image, (288, 200))
        sprite.rect = sprite.image.get_rect()
        sprite.rect.centerx = screen.get_width() // 2
        sprite.rect.centery = screen.get_height() // 2 - 240 + self.icarus_offset
        screen.blit(sprite.image, sprite.rect)

        # Display the buttons
        render_all_buttons(screen, world)

        # Flip display to render lines
        pygame.display.flip()

        self.icarus_offset = self.icarus_offset + self.icarus_offset_increment

        if abs(self.icarus_offset) > 10:
            self.icarus_offset_increment = self.icarus_offset_increment * -1