예제 #1
0
파일: glide.py 프로젝트: ioanclarke/glide
def main():
    # Create engine and window
    window_width, window_height = get_window_size()
    title = GAME_TITLE
    game_window = arc.Window(window_width, window_height, title)
    menu_scr = menu.Menu()
    game_window.show_view(menu_scr)

    # Run the game
    arc.run()
예제 #2
0
파일: game.py 프로젝트: ioanclarke/glide
 def __init__(self):
     super().__init__()
     # Declare map variables
     self.level = 1
     self.eng = engine.Engine()
     self.width, self.height = gt.get_window_size()
     self.eng.create_player()
     self.wall_list = None
     self.finish_list = None
     self.player_list = None
     self.total_time = 0.0
     self.setup()
예제 #3
0
    def __init__(self):
        super().__init__()
        self.eng = Engine()
        self.width, self.height = gt.get_window_size()
        # Create player and put in location
        self.eng.create_player()
        self.eng.reset_player()

        # Load the map and physics engine
        self.eng.load_map_menu()

        # Load the walls and player
        self.wall_list = self.eng.wall_list
        self.play_list = self.eng.play_list
        self.quit_list = self.eng.quit_list
        self.player_list = self.eng.player_list
        bg_color = gt.choose_colour()
        arc.set_background_color(bg_color)
예제 #4
0
    def __init__(self, time_elapsed):
        super().__init__()
        self.time_elapsed = time_elapsed
        self.eng = Engine()

        self.width, self.height = gt.get_window_size()
        # Create player and put in location
        self.eng.create_player()
        self.eng.reset_player()

        # Load the map and physics engine
        self.eng.load_map_menu()

        # Load the walls and player
        self.wall_list = self.eng.wall_list
        self.play_list = self.eng.play_list
        self.quit_list = self.eng.quit_list
        self.player_list = self.eng.player_list
        arc.set_background_color(arc.color.LIGHT_YELLOW)
예제 #5
0
    def scrolling(self):
        changed = False
        window_width, window_height = gt.get_window_size()
        # Scroll left
        left_boundary = self.view_left + LEFT_VIEWPORT_MARGIN
        if self.player_sprite.left < left_boundary:
            self.view_left -= left_boundary - self.player_sprite.left
            changed = True

        # Scroll right
        right_boundary = self.view_left + window_width - RIGHT_VIEWPORT_MARGIN
        if self.player_sprite.right > right_boundary:
            self.view_left += self.player_sprite.right - right_boundary
            changed = True

        # Scroll up
        top_boundary = self.view_bottom + window_height - TOP_VIEWPORT_MARGIN
        if self.player_sprite.top > top_boundary:
            self.view_bottom += self.player_sprite.top - top_boundary
            changed = True

        # Scroll down
        bottom_boundary = self.view_bottom + BOTTOM_VIEWPORT_MARGIN
        if self.player_sprite.bottom < bottom_boundary:
            self.view_bottom -= bottom_boundary - self.player_sprite.bottom
            changed = True

        # Make sure our boundaries are integer values. While the view port does
        # support floating point numbers, for this application we want every pixel
        # in the view port to map directly onto a pixel on the screen. We don't want
        # any rounding errors.
        self.view_left = int(self.view_left)
        self.view_bottom = int(self.view_bottom)

        # If we changed the boundary values, update the view port to match
        if changed:
            arc.set_viewport(self.view_left,
                             window_width * 0.8 + self.view_left,
                             self.view_bottom,
                             window_height * 0.8 + self.view_bottom)
예제 #6
0
 def reset_player(self):
     window_width, window_height = gt.get_window_size()
     self.player_sprite.center_x = window_width / 3
     self.player_sprite.center_y = window_height / 2
     self.player_sprite.change_x = 0
     self.player_sprite.change_y = 0