def __init__(self): """ Maintain events received from JVM. Module initialization creates pyj2d.event instance. """ self.eventQueue = [None] * 256 #max 256: Error: Event queue full self.eventNum = 0 self.eventQueueTmp = [None] * 256 #used when main queue is locked self.eventNumTmp = 0 self.eventAllowed = [] self.eventBlocked = [] self.queueLock = False self.queueAccess = False self.queue = [] self.mousePress = None self.timer = time.Clock() self._nonimplemented_methods() self.eventName = { MouseEvent.MOUSE_PRESSED: 'MouseButtonDown', MouseEvent.MOUSE_RELEASED: 'MouseButtonUp', MouseEvent.MOUSE_MOVED: 'MouseMotion', KeyEvent.KEY_PRESSED: 'KeyDown', KeyEvent.KEY_RELEASED: 'KeyUp' } self.eventType = [ MouseEvent.MOUSE_PRESSED, MouseEvent.MOUSE_RELEASED, MouseEvent.MOUSE_MOVED, KeyEvent.KEY_PRESSED, KeyEvent.KEY_RELEASED ] self.events = [ MouseEvent.MOUSE_PRESSED, MouseEvent.MOUSE_RELEASED, MouseEvent.MOUSE_MOVED, KeyEvent.KEY_PRESSED, KeyEvent.KEY_RELEASED ]
def check_RTT_timing(pkt): if pkt.haslayer(TCP): pktStr = pkt.sprintf('%TCP.flags%') #SYN: Send ICMP Ping to get RTT if pktStr == 'S': time1 = time.Clock() ans, unans = sr(IP(dst=pkt[IP].src) / ICMP()) time2 = time.Clock() rttThresh = 2 * (time2 - time1) currIp = pkt[IP].src #SYNACK: Get start time from send of SYNACK elif pktStr == 'SA' and currIp == pkt.src: sTime = time.Clock() #ACK: Get end time, look for bad behavior(2xRTT) elif pktStr == 'A' and currIp == pkt.src: if (time.Clock() - sTime) > rttThresh: print(pkt[IP].src + " has broken the RTT threshold") currIp = ""
def duyuruYap(metin): try: tts = gTTS(metin, lang="tr") tts.save("duyuru.mp3") mixer.init() mixer.music.load("duyuru.mp3") mixer.music.play() while mixer.music.get_busy(): time.Clock().tick(10) mixer.music.stop() mixer.quit() os.remove("duyuru.mp3") except: print("Google API'si devre dışı") finally: cursorObj.execute('UPDATE cal_duyur SET metin=NULL') con.commit()
import sys import time from pygame import * from settings import * from Objects import * from menu import dino_menu init() if dino_menu(): mixer.music.play(-1) else: pass generate_cactus_array(cactus_array) while True: pace += 0.01 for event_ in event.get(): if event_.type == QUIT: # exit game sys.exit(0) win_actions() time.Clock().tick(pace)
# To see messages from networktables, you must setup logging import logging logging.basicConfig(level=logging.DEBUG) ip = 'localhost' #'10.49.3.2' NetworkTables.initialize(server=ip) table = NetworkTables.getTable("Diagram") screen = display.set_mode((800, 450)) init() pytimer = time.Clock() ELEVATOR_MAX_VALUE = 2195 TILT_MAX_VALUE = 450000 # text font = font.Font('avenir.otf', 20) texts = [] INTAKE_POSITIONS = {-1: 'OUT', 0: 'NEUTRAL', 1: 'IN'} rocket = image.load('rocket.png') # C # __-- # | /
import random import time import pyautogui a1 = '' mixer.init() sound = mixer.Sound('Resources/Musica.wav') sound.set_volume(0.12) sound.play() sound2 = mixer.Sound('Resources/Errouu.wav') sound2.set_volume(0.5) sound3 = mixer.Sound('Resources/Acertou.wav') sound3.set_volume(0.5) while mixer.music.get_busy(): time.Clock().tick(10) print( f"""\n\033[7;30m=============================================================================================================\033[m \033[7;30m{'JOGO DA ADIVINHAÇÃO 2.0':^}\033[m \033[7;30m=============================================================================================================\033[m""" ) numero = random.randint(0, 100) tentativas = 1 a1 = 0 a2 = 0 sopnparar = '' a1 = int( input( '\n\033[34mEu sou o Vitu, sua inteligênia artificial. Eu pensei em um número de 0 a 100 nesse momento. Qual seu palpite?: ' ))
import turtle import time h = turtle.Turtle() h.shape('square') h.turtlesize(4) clock = time.Clock() for i in range(4): h.clear() h.forward(4) clock.tick(60) turtle.done()
def __init__(self): """ Maintain events received from browser. Module initialization creates pyjsdl.event instance. """ self.eventQueue = [None for i in range(256) ] #max 256: Error: Event queue full # self.eventQueue = [None] * 256 #pyjs -O TypeError self.eventNum = 0 self.eventQueueTmp = [None for i in range(256) ] #used when main queue is locked # self.eventQueueTmp = [None] * 256 #pyjs -O TypeError self.eventNumTmp = 0 self.queueLock = False self.queueAccess = False self.queue = [] self.mousePress = {0: False, 1: False, 2: False} self.mouseMove = {'x': -1, 'y': -1} self.mouseMoveRel = {'x': None, 'y': None} self.keyPress = { Const.K_ALT: False, Const.K_CTRL: False, Const.K_SHIFT: False } self.keyMod = { Const.K_ALT: { True: Const.KMOD_ALT, False: 0 }, Const.K_CTRL: { True: Const.KMOD_CTRL, False: 0 }, Const.K_SHIFT: { True: Const.KMOD_SHIFT, False: 0 } } self.mouseCursor = True self.timer = time.Clock() self.eventName = { 'mousemove': 'MouseMotion', 'mousedown': 'MouseButtonDown', 'mouseup': 'MouseButtonUp', 'keydown': 'KeyDown', 'keyup': 'KeyUp' } self.eventType = [ 'mousemove', 'mousedown', 'mouseup', 'wheel', 'mousewheel', 'DOMMouseScroll', 'keydown', 'keypress', 'keyup' ] self.events = set(self.eventType) self.eventTypes = { Const.MOUSEMOTION: ['mousemove'], Const.MOUSEBUTTONDOWN: ['mousedown', 'wheel', 'mousewheel', 'DOMMouseScroll'], Const.MOUSEBUTTONUP: ['mouseup'], Const.KEYDOWN: ['keydown', 'keypress'], Const.KEYUP: ['keyup'] } if env.pyjs_mode.optimized: self.modKey = set([Const.K_ALT, Const.K_CTRL, Const.K_SHIFT]) self.specialKey = set([ Const.K_UP, Const.K_DOWN, Const.K_LEFT, Const.K_RIGHT, Const.K_HOME, Const.K_END, Const.K_PAGEDOWN, Const.K_PAGEUP, Const.K_BACKSPACE, Const.K_DELETE, Const.K_INSERT, Const.K_RETURN, Const.K_TAB, Const.K_ESCAPE ]) else: #pyjs-S onKeyDown keycode 'mod' not in set, due to js/pyjs numeric diff self.modKey = set([ keycode.valueOf() for keycode in (Const.K_ALT, Const.K_CTRL, Const.K_SHIFT) ]) self.specialKey = set([ keycode.valueOf() for keycode in (Const.K_UP, Const.K_DOWN, Const.K_LEFT, Const.K_RIGHT, Const.K_HOME, Const.K_END, Const.K_PAGEDOWN, Const.K_PAGEUP, Const.K_BACKSPACE, Const.K_DELETE, Const.K_INSERT, Const.K_RETURN, Const.K_TAB, Const.K_ESCAPE) ]) #Const.K_F1, Const.K_F2, Const.K_F3, Const.K_F4, Const.K_F5, Const.K_F6, Const.K_F7, Const.K_F8, Const.K_F9, Const.K_F10, Const.K_F11, Const.K_F12, Const.K_F13, Const.K_F14, Const.K_F15 #IE keypress keycode: id same as alpha keys self.Event = UserEvent self._nonimplemented_methods()
music = mixer.music.load("Sounds/bg_music.mp3") catch = mixer.Sound("Sounds/bg_music.mp3") mixer.music.set_volume(0.4) mixer.music.play(-1) heart = image.load("Images/heart.png") # Scherm instellingen scherm_breedte = 400 scherm_hoogte = 600 grootte = width, height = scherm_breedte, scherm_hoogte scherm = display.set_mode(grootte) Achtergrondkleur = 115, 115, 115 # [RED,GREEN,BLUE] # Zet het aantal FPS gelijk aan de clock van fpsClock = time.Clock() # Text instellingen font_vorige_score = font.SysFont("monospace", 25) font_big = font.SysFont("monospace", 50) font_medium = font.SysFont("monospace", 20) # Bal instellingen bal = image.load("Images/bal.png") # Het plaatje van de bal toewijzen standaard_snelheid = 5 # Standaardsnelheid van de bal toewijzen. Hiermee wordt de snelheid ook verhoogt speed = [0, standaard_snelheid] # Balsnelheid [horizontaal, verticaal] bal_sneller_naar = 100 # Het aantal punten waar een snelheidsverhoging ingaat. balrect = bal.get_rect( ) # Sla het vierkant van de bal op (makkelijk voor intersects) balrect.centerx = randint(