MCPcopy Create free account
hub / github.com/ActiveState/code / moveTo

Method moveTo

recipes/Python/361168_Vpython_example/recipe-361168.py:195–213  ·  view source on GitHub ↗

Simply puts the block on top of the stack numbered newPosition

(self, newPosition)

Source from the content-addressed store, hash-verified

193 self.label = label(pos=array(self.box.pos) + array([0,0,1]), text=str(position), opacity=0, box=0, line=0)
194
195 def moveTo(self, newPosition):
196 """Simply puts the block on top of the stack numbered newPosition"""
197 Block.moveTo(self, newPosition)
198 # Now animate our movement
199 height = 0
200 for block in self.stack:
201 if block is self: break
202 else: height -= 1
203 start = array(self.box.pos)
204 end = array((newPosition-(self.stacks.blockCount/2), height, 0))
205 # Move in 30 steps
206 step = array((end - start) / 30.)
207 for i in range(1,31):
208 self.box.pos = start + (step * i)
209 self.label.pos = start + (step * i) + array([0,0,1])
210 rate(120)
211 self.box.pos = end
212 self.label.pos = end + array([0,0,1])
213 print self.box.pos
214
215def parse():
216 """Parses the user input, starting with the number of blocks"""

Callers

nothing calls this directly

Calls 3

rangeFunction · 0.85
arrayClass · 0.50
moveToMethod · 0.45

Tested by

no test coverage detected