""" May it be a light for you in dark places, when all other lights go out.
"""
+import time
+
import pymunk
import pymunk.pygame_util
import pygame.draw
-from .constants import SCREEN_SIZE, LIGHT_CATEGORY
+from .constants import SCREEN_SIZE, LIGHT_CATEGORY, DEBUG
LIGHT_FILTER = pymunk.ShapeFilter(
mask=pymunk.ShapeFilter.ALL_MASKS ^ LIGHT_CATEGORY,
"""
w, h = SCREEN_SIZE
left, right, bottom, top = 0, w, 0, h
- for y in range(h):
+ step = 1
+ for y in range(0, h, step):
yield pymunk.Vec2d(left, y)
- for x in range(w):
+ for x in range(0, w, step):
yield pymunk.Vec2d(x, top)
- for y in range(top, -1, -1):
+ for y in range(top, -1, -step):
yield pymunk.Vec2d(right, y)
- for x in range(right, -1, -1):
+ for x in range(right, -1, -step):
yield pymunk.Vec2d(x, bottom)
def calculate_ray_polys(space, body, position):
+ start_time = time.time()
position = pymunk.Vec2d(position)
vertices = [position]
ray_polys = []
ray_polys.append(new_poly)
if len(vertices) > 2:
ray_polys.append(pymunk.Poly(body, vertices))
- print "NUM POLYS: ", len(ray_polys)
+ end_time = time.time()
+ if DEBUG:
+ print(
+ "calculate_ray_polys: %d polys, %g seconds" %
+ (len(ray_polys), end_time - start_time))
return ray_polys