def fire_laser(self, x, y, rot): """Add a laser beam to the game""" x_vel = sin(radians(rot)) y_vel = -cos(radians(rot)) self.laser_beams.append( LaserBeam(self.SPACE, x, y, x_vel, y_vel) )
def test_constructor(): # Test minimal required constructor args a = LaserBeam(params['SPACE'], params['x'], params['y'], params['x_vel'], params['y_vel'], params['lifespan']) assert a.SPACE['w'] == 100 and \ a.SPACE['h'] == 200 and \ a.x_vel == params['x_vel'] * a.LASER_SPEED_FACTOR and \ a.y_vel == params['y_vel'] * a.LASER_SPEED_FACTOR and \ a.x == params['x'] + params['x_vel'] and \ a.y == params['y'] + params['y_vel'] and \ hasattr(a, "radius") and \ hasattr(a, "lifespan") and \ hasattr(a, "diam")