def __init__(self, argparser): Arbapp.__init__(self, argparser) self.racket_size = int(self.width/3.) # Size of the racket in pixels self.ball_color = 'deeppink' self.racket_color = 'navy' self.command = {"left": False, "right": False} # User asks to move the racket to the left or right self.reset_game()
def __init__(self, parser, matrixes): Arbapp.__init__(self, parser) self.CHAR_COLORS = self.args.type self.BG_COLOR = 'black' # Matrix of matrixes. Each matrix represents a digit. self.matrixes = matrixes
def __init__(self, parser, animations): Arbapp.__init__(self, parser) config = animations[self.args.type] self.durations = [int(config['dur_min']*config['rate']), int(config['dur_max']*config['rate'])] self.rate = Rate(config['rate']) if config['colors'][-1]!=config['colors'][0]: config['colors'].append(config['colors'][0]) self.colors = config['colors'] self.generator = self.generators[config['generator_id']]
def __init__(self, num_lanes, path, level, speed): Arbapp.__init__(self) self.num_lanes = num_lanes self.score = 0 self.speed = float(speed) self.rate = Rate(self.speed) self.grid = [['background']*num_lanes for h in range(self.height)] # The coming notes (last line included even if it will overwritten by the bottom bar) self.bar = ['idle']*num_lanes # The bottom bar, idle = not pressed, hit = pressed during a note, pressed = pressed outside a note # Threads creation and starting self.renderer = Renderer(self.model, self.grid, self.bar, self.height, num_lanes, self.width) self.reader = SongReader(path, num_lanes, level, speed) self.sound = SoundManager(path) self.hits = UserHits(self.num_lanes)
def __init__(self, argparser): Arbapp.__init__(self, argparser, True) # starting mock mode, init flags (-w and -ng) will be redirected to the server init() joystick.init() self.joysticks = [] self.server_process = None # Joysticks initialization for i in range(joystick.get_count()): joy = joystick.Joystick(i) joy.init() if joy.get_numbuttons()>0: self.joysticks.append(joy) else: joy.quit() print len(self.joysticks), 'joystick(s) with buttons found!'
def __init__(self, argparser): Arbapp.__init__(self, argparser) self.chunk = 1024 self.parser = argparser self.renderer = None self.file = None print "Starting pyaudio..." self.pyaudio = pyaudio.PyAudio() ##### Fourier related attributes, we generate a suitable log-scale self.num_bands = self.width if self.args.vertical else self.height self.min = 50 self.max = 22050 #self.db_scale = [self.file.getframerate()*2**(b-self.num_bands) for b in range(self.num_bands)] #self.db_scale = [self.min+self.max*2**(b-self.num_bands+1) for b in range(self.num_bands)] self.db_scale = [self.max*(numpy.exp(-numpy.log(float(self.min)/self.max)/self.num_bands))**(b-self.num_bands) for b in range(1, self.num_bands+1)] print "Scale of maximum frequencies:", map(int, self.db_scale)
def __init__(self): Arbapp.__init__(self) self.grid = numpy.zeros([self.height, self.width], dtype=int) self.old_grid = deepcopy(self.grid) self.speed = 2 # Speed of tetromino fall in Hertz self.score = 0 self.playing = True self.tetromino = None self.command = {'left': False, 'right': False, 'down': False, 'rotate': False} # User commands (joy/keyboard) self.touchdown = False # True if the tetro has reached the floor pygame.init() pygame.joystick.init() for j in range(pygame.joystick.get_count()): joy = pygame.joystick.Joystick(j) joy.init() if joy.get_numhats()==0: joy.quit() # We can play only with joysticks having hats
def __init__(self, parser, rate): Arbapp.__init__(self, parser) self.balls = [] self.rate = Rate(rate) def rand(): return choice([-1, 1])*uniform(1./rate, 10./rate) for ball in range(4): self.balls.append(Ball(ball, randint(0, self.height-1), randint(0, self.width-1), self.height, self.width, Ball.colors[ball%len(Ball.colors)], rand(), rand())) # Motion control via Leap Motion self.swipe = [None] self.swipe_lock = Lock() self.leap_listener = SampleListener(self.swipe, self.swipe_lock) self.controller = Leap.Controller() self.controller.add_listener(self.leap_listener)
def __init__(self, port, argparser=None): Arbapp.__init__(self, argparser) self.bottle = Bottle() self.port = int(port) self.route()
def __init__(self, argparser): Arbapp.__init__(self, argparser) self.BG_COLOR = 'black' self.PIXEL_COLOR='darkred'
def close(self, reason='unknown'): Arbapp.close(self, reason) self.controller.remove_listener(self.leap_listener)
def __init__(self, argparser): Arbapp.__init__(self, argparser) self.image = None self.palette = None self.vertical = False
def __init__(self, argparser): Arbapp.__init__(self, argparser) self.video_reader = None
def __init__(self, argparser): Arbapp.__init__(self, argparser) self.port = str(self.args.port) self.context = zmq.Context() self.connection = None