コード例 #1
0
    def create_pipe(self):

        opennig_size_scale = random.randint(3, 6) * 0.40 * self.difficulty
        openning_y_middle =  random.normalvariate(GlobalVars.get_world_size().y / 2, sigma= 0.4)
        openning_y_upper = openning_y_middle - opennig_size_scale
        opennig_y_lower = openning_y_middle + opennig_size_scale
        self.last_created = (self.last_created + 1 ) % 2
        
        print("Middle: " + str(openning_y_middle), "Upper: " + str(openning_y_upper), "Lower:" + str(opennig_y_lower) )
        
        bottom_pipe =  Pipe(
                self.image,
                Vector2(
                    GlobalVars.get_world_size().x , 
                    opennig_y_lower),
                Rect(self.texture_offset, self.texture_size)
            ) 
            
        up_pipe =  Pipe(
                flip(self.image, False, True),
                Vector2(GlobalVars.get_world_size().x , openning_y_upper - (GlobalVars.get_world_size().y / 2)),
                Rect(self.texture_offset, self.texture_size)
            )

        return (up_pipe, bottom_pipe)
コード例 #2
0
ファイル: menu.py プロジェクト: egeyosunkaya/floppy-birdie
    def __init__(self, start_game_callback, quit_game_callback):
        self.menu = pygame_menu.Menu(int(GlobalVars.get_screen_size().x * 0.6),
                                     int(GlobalVars.get_screen_size().y * 0.6),
                                     'Floppy Birdie',
                                     theme=pygame_menu.themes.THEME_BLUE)

        self.menu.add_button("Start", start_game_callback)
        self.menu.add_button("Quit", quit_game_callback)
コード例 #3
0
 def __init__(self):
     self.world_size = GlobalVars.get_world_size()
     self.bird_state = BirdState()
     self.background_state = BackgroundState()
     self.collision_checker = CollisionChecker(self.background_state, self.bird_state)
     self.is_alive = True
     self.score = 0
コード例 #4
0
 def update(self):
     for pipe_tuple in self.pipe_list:
         for pipe in pipe_tuple:
             pipe.location += Vector2(-1,0).elementwise() * self.velocity_scale
     
     if self.pipe_list[-1][0].location.x < GlobalVars.get_world_size().x - self.pipe_offset_x:
         self.pipe_list.append(
             self.pipe_factory.create_pipe()
         )
     
     if self.pipe_list[0][0].location.x < - 4:
         self.pipe_list.pop(0)
コード例 #5
0
ファイル: amazonframe.py プロジェクト: eddie-c/amaproj
    def __init__(self, master):
        self.master = master
        self.queue = Manager().Queue()
        # GuiPart.setmainframe(master)

        # print GuiPart.getmainframe()
        self.gui = GuiPart(master, self.queue, self.endApplication)
        # GuiPart.maingui = master
        gvars = GlobalVars(master)
        # GlobalVars.mainframe = master
        self.running = True
        # self.thread1=threading.Thread()
        # self.thread1.start()
        self.periodicCall()
コード例 #6
0
 def __init__(self):
     pygame.init()
     
     pygame.display.set_caption("Floppy Birdie")
     self.clock = pygame.time.Clock()
     self.game_state = GameState()
     self.move_command =  None
     self.cell_size = GlobalVars.get_cell_size()
     self.game_window = pygame.display.set_mode(
         (int(self.cell_size.x * self.game_state.world_size.x), 
         int(self.cell_size.y * self.game_state.world_size.y))
         )
     self.running = True
     self.game_status = GameStatus.START_MENU
     self.window_size = self.game_state.world_size.elementwise() * self.cell_size
     self.game_menu = Menu(self.start_game, self.quit_game)
コード例 #7
0
    def __init__(self, extension = '.qp'):
        super(self.__class__, self).__init__()
        self.setupUi(self)
        self.setFixedSize(self.size())
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self._initialize_defaults()
        self.gv = GlobalVars()
        self.new_file = ''
        self.extension = extension

        # Connecting the signals and slots
        self.create_qp_push_button.clicked.connect(self.create_qp_clicked)
        self.cancel_push_button.clicked.connect(self.cancel_qp_clicked)
        self.qp_path_tool_button.clicked.connect(self.qp_path_clicked)
        self.qp_filename_line_edit.textChanged.connect(self.filename_line_edit_changed)
        self.qp_path_line_edit.textChanged.connect(self.path_line_edit_changed)
コード例 #8
0
    def check_collision(self):

        # Pipe - Bird Collision
        for pipe_tuple in self.background_state.pipe_list:
            for pipe in pipe_tuple:
                if pipe.get_collision_box().colliderect(
                        self.bird_state.get_collision_box()):
                    print("Collision detected")
                    return True

        # Bird Out of bounds check
        out_of_bounds_pixel_tolerance = 10
        bird_coll_box = self.bird_state.get_collision_box()
        if bird_coll_box.bottom > GlobalVars.get_screen_size().y + out_of_bounds_pixel_tolerance \
            or bird_coll_box.top < 0 - out_of_bounds_pixel_tolerance:
            print("Out of bounds deteced")
            return True

        return False
コード例 #9
0
    def get_collision_box(self):

        return self.sprite.get_bounding_rect(min_alpha=1).move(self.location.elementwise() * GlobalVars.get_cell_size())
        # return Rect(
        #     (self.location + Vector2(1.3, 0)).elementwise() * GlobalVars.get_cell_size(),
        #     (self.texture_rect.size[0] * 0.375, self.texture_rect.size[1] * 0.9)
        # )
コード例 #10
0
 def __init__(self):
     self.sprite = pygame.transform.scale(pygame.image.load("assets/background.jpg"),
         (int(GlobalVars.get_screen_size().x), int(GlobalVars.get_screen_size().y)),
      )
     self.location = Vector2(0,0)
     self.texture_rect = Rect(0, 0, 768, 512)
コード例 #11
0
    def get_collision_box(self):

        return self.bird_sprite.get_bounding_rect(min_alpha=1).move(self.bird_position.elementwise() * GlobalVars.get_cell_size())

            
コード例 #12
0
ファイル: mainwindow.py プロジェクト: Halicea/hal_automator
 def get_config_path(self):
   global_vars = GlobalVars.get_instance()
   global_vars.current_config_path=os.path.join(config_path, self.cmb_brands.currentText(), self.cmb_platforms.currentText(),"bc.json")      
   return global_vars.current_config_path
コード例 #13
0
ファイル: mainwindow.py プロジェクト: codechem/hal_automator
 def get_config_path(self):
     global_vars = GlobalVars.get_instance()
     global_vars.current_config_path = os.path.join(
         config_path, self.cmb_brands.currentText(),
         self.cmb_platforms.currentText(), "bc.json")
     return global_vars.current_config_path