Skip to content

Commit c16bb67

Browse files
authored
Merge branch 'main' into line_collidepolygon
2 parents a4d80a2 + 39ee131 commit c16bb67

File tree

13 files changed

+680
-217
lines changed

13 files changed

+680
-217
lines changed

.github/workflows/macos_test.yml

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,28 @@ name: macOS latest
22

33
on: [ push, pull_request ]
44

5-
env:
6-
TEMP_FIX_PYGAME_VERSION: 2.1.3.dev8
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
78

89
jobs:
9-
Python_37:
10+
Python:
1011
runs-on: macos-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
1115
steps:
1216
- uses: actions/checkout@v3.0.2
13-
- name: Install Python 3.7
14-
run: |
15-
brew install python@3.7
16-
- name: Install dependencies
17-
run: |
18-
brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf pkg-config
19-
python3 -m pip install setuptools -U
20-
python3 -m pip install pygame==$TEMP_FIX_PYGAME_VERSION
21-
python3 -m pip install .
22-
- name: Run Tests
23-
run: python3 -m unittest
24-
25-
Python_38:
26-
runs-on: macos-latest
27-
steps:
28-
- uses: actions/checkout@v3.0.2
29-
- name: Install Python 3.8
30-
run: |
31-
brew install python@3.8
32-
- name: Install dependencies
33-
run: |
34-
brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf pkg-config
35-
python3 -m pip install setuptools -U
36-
python3 -m pip install pygame==$TEMP_FIX_PYGAME_VERSION
37-
python3 -m pip install .
38-
- name: Run Tests
39-
run: python3 -m unittest
40-
41-
Python_39:
42-
runs-on: macos-latest
43-
steps:
44-
- uses: actions/checkout@v3.0.2
45-
- name: Install Python 3.9
46-
run: |
47-
brew install python@3.9
48-
- name: Install dependencies
49-
run: |
50-
brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf pkg-config
51-
python3 -m pip install setuptools -U
52-
python3 -m pip install pygame==$TEMP_FIX_PYGAME_VERSION
53-
python3 -m pip install .
54-
- name: Run Tests
55-
run: python3 -m unittest
56-
57-
Python_310:
58-
runs-on: macos-latest
59-
steps:
60-
- uses: actions/checkout@v3.0.2
61-
- name: Install Python 3.10
62-
run: |
63-
brew install python@3.10
17+
- name: Install Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ matrix.python-version }}
6421
- name: Install dependencies
6522
run: |
6623
brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf pkg-config
67-
python3 -m pip install setuptools -U
68-
python3 -m pip install pygame==$TEMP_FIX_PYGAME_VERSION
69-
python3 -m pip install .
24+
python -m pip install setuptools -U
25+
python -m pip install pygame-ce
26+
python -m pip install .
7027
- name: Run Tests
71-
run: python3 -m unittest
72-
73-
Python_311:
74-
runs-on: macos-latest
75-
steps:
76-
- uses: actions/checkout@v3.0.2
77-
- name: Install Python 3.11
7828
run: |
79-
brew install python@3.11
80-
- name: Install dependencies
81-
run: |
82-
brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf pkg-config
83-
python3 -m pip install setuptools -U
84-
python3 -m pip install pygame==$TEMP_FIX_PYGAME_VERSION
85-
python3 -m pip install .
86-
- name: Run Tests
87-
run: python3 -m unittest
29+
python -m unittest

.github/workflows/ubuntu_test.yml

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,96 +2,31 @@ name: Ubuntu latest
22

33
on: [ push, pull_request ]
44

5-
jobs:
6-
Python_37:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- uses: actions/checkout@v3.0.2
10-
- name: Update package list
11-
run: sudo apt-get update
12-
- name: Add Deadsnakes PPA
13-
run: sudo add-apt-repository ppa:deadsnakes/ppa
14-
- name: Install Python 3.7
15-
run: sudo apt-get install -y python3.7
16-
- name: Install dependencies
17-
run: |
18-
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config -y
19-
python3 -m pip install --upgrade pip
20-
python3 -m pip install pygame
21-
python3 -m pip install .
22-
- name: Run Tests
23-
run: python3 -m unittest
24-
- name: Remove Deadsnakes PPA
25-
run: |
26-
sudo add-apt-repository --remove ppa:deadsnakes/ppa
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
278

28-
Python_38:
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v3.0.2
32-
- name: Update package list
33-
run: sudo apt-get update
34-
- name: Add Deadsnakes PPA
35-
run: sudo add-apt-repository ppa:deadsnakes/ppa
36-
- name: Install Python 3.8
37-
run: sudo apt-get install -y python3.8
38-
- name: Install dependencies
39-
run: |
40-
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config -y
41-
python3 -m pip install --upgrade pip
42-
python3 -m pip install pygame
43-
python3 -m pip install .
44-
- name: Run Tests
45-
run: python3 -m unittest
46-
- name: Remove Deadsnakes PPA
47-
run: |
48-
sudo add-apt-repository --remove ppa:deadsnakes/ppa
499

50-
Python_39:
51-
runs-on: ubuntu-latest
52-
steps:
53-
- uses: actions/checkout@v3.0.2
54-
- name: Install Python 3.9
55-
run: |
56-
sudo apt-get update
57-
sudo apt-get install python3.9
58-
- name: Install dependencies
59-
run: |
60-
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config -y
61-
python3 -m pip install setuptools -U
62-
python3 -m pip install pygame
63-
python3 -m pip install .
64-
- name: Run Tests
65-
run: python3 -m unittest
66-
Python_310:
67-
runs-on: ubuntu-latest
68-
steps:
69-
- uses: actions/checkout@v3.0.2
70-
- name: Install Python 3.10
71-
run: |
72-
sudo apt-get update
73-
sudo apt-get install python3.10
74-
- name: Install dependencies
75-
run: |
76-
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config -y
77-
python3 -m pip install setuptools -U
78-
python3 -m pip install pygame
79-
python3 -m pip install .
80-
- name: Run Tests
81-
run: python3 -m unittest
82-
Python_311:
10+
jobs:
11+
Python:
8312
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
8416
steps:
8517
- uses: actions/checkout@v3.0.2
86-
- name: Install Python 3.11
18+
- name: Install Python
8719
run: |
20+
# Add the deadsnakes PPA to install python
21+
sudo add-apt-repository ppa:deadsnakes/ppa
8822
sudo apt-get update
89-
sudo apt-get install python3.11
23+
sudo apt-get install python${{ matrix.python-version }}-dev
24+
sudo apt-get install python${{ matrix.python-version }}-distutils
9025
- name: Install dependencies
9126
run: |
9227
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config -y
93-
python3 -m pip install setuptools -U
94-
python3 -m pip install pygame
95-
python3 -m pip install .
28+
python${{ matrix.python-version }} -m pip install setuptools -U
29+
python${{ matrix.python-version }} -m pip install pygame-ce
30+
python${{ matrix.python-version }} -m pip install .
9631
- name: Run Tests
97-
run: python3 -m unittest
32+
run: python${{ matrix.python-version }} -m unittest

.github/workflows/windows_test.yml

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,23 @@ name: Windows latest
22

33
on: [ push, pull_request ]
44

5-
jobs:
6-
Python_37:
7-
runs-on: windows-latest
8-
steps:
9-
- uses: actions/checkout@v3.0.2
10-
- name: Install packages
11-
run: |
12-
py -3.7 -m pip install --upgrade pip
13-
py -3.7 -m pip install pygame
14-
py -3.7 -m pip install .
15-
- name: Run Tests
16-
run: py -3.7 -m unittest
17-
18-
Python_38:
19-
runs-on: windows-latest
20-
steps:
21-
- uses: actions/checkout@v3.0.2
22-
- name: Install packages
23-
run: |
24-
py -3.8 -m pip install --upgrade pip
25-
py -3.8 -m pip install pygame
26-
py -3.8 -m pip install .
27-
- name: Run Tests
28-
run: py -3.8 -m unittest
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
298

30-
Python_39:
31-
runs-on: windows-latest
32-
steps:
33-
- uses: actions/checkout@v3.0.2
34-
- name: Install packages
35-
run: |
36-
py -3.9 -m pip install --upgrade pip
37-
py -3.9 -m pip install pygame
38-
py -3.9 -m pip install .
39-
- name: Run Tests
40-
run: py -3.9 -m unittest
41-
42-
Python_310:
9+
jobs:
10+
Python:
4311
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
4415
steps:
4516
- uses: actions/checkout@v3.0.2
4617
- name: Install packages
4718
run: |
48-
py -3.10 -m pip install --upgrade pip
49-
py -3.10 -m pip install pygame
50-
py -3.10 -m pip install .
19+
py -${{ matrix.python-version }} -m pip install --upgrade pip
20+
py -${{ matrix.python-version }} -m pip install pygame-ce
21+
py -${{ matrix.python-version }} -m pip install .
5122
- name: Run Tests
52-
run: py -3.10 -m unittest
23+
run: py -${{ matrix.python-version }} -m unittest
5324

54-
Python_311:
55-
runs-on: windows-latest
56-
steps:
57-
- uses: actions/checkout@v3.0.2
58-
- name: Install packages
59-
run: |
60-
py -3.11 -m pip install --upgrade pip
61-
py -3.11 -m pip install pygame==2.1.3.dev8
62-
py -3.11 -m pip install .
63-
- name: Run Tests
64-
run: py -3.11 -m unittest

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ purpose of this repository is to help users integrate
1414
special colliders easier for their video game.
1515

1616
**Everything you see in this repository is subject to change as
17-
this project is heavily in development.** This decision is also
18-
subject to change when this project migrates to the
19-
[official pygame repository](https://github.com/pygame/pygame) or
20-
becomes a third-party library.
17+
this project is heavily in development.** The project is set to be migrated to the
18+
[official pygame-ce repository](https://github.com/pygame-community/pygame-ce).
2119

2220
## Installation (Python 3.7+)
2321
Please follow [this guide](https://github.com/novialriptide/pygame_geometry/blob/main/CONTRIBUTING.md)

docs/geometry.rst

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ other objects.
108108

109109
scale_ip: Scales the line by the given amount in place.
110110

111+
flip: Switches the endpoints of the line.
112+
113+
flip_ip: Switches the endpoints of the line in place.
114+
111115
update: Updates the line's attributes.
112116

113117
copy: Returns a copy of the line.
@@ -124,6 +128,8 @@ other objects.
124128

125129
collideswith: Checks if the line collides with the given object.
126130

131+
as_circle: Returns a circle which fully encloses the line.
132+
127133
Additionally to these, the line shape can also be used as a collider for the ``geometry.raycast`` function.
128134

129135
Polygon
@@ -219,4 +225,28 @@ such as raycasting and general utility functions.
219225
which represent the top left, top right, bottom right, and bottom left corners
220226
of the rectangle, respectively.
221227

222-
.. ## geometry.rect_to_polygon ##
228+
.. ## geometry.rect_to_polygon ##
229+
230+
.. method:: multiraycast
231+
232+
| :sl:`Returns a list of intersection points between a sequence of rays and a sequence of colliders`
233+
| :sg:`multiraycast(rays, colliders) -> [(x, y) | None]`
234+
235+
This function returns a list of intersection points between a sequence of
236+
rays and a sequence of colliders.
237+
The rays parameter is a sequence that can be composed of the following objects:
238+
239+
- Line objects.
240+
- Tuples of: origin point, angle, max_dist.
241+
- Tuples of: origin point, direction, max_dist.
242+
- Tuples of: origin point, end point.
243+
244+
Apart from Lines, which have fixed length, the rays can have any length,
245+
including infinite length. To define an infinite ray, set the max_dist parameter
246+
to a negative value. The max_dist parameter cannot be set to 0.
247+
The colliders can be any sequence of objects such as Circle, Line, or Rect.
248+
249+
The function returns a list of tuples containing the closest intersection point to
250+
the ray's origin, or None if it couldn't find one.
251+
252+
.. ## geometry.multiraycast ##

docs/line.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Line Methods
216216
.. method:: flip
217217

218218
| :sl:`flips the line a and b points`
219-
| :sg:`flip(axis) -> Line`
219+
| :sg:`flip() -> Line`
220220
221221
Returns a new `Line` that has the `a` and `b` points flipped.
222222
The original `Line` is not modified.
@@ -226,7 +226,7 @@ Line Methods
226226
.. method:: flip_ip
227227

228228
| :sl:`flips the line a and b points, in place`
229-
| :sg:`flip_ip(axis) -> None`
229+
| :sg:`flip_ip() -> None`
230230
231231
Flips the `Line`'s `b` and `b` points. The original `Line` is modified.
232232
Always returns None.
@@ -339,6 +339,20 @@ Line Methods
339339
If a shape is passed it must be an actual single shape object. It cannot be a
340340
tuple or list of coordinates that represent the shape. This is because there
341341
is no way to determine what type of shape the coordinates represent.
342+
343+
.. ## Line.collideswith ##
344+
345+
346+
.. method:: as_circle
347+
348+
| :sl:`returns a circle that extends over the line`
349+
| :sg:`as_circle() -> Circle`
350+
351+
Returns a `Circle` object, with the center point being the center point of the `Line`,
352+
and the diameter being the length of the `Line`.
353+
354+
.. ## Line.as_circle ##
355+
342356
343357
.. method:: at
344358

0 commit comments

Comments
 (0)