예제 #1
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)
예제 #2
0
 def __init__(self, target_entity_id):
     metadata = {
         "target_entity_id": target_entity_id,
         "x": 0,
         "y": 0,
     }
     Component.__init__(self, "camera", metadata)
예제 #3
0
 def __init__(self, xvel=0, yvel=0, xaccel=0, yaccel=0):
     metadata = {
         "xvel": xvel,
         "yvel": yvel,
         "xaccel": xaccel,
         "yaccel": yaccel
     }
     Component.__init__(self, "movement", metadata)
예제 #4
0
 def __init__(self, screen, clock, background):
     metadata = {
         "screen": screen,
         "clock": clock,
         "background": background,
         "running": True,
         "paused": False,
     }
     Component.__init__(self, "context", metadata)
예제 #5
0
 def __init__(self):
     metadata = {
         "has_jumped": False,
         "currency": 0,
         "hasCloudSleeves": 0,
         "hasWings": 0,
         "hasJetBoots": 0,
     }
     Component.__init__(self, "player", metadata)
예제 #6
0
 def __init__(self):
     metadata = {
         "has_jumped": False,
         "jumping": False,
         "currency": 0,
         "hasCloudSleeves": 0,
         "hasWings": 0,
         "hasJetBoots": 0,
         "extraFuel": 0,
         "maxBoosts": 0,
         "numBoosts": 0,
     }
     Component.__init__(self, "player", metadata)
예제 #7
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)
예제 #8
0
 def __init__(
     self,
     rect,
     text="",
     callback=None,
     is_small=False,
     is_disabled=False,
     image=None,
 ):
     if is_small:
         normal_image = _create_image("resources/shop_btn_inactive.png",
                                      text, is_disabled, image)
         hover_image = _create_image("resources/shop_btn_hover.png", text,
                                     is_disabled, image)
         clicked_image = _create_image("resources/shop_btn_press.png", text,
                                       is_disabled, image)
         disabled_image = _create_image("resources/shop_btn_locked.png",
                                        text, is_disabled, image)
     else:
         normal_image = _create_image("resources/btn_inactive.png", text,
                                      is_disabled, image)
         hover_image = _create_image("resources/btn_hover.png", text,
                                     is_disabled, image)
         clicked_image = _create_image("resources/btn_press.png", text,
                                       is_disabled, image)
         disabled_image = _create_image("resources/btn_locked.png", text,
                                        is_disabled, image)
     metadata = {
         "normal": normal_image,
         "hover": hover_image,
         "clicked": clicked_image,
         "disabled": disabled_image,
         "rect": rect,
         "text": text,
         "active": False,
         "isMouseDown": False,
         "isDisabled": is_disabled,
         "callback": callback,
     }
     Component.__init__(self, "button", metadata)
예제 #9
0
 def __init__(self):
     Component.__init__(self, "gravity", {})
예제 #10
0
 def __init__(self):
     Component.__init__(self, "gliding", {})
예제 #11
0
 def __init__(self, angle):
     metadata = {"angle": angle}
     Component.__init__(self, "rotation", metadata)
예제 #12
0
 def __init__(self):
     metadata = {"velocity": 0, "angle": 0, "acceleration": 0}
     Component.__init__(self, "physics", metadata)
예제 #13
0
 def __init__(self, x, y):
     metadata = {"x": x, "y": y}
     Component.__init__(self, "position", metadata)
예제 #14
0
 def __init__(self, sprite):
     metadata = {"sprite": sprite}
     Component.__init__(self, "graphic", metadata)
예제 #15
0
파일: game.py 프로젝트: numberQ/icarus
 def __init__(self):
     Component.__init__(self, "moon", {})
예제 #16
0
파일: game.py 프로젝트: numberQ/icarus
 def __init__(self, worth):
     metadata = {
         "worth": worth,
     }
     Component.__init__(self, "collectable", metadata)