Simply puts the block on top of the stack numbered newPosition
(self, newPosition)
| 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 | |
| 215 | def parse(): |
| 216 | """Parses the user input, starting with the number of blocks""" |