Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions arcade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ def configure_logging(level: Optional[int] = None):
from .drawing_support import color_from_hex_string
from .drawing_support import float_to_byte_color

from .geometry_generic import get_distance
from .geometry_generic import rotate_point
from .geometry_generic import get_angle_degrees
from .geometry_generic import get_angle_radians

from .geometry import are_polygons_intersecting
from .geometry import is_point_in_polygon

# Complex imports with potential circularity
from .window_commands import close_window
from .window_commands import exit
Expand Down Expand Up @@ -176,7 +168,6 @@ def configure_logging(level: Optional[int] = None):
from .sprite import Sprite
from .sprite import SpriteCircle
from .sprite import SpriteSolidColor
from .sprite import get_distance_between_sprites

from .sprite_list import SpriteList
from .sprite_list import check_for_collision
Expand All @@ -185,6 +176,10 @@ def configure_logging(level: Optional[int] = None):
from .sprite_list import get_closest_sprite
from .sprite_list import get_sprites_at_exact_point
from .sprite_list import get_sprites_at_point
from .sprite_list import get_distance_between_sprites
from .sprite_list import get_sprites_in_rect

from .sprite_list import SpatialHash

from .scene import Scene

Expand Down Expand Up @@ -275,7 +270,6 @@ def configure_logging(level: Optional[int] = None):
'VERSION',
'View',
'Window',
'are_polygons_intersecting',
'astar_calculate_path',
'check_for_collision',
'check_for_collision_with_list',
Expand Down Expand Up @@ -315,11 +309,9 @@ def configure_logging(level: Optional[int] = None):
'finish_render',
'float_to_byte_color',
'get_closest_sprite',
'get_angle_degrees',
'get_angle_radians',
'get_display_size',
'get_distance',
'get_distance_between_sprites',
'get_sprites_in_rect',
'get_four_byte_color',
'get_four_float_color',
'get_controllers',
Expand All @@ -331,14 +323,14 @@ def configure_logging(level: Optional[int] = None):
'get_screens',
'get_sprites_at_exact_point',
'get_sprites_at_point',
'SpatialHash',
'get_timings',
'get_three_float_color',
'create_text_sprite',
'clear_timings',
'get_window',
'get_fps',
'has_line_of_sight',
'is_point_in_polygon',
'load_animated_gif',
'load_font',
'load_sound',
Expand All @@ -356,7 +348,6 @@ def configure_logging(level: Optional[int] = None):
'play_sound',
'read_tmx',
'load_tilemap',
'rotate_point',
'run',
'schedule',
'set_background_color',
Expand Down
5 changes: 3 additions & 2 deletions arcade/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import arcade
from arcade.types import Point
from arcade.math import get_distance

if TYPE_CHECKING:
from arcade import Sprite, SpriteList
Expand Down Expand Up @@ -477,8 +478,8 @@ def update(self) -> None:

# Calculate the angle our offset is at, and how far out
angle = math.atan2(ox, oy)
distance = arcade.get_distance(0, 0, ox, oy)
velocity_mag = arcade.get_distance(0, 0, vx, vy)
distance = get_distance(0, 0, ox, oy)
velocity_mag = get_distance(0, 0, vx, vy)

# Ok, what's the reverse? Pull it back in.
reverse_speed = min(self.shake_speed, distance)
Expand Down
2 changes: 1 addition & 1 deletion arcade/draw_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from arcade.types import Color, PointList
from arcade.earclip import earclip
from .geometry_generic import rotate_point
from .math import rotate_point
from arcade import (
get_four_byte_color,
get_points_for_thick_line,
Expand Down
2 changes: 1 addition & 1 deletion arcade/easing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from math import pi, sin, cos
from dataclasses import dataclass
from typing import Callable, Tuple
from .geometry_generic import get_distance
from .math import get_distance


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion arcade/examples/slime_invaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def setup(self):
self.enemy_list = arcade.SpriteList()
self.player_bullet_list = arcade.SpriteList()
self.enemy_bullet_list = arcade.SpriteList()
self.shield_list = arcade.SpriteList(is_static=True)
self.shield_list = arcade.SpriteList()

# Set up the player
self.score = 0
Expand Down
6 changes: 3 additions & 3 deletions arcade/examples/sprite_rotate_around_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
python -m arcade.examples.sprite_rotate_around_point
"""
import arcade

from arcade.math import rotate_point

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
Expand Down Expand Up @@ -38,12 +38,12 @@ def rotate_around_point(self, point, degrees, change_angle=True):
:param change_angle: Whether the sprite's angle should also be adjusted.
"""

# If changle_angle is true, change the sprite's angle
# If change_angle is true, change the sprite's angle
if change_angle:
self.angle += degrees

# Move the sprite along a circle centered on the point by degrees
self.position = arcade.rotate_point(
self.position = rotate_point(
self.center_x, self.center_y,
point[0], point[1], degrees)

Expand Down
21 changes: 13 additions & 8 deletions arcade/examples/sprite_rotate_around_tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
If Python and Arcade are installed, this example can be run from the command line with:
python -m arcade.examples.sprite_rotate_around_tank
"""
import math
import arcade
from arcade.types import Point
import math

from arcade.math import (
get_angle_radians,
rotate_point,
get_angle_degrees,
)

TANK_SPEED_PIXELS = 64 # How many pixels per second the tank travels
TANK_TURN_SPEED_DEGREES = 70 # How fast the tank's body can turn
Expand Down Expand Up @@ -68,7 +72,7 @@ def rotate_around_point(self, point: Point, degrees: float):
self.angle += degrees

# Move the sprite along a circle centered around the passed point
self.position = arcade.rotate_point(
self.position = rotate_point(
self.center_x, self.center_y,
point[0], point[1], degrees)

Expand Down Expand Up @@ -144,7 +148,7 @@ def move_tank(self, delta_time):
self.barrel.center_y + y_dir

# Begin rotating the barrel by finding the angle to the mouse
mouse_angle = arcade.get_angle_degrees(
mouse_angle = get_angle_degrees(
self.tank.center_y, self.tank.center_x,
self.mouse_pos[1], self.mouse_pos[0])

Expand Down Expand Up @@ -204,13 +208,14 @@ def correct(self, correct: bool):
"""
self._correct = correct
if correct:
angle = arcade.get_angle_radians(
angle = get_angle_radians(
self.tank.center_y, self.tank.center_x,
self.mouse_pos[1], self.mouse_pos[0])

self.barrel.position =\
self.barrel.center_x + math.cos(angle) * TANK_BARREL_LENGTH_HALF,\
self.barrel.center_y + math.sin(angle) * TANK_BARREL_LENGTH_HALF
self.barrel.position = (
self.barrel.center_x + math.cos(angle) * TANK_BARREL_LENGTH_HALF,
self.barrel.center_y + math.sin(angle) * TANK_BARREL_LENGTH_HALF,
)

else:
self.barrel.position = self.tank.position
Expand Down
2 changes: 1 addition & 1 deletion arcade/experimental/light_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, width, height, title):
self.time = 0
self.background = arcade.load_texture(":resources:images/backgrounds/abstract_1.jpg")

self.torch_list = arcade.SpriteList(is_static=True)
self.torch_list = arcade.SpriteList()
self.torch_list.extend([
arcade.Sprite(":resources:images/tiles/torch1.png", scale=0.4, center_x=100, center_y=150),
arcade.Sprite(":resources:images/tiles/torch1.png", scale=0.4, center_x=300, center_y=150),
Expand Down
15 changes: 0 additions & 15 deletions arcade/geometry.py

This file was deleted.

32 changes: 32 additions & 0 deletions arcade/geometry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
The geometry module contains functions for checking collisions with geometry.

Other simpler math related functions are in the :py:mod:`arcade.math` module.
"""
from .geometry_python import (
get_triangle_orientation,
are_lines_intersecting,
is_point_in_box,
)
try:
from .geometry_shapely import (
are_polygons_intersecting,
is_point_in_polygon,
)
shapely_installed = True
except ImportError:
from .geometry_python import (
are_polygons_intersecting,
is_point_in_polygon,
)
shapely_installed = False


__all__ = [
"are_polygons_intersecting",
"is_point_in_polygon",
"get_triangle_orientation",
"are_lines_intersecting",
"is_point_in_box",
"shapely_installed",
]
Loading