コード例 #1
0
 def user_input(timeout=0.1):
     '''input method'''
     signal.signal(signal.SIGALRM, alarmhandler )
     signal.setitimer(signal.ITIMER_REAL, timeout)
     try:
         move = getch._getChUnix()()
         signal.alarm(0)
         return move
     except alarm.AlarmException:
         pass
     signal.signal(signal.SIGALRM, signal.SIG_IGN)
     return ''
コード例 #2
0
 def bosstime(self):
     self.set__(1)
     import time
     if self.getbosstimeanou() == 0:
         time.sleep(1.5)
         # print("\033[2J")
         print("\033[0;0H")
         print("\n\n\n\n\n\n\t\t\t\t\t\t\033[33m" +
               "<< \033[32mBOSS TIME!! \033[33m>>\033[0m\n")
         if getch._getChUnix()() is not '':  #press key to start
             pass
         self.setbosstimeanou(1)
コード例 #3
0
 def loselife(self,game):
     import time
     self.__lives-=1
     print("\033[2J")
     # print("\033[0;0H")
     print("\t\t\t\t\t<<\033[31m DEAD \033[0m>>\n\t\t\t\t<< PRESS ANY KEY TO START >>")
     
     time.sleep(1)
     if getch._getChUnix()() is not '': #press key to start
         self.__x = game.getx() + 5
         pass
         
     print("\033[2J")
コード例 #4
0
from session import session
from character import Mando
from getch import _getChUnix
from alarmexception import AlarmException
from datetime import datetime
import signal


def pos(x, y):
    return '\x1b[%d;%dH' % (y, x)


getch = _getChUnix()


def alarmHandler(signum, frame):
    raise AlarmException


def input_to(timeout=1):
    signal.signal(signal.SIGALRM, alarmHandler)
    signal.setitimer(signal.ITIMER_REAL, timeout)
    try:
        text = getch()
        signal.alarm(0)
        return text
    except AlarmException:
        pass
    signal.signal(signal.SIGALRM, signal.SIG_IGN)
    return ''