Esempio n. 1
0
File: audio.py Progetto: Rtshaw/DIP
def outcome(txtfile):
    
    
    if os.path.isfile(txtfile):
        word = getContent(txtfile)
        #print(word)
        """
            with open(txtfile, 'r') as f:
            word = f.read()
            #print(word)
            """
    else:
        print("\n[INFO] 沒有可讀取檔案.")
    
    with tempfile.NamedTemporaryFile(delete=True) as fp:
        tts = gTTS(text=word, lang='zh-TW')
        tts.save('./result/outcome.mp3')
    
    sound = AudioSegment.from_mp3('./result/outcome.mp3')
    sound.export('./result/outcome.wav', format='wav')
    
    mixer.init()
    mixer.music.load('./result/outcome.wav')
    print("\n\n[INFO] 開始播放")
    screen=display.set_mode([200,50])
    mixer.music.play(0)
    clock= time.Clock()
    clock.tick(10)
    while mixer.music.get_busy():
        event.poll()
        clock.tick(10)
Esempio n. 2
0
    def responder_por_voz(self, afirmacao, troll_mode=False):
        if troll_mode:
            from requests import get
            som_troll = f'https://www.myinstants.com/media/sounds/{self.__bot.sentenca_usuario.lower()}.mp3'
            r = get(som_troll)
            path = f'/home/renan/Documents/projetos/Edgar/Sounds/{self.__bot.sentenca_usuario}.mp3'

            with open(path, 'wb') as f:
                f.write(r.content)

            music_path = f"Sounds/{self.__bot.sentenca_usuario}.mp3"
            init()
            try:
                mixer.music.load(music_path)
            except Exception as e:
                print('erro ao carregar som ' + str(e))
            mixer.music.play()
            mixer.music.set_volume(1)

            clock = time.Clock()
            clock.tick(10)

            while mixer.music.get_busy():
                event.poll()
                clock.tick(10)

        idioma = "pt"
        limpar_log = "&> /dev/null"
        resposta_edgar = afirmacao
        resposta_segura = quote(resposta_edgar)
        executar_espeak = f"espeak -v{idioma} {resposta_segura} {limpar_log}"
        check_output(executar_espeak, shell=True)
Esempio n. 3
0
    def _get_key(self):
        # Poll the events until the user presses a key and return it.
        # Discard all other events.
        # - self is the Window

        event = poll()
        while event.type != KEYUP:
            event = poll()
        return event.key
    def _get_key(self):
        """Poll the events until the user presses a key and return it. Discard all other events.

        :return: the user-pressed keys
        """

        event = poll()
        while event.type != KEYUP:
            event = poll()
        return event.key
Esempio n. 5
0
    def cantar(self):
        iniciar_canto()
        mixer.music.load("./Sounds/music.mp3")
        mixer.music.play()
        mixer.music.set_volume(1)

        clock = time.Clock()
        clock.tick(10)

        while mixer.music.get_busy():
            event.poll()
            clock.tick(10)
Esempio n. 6
0
 def run(self):
     icon = image.load("Icon.png")
     display.set_icon(icon)
     self.__window = display.set_mode(SIZE)
     display.set_caption("Twenty Nine")
     self.__window.fill(COLOURS.get('BOARD'))
     display.flip()
     while True:
         r, w, x = select(self.__read, self.__write, self.__error, 0)
         for f in r:
             if f is self.__listener:
                 data = receive(f)
                 if data:
                     print data
                     if data[0] == "ID":
                         self.__ID = int(data[1])
                     if data[0] == "Cards":
                         print data[1]
         event = pyevent.poll()
         if event.type == QUIT:
             self.__Quit()
             break
         elif event.type == KEYDOWN:
             if event.key == K_ESCAPE:
                 self.__Quit()
                 break
             else:
                 send(self.__listener, chr(event.key))
         elif event.type == MOUSEBUTTONDOWN:
             print event
Esempio n. 7
0
 def get_key(self):
     while 1:
         event = PE.poll()
         if event.type == PY.KEYDOWN:
             return event.key
         else:
             pass
Esempio n. 8
0
    def update(self):
        # Update the window by copying all drawn objects from the
        # frame buffer to the display.
        # - self is the Window

        update()
        event = poll()
Esempio n. 9
0
    def update(self, field):
        from pygame.constants import KEYDOWN, MOUSEBUTTONUP, K_EQUALS, K_MINUS, K_ESCAPE
        from pygame.event import poll, clear

        field.camera.set_lead(self.mob.leads[self.mob.current_lead])
        new_event = poll()
        if new_event.type == KEYDOWN:
            if new_event.key == K_EQUALS:
                self.mob.current_lead += 1
                self.mob.current_lead %= len(self.mob.leads)
            elif new_event.key == K_MINUS:
                self.mob.current_lead -= 1
                self.mob.current_lead %= len(self.mob.leads)
            elif new_event.key == K_ESCAPE:
                from bin.Interaction import pause_menu
                return pause_menu(field.screen, field)
        elif new_event.type == MOUSEBUTTONUP:
            if new_event.button == 1:
                from bin.Logic import pixel_to_hex, coord_get_offset, coord_available
                position = new_event.pos[0] + field.camera.border_pixel[0], new_event.pos[1] + field.camera.border_pixel[1]
                hexagon = pixel_to_hex(position, field.camera.size, field)
                coord = coord_get_offset(hexagon, field)
                if coord_available(hexagon, field) and field.map[coord[0]][coord[1]][1].exploration and \
                        field.map[coord[0]][coord[1]][1].passability:
                    self.hexagon = hexagon
        clear()
        return True
Esempio n. 10
0
    def run(self):
        #mixer.init()
        #mixer.music.load('sound/ACDC.mp3')
        #mixer.music.play(-1)

        new = NewGame()
        new.update()
        display.set_caption("Menu")
        going = True

        while going:
            ev = event.poll()

            if ev.type == QUIT:
                sys.exit()
            if ev.type == KEYDOWN and ev.key == K_SPACE:
                going = False
            if ev.type == MOUSEBUTTONDOWN:
                if new.click(mouse.get_pos()):
                    print("hello world")
                    going = False

            new.mouse_over(mouse.get_pos())
            #print "Mouse at : ", mouse.get_pos(), "and rect is : ", new.textpos

            Background.render()

            new.render()

            display.flip()
Esempio n. 11
0
    def update(self, field):
        from pygame.constants import KEYDOWN, MOUSEBUTTONUP, K_EQUALS, K_MINUS, K_ESCAPE
        from pygame.event import poll, clear

        field.camera.set_lead(self.mob.leads[self.mob.current_lead])
        new_event = poll()
        if new_event.type == KEYDOWN:
            if new_event.key == K_EQUALS:
                self.mob.current_lead += 1
                self.mob.current_lead %= len(self.mob.leads)
            elif new_event.key == K_MINUS:
                self.mob.current_lead -= 1
                self.mob.current_lead %= len(self.mob.leads)
            elif new_event.key == K_ESCAPE:
                from bin.Interaction import pause_menu
                return pause_menu(field.screen, field)
        elif new_event.type == MOUSEBUTTONUP:
            if new_event.button == 1:
                from bin.Logic import pixel_to_hex, coord_get_offset, coord_available
                position = new_event.pos[0] + field.camera.border_pixel[
                    0], new_event.pos[1] + field.camera.border_pixel[1]
                hexagon = pixel_to_hex(position, field.camera.size, field)
                coord = coord_get_offset(hexagon, field)
                if coord_available(hexagon, field) and field.map[coord[0]][coord[1]][1].exploration and \
                        field.map[coord[0]][coord[1]][1].passability:
                    self.hexagon = hexagon
        clear()
        return True
Esempio n. 12
0
def check_for_exit(poll_time=KEY_PRESS_POLL_TIME):
    time.wait(poll_time)
    if not event.peek():
        return

    ev = event.poll()
    if ev.type == pygame.KEYDOWN and ev.key == pygame.K_SPACE:
        sys.exit(0)
Esempio n. 13
0
def getEvent():
  event = poll()
  #print pygame.event.event_name(event.type)
  if event.type == pygame.NOEVENT:
    return (NO_EVENT, 0, 0)
  elif event.type == pygame.JOYBUTTONDOWN: 
    return (SWITCH_DOWN, event.joy, event.button)
  elif event.type == pygame.JOYBUTTONUP: 
    return (SWITCH_UP, event.joy, event.button)
Esempio n. 14
0
def get_key():
    while 1:
        evnt = event.poll()
        if evnt.type == KEYDOWN:
            if (evnt.key >= 0x100 and evnt.key <= 0x109):
                return evnt.key - 0xD0
            else:
                return evnt.key
        else:
            pass
Esempio n. 15
0
def GetKey():
    while True:
        event = pyevent.poll()
        if event.type == QUIT:
            return K_ESCAPE
        if event.type == KEYDOWN:
            if event.key in range(256, 266):
                # For keys pressed in numberpad
                return event.key - 208
            return event.key
Esempio n. 16
0
def check_for_exit(wait=False):
    global DETAILED_PROGRESS

    if wait:
        ev = event.wait()
    else:
        ev = event.poll()

    if ev and ev.type == pygame.KEYDOWN and ev.key == pygame.K_SPACE:
        end()
        sys.exit(0)
    elif ev and ev.type == pygame.KEYDOWN and ev.key == pygame.K_DELETE:
        DETAILED_PROGRESS = not DETAILED_PROGRESS
        clear_progress()
Esempio n. 17
0
    def update(self):
        from pygame.constants import KEYDOWN, K_UP, K_DOWN, K_RETURN
        from pygame.event import poll

        self.draw(0)
        while True:
            event = poll()
            if event.type == KEYDOWN:
                if event.key == K_UP:
                    self.draw(-1)
                if event.key == K_DOWN:
                    self.draw(1)
                if event.key == K_RETURN:
                    return self.get_position()
        return -1
Esempio n. 18
0
    def update(self):
        from pygame.constants import KEYDOWN, K_UP, K_DOWN, K_RETURN
        from pygame.event import poll

        self.draw(0)
        while True:
            event = poll()
            if event.type == KEYDOWN:
                if event.key == K_UP:
                    self.draw(-1)
                if event.key == K_DOWN:
                    self.draw(1)
                if event.key == K_RETURN:
                    return self.get_position()
        return -1
def main():
    screen = display.set_mode([xmax, ymax])
    drops = []
    clock = time.Clock()
    animate = True

    while animate:
        screen.fill([0, 0, 0])
        for d in drops.copy():
            draw.circle(screen, d.color, d.center, d.radius, 1)
            d.radius += 1
            if d.radius >= d.rmax:
                drops.remove(d)
        drops.append(Drop())
        display.flip()
        clock.tick(60)
        if event.poll().type == pygame.KEYDOWN:
            break
Esempio n. 20
0
    def run(self):
        self.start()
        self.clock.start()
        while True:
            while True:
                wait_time = self.clock.time_remaining()
                if wait_time > 0:
                    e = event.wait(wait_time)
                else:
                    e = event.poll()
                if e.type == pygame.NOEVENT:
                    break
                self.event(e)
            self.clock.advance()

            update_ret = self.update()
            if update_ret is not None:
                return update_ret

            self.render()
Esempio n. 21
0
'''

circles = []
''' # creepy white circles <3
while not event.poll().type == KEYDOWN:
    circles.append(Circle([random.randint(20, 780), random.randint(20, 580)], 20))

    for c in circles:
        c.radius += 1
        draw.circle(screen, white, c.center, c.radius)
    clock = time.Clock()
    clock.tick(60)
    display.flip()
'''

while not event.poll().type == KEYDOWN:
    screen.fill([0] * 3)
    circles.append(
        Circle([random.randint(20, 780),
                random.randint(20, 580)], random.randint(20, 30)))

    for c in circles[:]:
        if c.radius > 55:
            circles.remove(c)
        else:
            c.radius += 1
            draw.circle(screen, white, c.center, c.radius, 1)
    clock = time.Clock()
    clock.tick(60)
    display.flip()
Esempio n. 22
0
            for digit in phone:
                if digit != ' ':
                    text2 += digit
            text.box2(text2, True)
            D.flip()
            MU.load("email.mp3")
            MU.play()

    main = screen()
    name = screen.Box(main)
    text1, text2, text3, button = "", "", "", None
    text = screen.Text(main)
    eventz = screen.event_handler(main)
    name.display()
    buttons = screen.Buttons(main)
    D.flip()
    exit = False
    VC = False
    if (VC):
        time.sleep(0.5)
        while E.poll().type != pygame.KEYDOWN:
            pass
        Audio()

    while (not exit):
        D.flip()
        eventz.textbox(E.get())

    web = Web(text1, text2, text3, button)
    web.run()
init()
counter = 0
display.set_caption('Music Visualizer')
icon = image.load('./music_128px_1230638_easyicon.net.ico')
display.set_icon(icon)
screen = display.set_mode(WINDOW_SIZE, 0, 32)
# 在界面中显示当前播放的音乐文件名
font_surface, font_rect = set_title(FILENAME)
screen.blit(font_surface, font_rect, font_rect)
display.update()

np.seterr(divide='ignore', invalid='ignore')

while data:
    # 监听pygame事件保证模块正常工作
    event = py_event.poll()
    if event.type == QUIT:
        quit()
        break

    counter += 1
    stream.write(data)
    if not counter % FRESH_RATE:
        color_gradients()

        # 播放音频,同时将获取音频数据转换为16位short形式
        # 将音频信息先转化为两列分别对应左耳通道与右耳通道
        # 进行矩阵转置后第一行代表左耳通道,第二行代表右耳通道
        numpydata = np.fromstring(data, dtype=np.int16)
        numpydata.shape = -1, 2
        numpydata = numpydata.T
Esempio n. 24
0
def poll():
    ev = event.poll()
    _foo(ev)
    return ev
Esempio n. 25
0
from pygame import display, draw, time, event
import random
import pygame
import sys

screen = display.set_mode([800,600])
clock = time.Clock()
circles = []
random.seed()

while True:
	screen.fill([0,0,0])
	action = event.poll()
	if action.type == pygame.KEYDOWN:
		sys.exit()
	for i in range(len(circles)-1):
		lst = list(circles[i])
		lst[3] += 1
		circles[i] = tuple(lst)
		draw.circle(circles[i][0],circles[i][1],circles[i][2],circles[i][3],circles[i][4])
	
	reusedCircles = []
	for i in range(len(circles)):
		if circles[i][3] <= 80:
			reusedCircles.append(circles[i])
	circles = reusedCircles
	
	if len(circles) <= 20:
		circles.append((screen, [255,255,255], [random.randint(0,800),random.randint(0,600)],0,1))	
	display.flip()
	clock.tick(60)
Esempio n. 26
0
def poll(l):
    e=event.poll()
    _foo(l,e)
    return e
Esempio n. 27
0
        """
        Make the circle grow!
        """

        self.radius = self.radius + 1


circles = []

display.flip()

clock = time.Clock()

while True:
    # Detect events and exit upon keypress
    ev = event.poll()
    if ev.type == KEYDOWN:
        sys.exit(0)

    screen.fill([0, 0, 0])
    for circle in circles:
        circle.draw()
        circle.grow()

    display.flip()

    # Remove circles too big
    circles = [c for c in circles if c.radius < 160 + random.randint(1, 40)]

    # Add new circle, if necessary
    if len(circles) < 50 + random.randint(1, 20):
Esempio n. 28
0
def poll(l):
    e = event.poll()
    _foo(l, e)
    return e
Esempio n. 29
0
    def __init__(self):
        parser = OptionParser(
            usage="Usage: %prog [OPTIONS] [HOST]",
            version="NATOcubes 0.5",
            epilog=
            "If HOST is not specified, the game will start in local mode. Otherwise it will start in client mode, with HOST as server."
        )
        parser.add_option('-s',
                          '--server',
                          action="store_true",
                          dest="server",
                          default=False,
                          help="server mode")
        parser.add_option(
            '-p',
            '--port',
            type="int",
            dest="port",
            default=12345,
            help="set port (client & server mode) [default: %default]")
        parser.add_option(
            '-x',
            type="int",
            dest="x",
            default=5,
            help="field width (server & local mode) [default: %default]")
        parser.add_option(
            '-y',
            type="int",
            dest="y",
            default=5,
            help="field height (server & local mode) [default: %default]")
        parser.add_option('-z',
                          '--size',
                          type="int",
                          dest="size",
                          default=75,
                          help="size of one field [default: %default]")
        parser.add_option(
            '-l',
            '--player',
            type="int",
            dest="numplayers",
            default=2,
            help="number of players (local mode) [default: %default]")
        options, args = parser.parse_args()

        self.xsize, self.ysize, self.fieldsize = options.x, options.y, options.size

        if options.server:
            self.handler = server('', options.port, options.x, options.y)
        else:
            if len(args) > 0:
                self.handler = client(args[0], options.port)
                self.xsize, self.ysize = self.handler.getsize()
            else:
                self.handler = local(options.numplayers)

        self.player, self.localplayer, self.numplayers = self.handler.getopts()
        self.counts = []

        self.f = Field(self.xsize, self.ysize, self.fieldsize)
        display.set_mode(((self.xsize * (self.fieldsize + 1) - 1),
                          18 + (self.ysize * (self.fieldsize + 1) - 1)))
        display.set_caption('NATOcubes')
        surf = self.f.render()
        self.handler.surface(surf, self.player, self.fieldsize)
        display.get_surface().blit(surf, (0, 0))
        display.update()

        ev = event.wait()
        while ev.type != QUIT:
            event.clear()
            display.update()
            if self.player == self.localplayer or self.localplayer == -1:
                ev = event.wait()
                if ev.type == MOUSEBUTTONDOWN:
                    px, py = ev.pos
                    x = px / (self.fieldsize + 1)
                    y = (py - 18) / (self.fieldsize + 1)
                    if self.f.turn(self.player, x, y):
                        self.handler.onTurn(x, y)
                        surf = self.f.render(x, y)
                        self.handler.surface(surf, self.newplayer(),
                                             self.fieldsize)
                        display.get_surface().blit(surf, (0, 0))
                        display.update()
                        if self.after_turn():
                            return
            else:
                recv = self.handler.recv_data()
                if recv and len(recv) == 2:
                    x = ord(recv[0])
                    y = ord(recv[1])
                    if self.f.turn(self.player, x, y):
                        self.handler.distribute_data(x, y)
                        surf = self.f.render(x, y)
                        self.handler.surface(surf, self.newplayer(),
                                             self.fieldsize)
                        display.get_surface().blit(surf, (0, 0))
                        display.update()
                        if self.after_turn():
                            return
                    else:
                        self.handler.failed_turn()
                elif recv == '\x00':
                    s = smallfont.render('Lost Connection', True,
                                         Color('#FFFFFF'), Color('#000000'))
                    sw, sh = s.get_size()
                    display.get_surface().blit(
                        s, (((self.xsize * self.fieldsize) - sw) / 2,
                            ((self.ysize * self.fieldsize) - sh) / 2 + 18))
                    display.update()
                    while event.wait().type != QUIT:
                        pass
                    return
                else:
                    sleep(0.1)
                ev = event.poll()
Esempio n. 30
0
if not constants.jetpack_mode:
    helper1 = Helper.Helper((0.5, 2.5))
    helper2 = Helper.Helper((5.5, 2.5))
    helper1.tag = 'helper'
    helper2.tag = 'helper'
    helper1.init_pos = ((0.5, 0.5))
    helper2.init_pos = ((5.5, 0.5))
else:
    helper1 = Jetpack(ragdoll)
    helper2 = Jetpack(ragdoll2)

running = True
while running:
    while True:
        e = event.poll()
        if e.type == pygame.NOEVENT:
            break
        elif e.type == pygame.QUIT:
            running = False
            break
        elif e.type == pygame.KEYDOWN:
            if e.key == pygame.K_ESCAPE:
                running = False
                break
            elif e.key == pygame.K_w:
                helper1.dirs[0] = True
            elif e.key == pygame.K_a:
                helper1.dirs[1] = True
            elif e.key == pygame.K_s:
                helper1.dirs[2] = True
Esempio n. 31
0
    def __init__(self):
        parser = OptionParser(
            usage="Usage: %prog [OPTIONS] [HOST]",
            version="NATOcubes 0.5",
            epilog="If HOST is not specified, the game will start in local mode. Otherwise it will start in client mode, with HOST as server.")
        parser.add_option('-s', '--server', action="store_true", dest="server", default=False, help="server mode")
        parser.add_option('-p', '--port', type="int", dest="port", default=12345, help="set port (client & server mode) [default: %default]")
        parser.add_option('-x', type="int", dest="x", default=5, help="field width (server & local mode) [default: %default]")
        parser.add_option('-y', type="int", dest="y", default=5, help="field height (server & local mode) [default: %default]")
        parser.add_option('-z', '--size', type="int", dest="size", default=75, help="size of one field [default: %default]")
        parser.add_option('-l', '--player', type="int", dest="numplayers", default=2, help="number of players (local mode) [default: %default]")
        options, args = parser.parse_args()

        self.xsize, self.ysize, self.fieldsize = options.x, options.y, options.size

        if options.server:
            self.handler = server('', options.port, options.x, options.y)
        else:
            if len(args) > 0:
                self.handler = client(args[0], options.port)
                self.xsize, self.ysize = self.handler.getsize()
            else:
                self.handler = local(options.numplayers)

        self.player, self.localplayer, self.numplayers = self.handler.getopts()
        self.counts = []

        self.f = Field(self.xsize, self.ysize, self.fieldsize)
        display.set_mode(((self.xsize * (self.fieldsize + 1) - 1), 18 + (self.ysize * (self.fieldsize + 1) - 1)))
        display.set_caption('NATOcubes')
        surf = self.f.render()
        self.handler.surface(surf, self.player, self.fieldsize)
        display.get_surface().blit(surf, (0, 0))
        display.update()

        ev = event.wait()
        while ev.type != QUIT:
            event.clear()
            display.update()
            if self.player == self.localplayer or self.localplayer == -1:
                ev = event.wait()
                if ev.type == MOUSEBUTTONDOWN:
                    px, py = ev.pos
                    x = px / (self.fieldsize + 1)
                    y = (py - 18) / (self.fieldsize + 1)
                    if self.f.turn(self.player, x, y):
                        self.handler.onTurn(x, y)
                        surf = self.f.render(x, y)
                        self.handler.surface(surf, self.newplayer(), self.fieldsize)
                        display.get_surface().blit(surf, (0, 0))
                        display.update()
                        if self.after_turn():
                            return
            else:
                recv = self.handler.recv_data()
                if recv and len(recv) == 2:
                    x = ord(recv[0])
                    y = ord(recv[1])
                    if self.f.turn(self.player, x, y):
                        self.handler.distribute_data(x, y)
                        surf = self.f.render(x, y)
                        self.handler.surface(surf, self.newplayer(), self.fieldsize)
                        display.get_surface().blit(surf, (0,0))
                        display.update()
                        if self.after_turn():
                            return
                    else:
                        self.handler.failed_turn()
                elif recv == '\x00':
                    s = smallfont.render('Lost Connection', True, Color('#FFFFFF'), Color('#000000'))
                    sw, sh = s.get_size()
                    display.get_surface().blit(s, (((self.xsize * self.fieldsize) - sw) / 2, ((self.ysize * self.fieldsize) - sh) / 2 + 18))
                    display.update()
                    while event.wait().type != QUIT:
                        pass
                    return
                else:
                    sleep(0.1)
                ev = event.poll()
Esempio n. 32
0
def random_circle():
    a = randint(1 + MAX_RADIUS, WIDTH - MAX_RADIUS)
    b = randint(1 + MAX_RADIUS, HEIGHT - MAX_RADIUS)
    return a, b, 1, [randint(0, 255), randint(0, 255), randint(0, 255)]


clock = time.Clock()

screen = display.set_mode([WIDTH, HEIGHT])
screen.fill([0, 0, 0])

radius = 10
circles = []

while event.poll().type != pygame.KEYDOWN:
    screen.fill([0, 0, 0])
    if radius <= MAX_RADIUS:
        radius = radius + 1
    circles.append(random_circle())

    for i, circle in enumerate(circles):
        x, y, r, color = circle
        circles[i] = (x, y, r + 1, color)

    circles = [x for x in circles if x[2] <= MAX_RADIUS]

    for x, y, r, c in circles:
        draw.circle(screen, c, (x, y), r, 1)

    display.flip()
Esempio n. 33
0
if not constants.jetpack_mode:
	helper1 = Helper.Helper((0.5, 2.5))
	helper2 = Helper.Helper((5.5, 2.5))
	helper1.tag = 'helper'
	helper2.tag = 'helper'
	helper1.init_pos = ((0.5, 0.5))
	helper2.init_pos = ((5.5, 0.5))
else:
	helper1 = Jetpack(ragdoll)
	helper2 = Jetpack(ragdoll2)

running = True
while running:
	while True:
		e = event.poll()
		if e.type == pygame.NOEVENT:
			break
		elif e.type == pygame.QUIT:
			running = False; break
		elif e.type == pygame.KEYDOWN:
			if e.key == pygame.K_ESCAPE:
				running = False; break
			elif e.key == pygame.K_w:
				helper1.dirs[0] = True
			elif e.key == pygame.K_a:
				helper1.dirs[1] = True
			elif e.key == pygame.K_s:
				helper1.dirs[2] = True
			elif e.key == pygame.K_d:
				helper1.dirs[3] = True
Esempio n. 34
0
def poll():
    ev=event.poll()
    _foo(ev)
    return ev
Esempio n. 35
0
from random import randint

import pygame
from pygame import display, draw, time, event


class circle:
    def __init__(self):
        self.color = [randint(0, 255), randint(0, 255), randint(0, 255)]
        self.center = [randint(0, 800), randint(0, 600)]
        self.radius = 1
        self.maxr = randint(20, 100)


screen = display.set_mode([800, 600])
clock = time.Clock()
drops = []
while True:
    screen.fill([0, 0, 0])
    for d in drops[:]:
        draw.circle(screen, d.color, d.center, d.radius, 1)
        d.radius += 1
        if d.radius >= d.maxr: drops.remove(d)
    drops.append(circle())
    display.flip()
    clock.tick(60)
    if event.poll().type == pygame.KEYDOWN: break