Friday, July 6, 2007

Autofields working with shapes for activation

I've recently finished enabling activation of fields by collision. Of course, this requires that both the field and any bodies it must effect. Fields with no shape apply to all bodies in the scene, as before. Here's an example, available in the tests directory as collide_field.py.
from time import sleep
import soy
sce = soy.Scene()
cam = soy.bodies.Camera(sce)
cam.position = (0,0,13)
py1 = soy.bodies.Pyramid(sce)
py1.position = (-2,0,0)
py1.shape = soy.shapes.Sphere(1)
py1.velocity = (0,0.7,0)
py2 = soy.bodies.Pyramid(sce)
py2.position = (0,0,0)
py2.shape = soy.shapes.Sphere(1)
py2.velocity = (0,0.7,0)
py3 = soy.bodies.Pyramid(sce)
py3.position = (2,0,0)
py3.shape = soy.shapes.Sphere(1)
py3.velocity = (0,0.7,0)
scr = soy.Screen()
win = soy.Window(scr, size=(640,480))
pro = soy.widgets.Projector(win, size=(640,480), camera=cam)
m = soy.bodies.fields.Monopole(sce)
m.position=(3,4.8,0)
m.shape=soy.shapes.Sphere(4.4)
m.multiplier=4

You should notice the pyramids being repelled by interesecting an invisible sphere.

1 comment:

Pedro Luz said...

Hi,

I've tryed that code... but grrr no luck :P

Traceback (most recent call last):
File "start.py", line 16, in module
cam.position(0,0,13)
TypeError: 'tuple' object is not callable