Platform: Windows-11-10.0.26200-SP0
System: Windows
System Version: 10.0.26200
Processor: Intel64 Family 6 Model 154 Stepping 3, GenuineIntel SSE2: Yes AVX2: Yes NEON: No
Architecture: Bits: 64bit Linkage: WindowsPE
Python: CPython 3.13.2 (main, Mar 17 2025, 21:04:07) [MSC v.1943 64 bit (AMD64)]
GIL Enabled: True
pygame version: 2.5.6
SDL versions: Linked: 2.32.10 Compiled: 2.32.10
SDL Mixer versions: Linked: 2.8.1 Compiled: 2.8.1
SDL Font versions: Linked: 2.24.0 Compiled: 2.24.0
SDL Image versions: Linked: 2.8.8 Compiled: 2.8.8
Freetype versions: Linked: 2.11.1 Compiled: 2.11.1
Display Driver: Display Not Initialized
Mixer Driver: Mixer Not Initialized
It should return points (of floats) (thus be a truthy list).
import pygame
win = pygame.display.set_mode((100, 100), pygame.SCALED)
clock = pygame.time.Clock()
rect = pygame.FRect((0, 0), (0, 0))
line = [(0, 0), (0, 0)]
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
rect.topleft = (event.pos[0] / 100, event.pos[1] / 100)
if event.button == 3:
line[0] = (event.pos[0] / 100, event.pos[1] / 100)
if pygame.mouse.get_pressed()[0]:
rect.size = (
event.pos[0] / 100 - rect.left,
event.pos[1] / 100 - rect.top,
)
if pygame.mouse.get_pressed()[2]:
line[1] = (event.pos[0] / 100, event.pos[1] / 100)
win.fill("black")
color = "red" if not bool(rect.clipline(line)) else "green"
pygame.draw.rect(
win,
color,
(rect.left * 100, rect.top * 100, rect.width * 100, rect.height * 100),
width=1,
)
pygame.draw.line(
win,
color,
(line[0][0] * 100, line[0][1] * 100),
(line[1][0] * 100, line[1][1] * 100),
)
pygame.display.flip()
clock.tick(60)
The code above translates the window space to a "world" space (values between (0-1, 0-1)), performs collision check and then renders the rect and the line scaled to the window space.
Environment:
Current behavior:
Collision using
bool(FRect.clipline(line))showsFalseeven when rect collides line.Expected behavior:
It should return points (of floats) (thus be a truthy list).
Test code
The code above translates the window space to a "world" space (values between (0-1, 0-1)), performs collision check and then renders the rect and the line scaled to the window space.