コード例 #1
0
ファイル: color.py プロジェクト: andrewgalisa/mousetrap
    def calc_move(self):
        if not hasattr(self, "vpoint"):
            return False

        x, y = mouse.position()
        """
        # If the difference between the new point and the last point is less than the threshold:
        if -self.threshold < self.point.rel_diff.x < self.threshold or -self.threshold < self.point.rel_diff.y < self.threshold:
            self.same_location_count+=1
            # If the point has been in the same location for more than 5 frames:
            if self.same_location_count > 5:
                mouse.move(x,y) # Leave the mouse in the same location
                return False
        """
        par = ["width", "height"]

        new_x, new_y = [
            (float(poss) / self.vscreen[par[i]]) * env.screen[par[i]]
            for i, poss in enumerate([(self.vscreen["width"] / 2) -
                                      (self.center["x"] - self.vpoint["x"]),
                                      (self.vscreen["height"] / 2) -
                                      (self.center["y"] - self.vpoint["y"])])
        ]

        mouse.move(new_x, new_y)
コード例 #2
0
ファイル: screen.py プロジェクト: kevin-brown/mousetrap
    def calc_move(self):
        if not hasattr(self, "vpoint"):
            return False

        x, y = mouse.position()

        par = ["width", "height"]

        new_x, new_y = [ (float(poss)/self.vscreen[par[i]])*env.screen[par[i]]
                          for i,poss in enumerate([ (self.vscreen["width"]/2) - ( self.center["x"] - self.vpoint["x"]),
                                                    (self.vscreen["height"]/2) - ( self.center["y"] - self.vpoint["y"] ) ])]

        mouse.move( new_x, new_y)
コード例 #3
0
    def calc_move(self):
        if not hasattr(self, "vpoint"):
            return False

        x, y = mouse.position()

        par = ["width", "height"]

        new_x, new_y = [
            (float(poss) / self.vscreen[par[i]]) * env.screen[par[i]]
            for i, poss in enumerate([(self.vscreen["width"] / 2) -
                                      (self.center["x"] - self.vpoint["x"]),
                                      (self.vscreen["height"] / 2) -
                                      (self.center["y"] - self.vpoint["y"])])
        ]

        mouse.move(new_x, new_y)
コード例 #4
0
ファイル: joystick.py プロジェクト: andrewgalisa/mousetrap
    def calc_move(self):
        if not hasattr(self, "vpoint"):
            return False

        x, y = mouse.position()

        par = ["width", "height"]

        if self.vpoint["x"] > (self.safe_area["x"] + 20):
            x = x + abs((self.safe_area["x"] + 20) - self.vpoint["x"])
        elif self.vpoint["x"] < self.safe_area["x"]:
            x = x - abs((self.safe_area["x"]) - self.vpoint["x"])

        if self.vpoint["y"] > (self.safe_area["y"] + 20):
            y = y + abs((self.safe_area["y"] + 20) - self.vpoint["y"])
        elif self.vpoint["y"] < self.safe_area["y"]:
            y = y - abs((self.safe_area["y"]) - self.vpoint["y"])

        mouse.move(x, y)
コード例 #5
0
ファイル: joystick.py プロジェクト: amberheilman/mousetrap
    def calc_move(self):
        if not hasattr(self, "vpoint"):
            return False
        
        x, y = mouse.position()

        par = ["width", "height"]
        
        if self.vpoint["x"] > (self.safe_area["x"] + 20):
            x = x + abs((self.safe_area["x"] + 20) - self.vpoint["x"]) 
        elif self.vpoint["x"] < self.safe_area["x"]: 
            x = x - abs((self.safe_area["x"]) - self.vpoint["x"])
            
        if self.vpoint["y"] > (self.safe_area["y"] + 20):
            y = y + abs((self.safe_area["y"] + 20) - self.vpoint["y"])
        elif self.vpoint["y"] < self.safe_area["y"]: 
            y = y - abs((self.safe_area["y"]) - self.vpoint["y"])
            
        
        mouse.move( x, y)
コード例 #6
0
ファイル: color.py プロジェクト: amberheilman/mousetrap
    def calc_move(self):
        if not hasattr(self, "vpoint"):
            return False

        x, y = mouse.position()
        """
        # If the difference between the new point and the last point is less than the threshold:
        if -self.threshold < self.point.rel_diff.x < self.threshold or -self.threshold < self.point.rel_diff.y < self.threshold:
            self.same_location_count+=1
            # If the point has been in the same location for more than 5 frames:
            if self.same_location_count > 5:
                mouse.move(x,y) # Leave the mouse in the same location
                return False
        """
        par = ["width", "height"]

        new_x, new_y = [ (float(poss)/self.vscreen[par[i]])*env.screen[par[i]]
                      for i,poss in enumerate([ (self.vscreen["width"]/2) - ( self.center["x"] - self.vpoint["x"]),
                                                (self.vscreen["height"]/2) - ( self.center["y"] - self.vpoint["y"] ) ])]

        mouse.move( new_x, new_y)