def _update(self, x, y, nx, ny): debug(msg='updating cache').flush() self.x = x self.y = y self.nx = nx self.ny = ny dx = self.x / self.nx dy = self.y / self.ny points = [ ] for i in range(nx): points.append([i*dx, 0.0, 0.0]) points.append([i*dx, y, 0.0]) points.append([x, 0.0, 0.0]) points.append([x, y, 0.0]) for i in range(ny): points.append([0.0, i*dy, 0.0]) points.append([x, i*dy, 0.0]) points.append([0, y, 0.0]) points.append([x, y, 0.0]) print('(x={}, y={})'.format(self.x, self.y)) print('(nx={}, ny={})'.format(self.nx, self.ny)) print('len(points)={}'.format(len(points))) self.buffer = Buffer(points) self.buffer.renderMode('lines')
def check_for_collision(self, pos): debug().flush() self.dragging = False for obj in self.tracked_objects: if obj.region.contains(pos): setattr(obj, 'active', True) self.dragging = True self.active = { 'object': obj } elif hasattr(obj, 'active'): delattr(obj, 'active')
def add_object(self, obj): debug().add('object', obj).flush() self.tracked_objects.append(obj) debug(indent=1).add('tracked objects', len(self.tracked_objects))