def rotate(self, forward=True): "rotate this maze. If forward, the XY dimensions move forward in RGB. Else, backward." # modify blocks and size rotate1 = lambda block: geo.rotate1(block, forward) newblocks = {} for (block, value) in self.blocks.items(): newblocks[rotate1(block)] = value self.blocks = newblocks self.size = rotate1(self.size) self.goalpos = rotate1(self.goalpos)
def rotate(self, forward=True): "Rotate the maze forward one dimension." rotate1 = lambda block: geo.rotate1(block, forward) self.lab.rotate(forward) self.player.pos = rotate1(self.player.pos) # also, change motion and animation motion (small utility for that) def update1(motion): "rotate a motion's direction" if not motion: return motion dim, n = motion if forward: dim = (dim+1) % self.lab.ndim else: dim = (dim-1 + self.lab.ndim) % self.lab.ndim return (dim, n) self.player.motion = update1(self.player.motion) anim = self.player.animation if anim: anim.dim, anim.mov = update1((anim.dim, anim.mov)) # also, rotate the GUI (needed for color management) self.gui.rotate()
def rotate(self, forward=True): "rotate the various vectors inside the color manager" self.colorstep = geo.rotate1(self.colorstep, forward)