Skip to content

Commit

Permalink
Updates for Arcade 3.0 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleptomania committed Oct 7, 2024
1 parent 76cafd3 commit ba33d96
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions python/arcade_accelerate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def patch_math(patches):
patches["arcade.math"].rand_angle_spread_deg = (
arcade_accelerate.rand_angle_spread_deg
)
patches["arcade.math"].rand_vec_degree_spread = (
arcade_accelerate.rand_vec_degree_spread
patches["arcade.math"].rand_vec_spread_deg = (
arcade_accelerate.rand_vec_spread_deg
)
patches["arcade.math"].rand_vec_magnitude = arcade_accelerate.rand_vec_magnitude
patches["arcade.math"].quaternion_rotation = arcade_accelerate.quaternion_rotation
Expand Down
2 changes: 1 addition & 1 deletion src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub fn is_point_in_polygon(x: f32, y: f32, polygon: Vec<(f32, f32)>) -> bool {
// segment 'i-next', then check if it lies
// on segment. If it lies, return true, otherwise false
if get_triangle_orientation(polygon[i], p, polygon[next_item]) == 0 {
return !is_point_in_box(polygon[i], p, polygon[next_item]);
return is_point_in_box(polygon[i], p, polygon[next_item]);
}

count += 1
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn arcade_accelerate(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(math::rand_on_line, m)?)?;
m.add_function(wrap_pyfunction!(math::rand_angle_360_deg, m)?)?;
m.add_function(wrap_pyfunction!(math::rand_angle_spread_deg, m)?)?;
m.add_function(wrap_pyfunction!(math::rand_vec_degree_spread, m)?)?;
m.add_function(wrap_pyfunction!(math::rand_vec_spread_deg, m)?)?;
m.add_function(wrap_pyfunction!(math::rand_vec_magnitude, m)?)?;
m.add_function(wrap_pyfunction!(math::quaternion_rotation, m)?)?;
m.add_function(wrap_pyfunction!(geometry::are_polygons_intersecting, m)?)?;
Expand Down
8 changes: 4 additions & 4 deletions src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ pub fn get_angle_radians(x1: f32, y1: f32, x2: f32, y2: f32) -> f32 {
}

#[pyfunction]
pub fn rand_in_rect(bottom_left: (f32, f32), width: f32, height: f32) -> (f32, f32) {
pub fn rand_in_rect(rect: (f32, f32, f32, f32, f32, f32, f32, f32)) -> (f32, f32) {
let mut rng = thread_rng();

let random_x: f32 = rng.gen_range(bottom_left.0..bottom_left.0 + width);
let random_y: f32 = rng.gen_range(bottom_left.1..bottom_left.1 + height);
let random_x: f32 = rng.gen_range(rect.0..=rect.1);
let random_y: f32 = rng.gen_range(rect.2..=rect.3);

(random_x, random_y)
}
Expand Down Expand Up @@ -159,7 +159,7 @@ pub fn rand_angle_spread_deg(angle: f32, half_angle_spread: f32) -> f32 {
}

#[pyfunction]
pub fn rand_vec_degree_spread(angle: f32, half_angle_spread: f32, length: f32) -> (f32, f32) {
pub fn rand_vec_spread_deg(angle: f32, half_angle_spread: f32, length: f32) -> (f32, f32) {
let a = rand_angle_spread_deg(angle, half_angle_spread);
let vel = _Vec2::from_polar(a, length);
vel.as_tuple()
Expand Down

0 comments on commit ba33d96

Please sign in to comment.