def on_key_down(self, event): key = event.key self.set_direction(event) # set direction rate(self.__cube.fps) if key == self.__x_key: self.__cube.turn_x(random.randint(0, 3), self.__direction) elif key == self.__y_key: self.__cube.turn_y(random.randint(0, 3), self.__direction) elif key == self.__z_key: self.__cube.turn_z(random.randint(0, 3), self.__direction) rate(self.__cube.fps)
def turn_z(self, event): rate(self.__cube.fps) self.__cube.turn_z(self.__index, self.__direction) rate(self.__cube.fps)
import Controller from LedCube import LedCube from visual_common import create_display # # # # MAIN means start the application --> HERE <-- # # # # # initialize led_cube and controller led_cube = LedCube() Controller.start(led_cube) # vpython bs while True: # caps the vpython framerate to 60fps create_display.rate(60)