0

I'm doing a project for a year 11 physics class and I'm trying to make a battery that generates electrons. This is the code:

electron = sphere(radius = 1, color = color.yellow, vel = vec(-1,0,0)); while battery.voltage > 0: eb = electron.clone(pos=vec(0,0,0), vel = vec(-1,0,0));

I'm trying to make "eb" constantly, but it only applies eb.pos = eb.pos + eb.vel * deltat; apply to a the first electron. Is there any way to do this without making 600 different electron objects?

2 Answers2

0

You could change the attribute that is modified directly to the electron object instead of creating it all the time. Apply the modifications to electron and add the computing action in the while. Is it what you meant?

  • No, I wanted to make a lot of electrons constantly. So every second it makes an electron. I did the eb thing a while ago and am too lazy to change it, but it shouldn't make a difference. – Ethan Horton May 17 '17 at 19:58
0

You definitely need to make and move 600 sphere objects in order to have 600 sphere objects move. Your variable "eb" is just the name of the most recently made clone of the original sphere.

I'll advertise that a better place to pose VPython questions is in the VPython forum at

https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users

user1114907
  • 972
  • 8
  • 15