From: Lenore H. <lh...@si...> - 2009-09-12 11:26:46
|
Sorry. I was in too big a hurry and forgot to paste the code. Here it is. I've put arrows off to the right indicating the lines where both air.acceleration and pixie.acceleration are being changed despite the fact that only air.acceleration appears in the code. I've included all of the while loop. I don't see anywhere that I'm reassigning pixie.acceleration from its original value of gravity but it changes as soon as it hits those to statements (and not before). Thanks, Lenore angle = math.pi/4 speed = 13.0 power = 2 constant = 1 gravity = vector(0,-9.8,0) launch_velocity = vector(speed*math.cos(angle),speed*math.sin(angle),0) pixie = sphere(pos=vector(-9,-3.55,0), radius=0.2, color=color.red) pixie.velocity = launch_velocity pixie.acceleration = gravity air = sphere(pos=vector(-9,-3.55,0.3), radius=0.15, color=color.blue) air.velocity = launch_velocity air.acceleration = gravity scene.mouse.getclick() # Don't launch until we're watching dt = 0.01 while 1: rate(100) air.pos = air.pos + air.velocity*dt if air.y < -3.55: air.velocity = vector(0,0,0) else: air.velocity = air.velocity + air.acceleration*dt air.acceleration.y = gravity.y - sign(air.velocity.y) * constant * air.radius * air.velocity.y**power <----- print "5", air.acceleration, pixie.acceleration air.acceleration.x = -sign(air.velocity.x) * constant * air.radius * air.velocity.x**power <------- print "6", air.acceleration, pixie.acceleration pixie.pos = pixie.pos + pixie.velocity*dt if pixie.y < -3.55: pixie.velocity = vector(0,0,0) else: pixie.velocity = pixie.velocity + pixie.acceleration*dt On Sep 11, 2009, at 18:20 , Bruce Sherwood wrote: > Can you explain the context of your question? I have no idea what > program or > documentation you're referring to. > > Bruce Sherwood > > Lenore Horner wrote: >> Perhaps I'm just blind, but I can't figure out why the assignment >> statements above print "5" and print "6" affect both acceleration >> vectors, but they do. How do I change the acceleration vector of one >> object without touching the vector of other objects? >> >> Thanks, >> Lenore > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |