Пример #1
0
 def __init__(self, argparser):
     Application.__init__(
         self, argparser, True
     )  # starting mock mode, init flags (-w and -ng) will be redirected to the server
     self.server_process = None
     self.running = True
     signal(SIGINT, self.close_processes)
Пример #2
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.base_color = None
     self.color = (1.0, 1.0, 1.0)
     # relative coordonate to image center
     self.y = self.height / 2
     self.x = self.width / 2
     # offset from
     self.offset_y = 0
     self.offset_x = 0
     self.model.set_all('white')
     self.state = 'init'
     self.spawns = []
     self.speed = 1
     self.fade = 1
     self.vector = None
     self.color_level = [0] * 6
     self.last_spawn_color = 0
     # Treating arguments
     parser = argparser.parse_args()
     self.invader = parser.invader
     self.ai = parser.auto
     self.file = parser.pattern
     if (self.file == ''):
         self.image = Image.new('RGB', size, (255, 255, 255))
     else:
         self.image = Image.open(self.file)
         self.image = self.image.resize(size)
Пример #3
0
    def __init__(self, touch_mode='quadridirectional'):
        Application.__init__(self, touch_mode=touch_mode)
        self.pierres = []

        self.bomb1 = Bomb((0, 0), 1)
        self.bomb2 = Bomb((0, 0), 2)
        self.bomb3 = Bomb((0, 0), 3)
        self.bomb4 = Bomb((0, 0), 4)
        self.bomb5 = Bomb((0, 0), 1)
        self.bomb6 = Bomb((0, 0), 2)
        self.bomb7 = Bomb((0, 0), 3)
        self.bomb8 = Bomb((0, 0), 4)
        self.bomb9 = Bomb((0, 0), 1)
        self.bomb10 = Bomb((0, 0), 2)
        self.bomb11 = Bomb((0, 0), 3)
        self.bomb12 = Bomb((0, 0), 4)

        self.slotbombs = [
            self.bomb1, self.bomb2, self.bomb3, self.bomb4, self.bomb5,
            self.bomb6, self.bomb7, self.bomb8, self.bomb9, self.bomb10,
            self.bomb11, self.bomb12
        ]
        self.bombs = []
        for i in range(1, self.height, 2):
            for j in range(self.width):
                if (j == 1 or j == 3 or j == 6 or j == 8):
                    self.pierres.append((i, j))

        self.p1 = Player((14, 5), 1, 'cyan')
        self.p2 = Player((0, 4), 2, 'darkblue')
        self.p3 = Player((6, 0), 3, 'green')
        self.p4 = Player((8, 9), 4, 'purple')
Пример #4
0
 def __init__(self, parser, animations):
     Application.__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'])
     self.colors = config['colors']
     self.generator = self.generators[config['generator_id']]
Пример #5
0
 def __init__(self):
     Application.__init__(self)
     self.PIECE = (8, 4)
     self.TABJEU = [[0] * 7 for _ in range(6)]
     self.DIRECTION = (0, 0)
     self.fin = False
     self.rate = Rate(self.RATE_SPEED)
     self.player_actu = True
Пример #6
0
 def __init__(self, argparser, touch_mode='quadridirectional'):
     Application.__init__(self, argparser, touch_mode=touch_mode)
     self.DIRECTION = DOWN
     self.HEAD = (5, 5)
     self.queue = [self.HEAD]
     self.FOOD_POSITIONS = {}
     self.rate = 2
     self.rate_increase = self.args.speed
     self.start_food = self.args.food
Пример #7
0
 def __init__(self):
     Application.__init__(self)
     pygame.init()
     self.fin = False
     self.games = ['pong','puissance4','tetris']
     self.indiceGame = 0
     self.choix = self.games[self.indiceGame]
     self.PLATEAU_COLOR = 'blue'
     self.launch = False
Пример #8
0
 def __init__(self, argparser, touch_mode='quadridirectional'):
     Application.__init__(self, argparser, touch_mode=touch_mode)
     self.DIRECTION=DOWN
     self.HEAD=(5,5)
     self.queue=[self.HEAD]
     self.FOOD_POSITIONS={}
     self.rate=2
     self.rate_increase=self.args.speed
     self.start_food=self.args.food
Пример #9
0
 def __init__(self, parser, animations):
     Application.__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'])
     self.colors = config['colors']
     self.generator = self.generators[config['generator_id']]
Пример #10
0
 def __init__(self, port, argparser=None):
     Application.__init__(self, argparser)
     self.port = int(port)
     self.flask = Flask(__name__)
     logging.basicConfig(level=logging.DEBUG)
     self.current_auth_nick = self.OFF 
     self.nicknames = {}
     self.lock = RLock()
     CORS(self.flask)
     self.loop = None
     self.route()
Пример #11
0
 def __init__(self, port, argparser=None):
     Application.__init__(self, argparser)
     self.port = int(port)
     self.flask = Flask(__name__)
     logging.basicConfig(level=logging.DEBUG)
     self.current_auth_nick = self.OFF 
     self.nicknames = {}
     self.lock = RLock()
     CORS(self.flask)
     self.loop = None
     self.route()
Пример #12
0
 def __init__(self):
     Application.__init__(self, touch_mode='quadridirectional')
     self.score = 0
     self.t0 = time.time()
     self.playing = True
     self.command = {
         'left': False,
         'right': False,
         'down': False
     }  # User commands (joy/keyboard)
     self.breakout = Breakout(self.arbalet.height, self.arbalet.width)
Пример #13
0
 def __init__(self):
     Application.__init__(self, touch_mode='quadridirectional')
     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
     self.music = Music()
Пример #14
0
    def __init__(self, argparser):
        Application.__init__(self, argparser)
        self.parser = argparser
        self.renderer = None
        self.framerate = 44100

        ##### 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.framerate*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:", list(map(int, self.db_scale)))
Пример #15
0
    def __init__(self, argparser, num_lanes, path, speed):
        Application.__init__(self, argparser, touch_mode='columns')
        self.arbalet.touch.set_keypad(False)
        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, self.args.level, speed)
        self.sound = SoundManager(path)
        self.hits = UserHits(self.num_lanes, self.arbalet, self.sound, self.args.simulate_player)
Пример #16
0
    def __init__(self, touch_mode='quadridirectional'):
        Application.__init__(self, touch_mode=touch_mode)
        self.rate=2
       
        self.DIRECTION1=DOWN
        self.HEAD1=(1,1)
        self.queue1=[self.HEAD1]

        self.DIRECTION2=UP
        self.HEAD2=(13,8)
        self.queue2=[self.HEAD2]
        
        self.FOOD_POSITIONS={}
        self.rate_increase=0.15
        self.start_food=3
Пример #17
0
 def __init__(self):
     Application.__init__(self, touch_mode='quadridirectional')
     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
     self.music = Music()
Пример #18
0
 def __init__(self):
     Application.__init__(self)
     pygame.init()
     self.BALLE = [7, random.randrange(0, 9)]
     self.P1_RACKET = range(3, 6)
     self.P2_RACKET = range(3, 6)
     self.P1_DIRECTION = []
     self.P2_DIRECTION = []
     self.P1_SCORE = 0
     self.P2_SCORE = 0
     self.SCORE_WIN = 5
     self.TABJEU = [[0] * 10 for _ in range(14)]
     self.fin = False
     self.ballspeed_increase = 0.01
     self.ballspeed = 0.5
     self.limspeed = 0.11
     self.RATE_SPEED = 2
     self.lenP1_RACKET = len(self.P1_RACKET)
     self.lenP2_RACKET = len(self.P2_RACKET)
Пример #19
0
    def __init__(self, argparser, num_lanes, path, speed):
        Application.__init__(self, argparser, touch_mode='columns')
        self.arbalet.touch.set_keypad(False)
        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, self.args.level, speed)
        self.sound = SoundManager(path)
        self.hits = UserHits(self.num_lanes, self.arbalet, self.sound,
                             self.args.simulate_player)
Пример #20
0
    def __init__(self, parser, rate):
        Application.__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 = RLock()

        if leapmotion:
            self.leap_listener = SampleListener(self.swipe, self.swipe_lock)
            self.controller = Controller()
            self.controller.add_listener(self.leap_listener)
Пример #21
0
    def __init__(self, parser, rate):
        Application.__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 = RLock()

        if leapmotion:
            self.leap_listener = SampleListener(self.swipe, self.swipe_lock)
            self.controller = Controller()
            self.controller.add_listener(self.leap_listener)
Пример #22
0
    def __init__(self, parser):

        Application.__init__(self, parser)

        self.CHAR_COLORS = self.args.type
        self.BG_COLOR = 'black'
Пример #23
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.image = None
     self.palette = None
     self.vertical = False
Пример #24
0
    def __init__(self, parser):

        Application.__init__(self, parser)

        self.CHAR_COLORS = self.args.type
        self.BG_COLOR = 'black'
Пример #25
0
 def __init__(self, argparser):
     Application.__init__(self, argparser, True) # starting mock mode, init flags (-w and -ng) will be redirected to the server
     self.server_process = None
     self.running = True
     signal(SIGINT, self.close_processes)
Пример #26
0
 def __init__(self):
     Application.__init__(self, touch_mode='quadridirectional')
     self.t0 = time.time()
     self.playing = True
     self.command = {'left': False, 'right': False,'left_p2': False, 'right_p2': False}  # User commands (joy/keyboard)
     self.pong = Pong(self.arbalet.height,self.arbalet.width)
Пример #27
0
 def close(self, reason='unknown'):
     Application.close(self, reason)
Пример #28
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.port = str(self.args.port)
     self.context = zmq.Context()
     self.connection = None
Пример #29
0
 def close(self, reason='unknown'):
     Application.close(self, reason)
     if leapmotion:
         self.controller.remove_listener(self.leap_listener)
Пример #30
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.video_reader = None
Пример #31
0
 def close(self, reason='unknown'):
     Application.close(self, reason)
     if leapmotion:
         self.controller.remove_listener(self.leap_listener)
Пример #32
0
 def __init__(self, parser, rate):
     Application.__init__(self, parser)
     self.rate = Rate(rate)
     self.t = Table(self.height, self.width, 3)
     print(self.t.table)
Пример #33
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.colors = ['red', 'green', 'blue']
     self.color_index = 0
Пример #34
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.colors = ['red', 'green', 'blue']
     self.color_index = 0
Пример #35
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.port = str(self.args.port)
     self.context = zmq.Context()
     self.connection = None
Пример #36
0
 def __init__(self, argparser):
     Application.__init__(self, argparser)
     self.video_reader = None
Пример #37
0
 def __init__(self, port, argparser=None):
     Application.__init__(self, argparser)
     self.bottle = Bottle()
     self.port = int(port)
     self.route()