예제 #1
0
    def update_position(self):
        """Update the position and reduce the velocity."""
        self.x += self.momentum_x
        self.y += self.momentum_y
        self.momentum_x *= constants.DRAG
        self.momentum_y *= constants.DRAG

        self.x = check_bounds(self.x, pyxel.width, constants.BUFFER)
        self.y = check_bounds(self.y, pyxel.height, constants.BUFFER)
예제 #2
0
    def update(self):
        """Update the position and rotate."""
        self.x += self.vel_x
        self.y += self.vel_y

        self.vel_x *= constants.SHIP_BREAKUP_DRAG
        self.vel_y *= constants.SHIP_BREAKUP_DRAG

        self.x = check_bounds(self.x, pyxel.width, constants.BUFFER)
        self.y = check_bounds(self.y, pyxel.height, constants.BUFFER)

        self.rotate(self.spin)
    def update(self):
        """Update the position and rotation of the asteroid. Also checks bounds."""

        rotation_angle = constants.ASTEROID_ROTATION * self.spin_direction

        for point in self.points:
            point.rotate_point(rotation_angle)

        x_vol, y_vol = self.velocity
        self.x += x_vol
        self.y += y_vol

        self.x = check_bounds(self.x, pyxel.width, constants.ASTEROID_BUFFER)
        self.y = check_bounds(self.y, pyxel.height, constants.ASTEROID_BUFFER)