def get(prompt):
    print(prompt)
    inkey = Getch._Getch()
    while (1):
        k = inkey()
        if k != '': break
    return k
Exemple #2
0
def next_LEVEL():
    ''' level increment '''
    Config.ENEMYPUT = True
    Config.CONSWALL = True
    getch = Getch._Getch()
    board = Board.Board()
    bomber = Bomberman.Bomber()
    for i in range(Config.LEVEL + 4):
        Config.ENEMIES.append(Enemy.Enemy())
        Config.ENEMIES[i].setposition(Config.ENEMYSET[i][0],
                                      Config.ENEMYSET[i][1])
def next_level():
    Global.enemyput = True
    Global.wallbuild = True
    getch = Getch._Getch()
    board = Board.Board()
    bomber.RemoveBomber()
    bomber.SetPosition(2, 2)
    bomber.MakeBomber()
    for i in range(Global.level + 5):
        Global.enemies.append(Enemy.Enemy())
        Global.enemies[i].SetPosition(Global.enemyset[i][0],
                                      Global.enemyset[i][1])
Exemple #4
0
def pull():
	getch=Getch._Getch();
	pin=libport.Port(3, libport.Port.IN);
	pout=libport.Port(5, libport.Port.OUT);
	k='0';
	while (not k=='q'):
		k=getch();
		if (k=='o'):	
			pout.write(1);
		elif (k=='f'):
			pout.write(0);
		v=pin.read();
		print "la tension est de {0} v :".format((v*3.3));
Exemple #5
0
def controleKey():
    global i
    global k
    getch = Getch._Getch()
    while (not k == 'c'):
        k = getch()
        if (k == 'q'):  # and i>-0.5):
            i = i - 0.1
        elif (k == 'd'):  #and i<0.35):
            i = i + 0.1
        elif (k == 's'):
            i = 0
        print((Tc + i) * (10**(-3)), " ms")
Exemple #6
0
def pull():
    getch = Getch._Getch()
    pin = libport.Port(3, libport.Port.IN)
    pout = libport.Port(5, libport.Port.OUT)
    k = '0'
    while (not k == 'q'):
        k = getch()
        if (k == 'o'):
            pout.write(1)
        elif (k == 'f'):
            pout.write(0)
        v = pin.read()
        print "la tension est de {0} v :".format((v * 3.3))
Exemple #7
0
def controleKey():
	global i;
	global k;
	getch=Getch._Getch();
	while (not k=='c'):
		k=getch();
		if (k=='q'):# and i>-0.5):
			i=i-0.1;
		elif (k=='d'): #and i<0.35):
			i=i+0.1;
		elif (k=='s'):
			i=0;
		print((Tc+i)*(10**(-3)), " ms");
def exploration(command):

    explored_maze = []
    exit = False
    getch = G._Getch()

    while not exit:

        res = mazeClient.send_command(command.GET_STATE)
        pos = json.loads(res)
        print(pos)

        elm = {}
        elm["x"] = pos["userX"]
        elm["y"] = pos["userY"]
        elm["val"] = pos["userVal"]
        if is_in_maze(explored_maze, elm) == False:
            explored_maze.append(elm)

        for block in pos["Neighbors"]:
            if is_in_maze(explored_maze, block) == False:
                explored_maze.append(block)

        os.system("clear")
        print("")
        print_map(explored_maze, elm)
        print("")
        values = get_stats(explored_maze)
        print("Total: " + str(values["total"]) + ", red: " +
              str(values["red"]) + ", green: " + str(values["green"]) +
              ", blue: " + str(values["blue"]) + ", white: " +
              str(values["white"]))
        filter_neighbors(pos["Neighbors"], elm)
        print(
            "Select option:\nW) Up\nS) Down\nR) Right\nA) Left\nE) Exit\nP) Plot stats\n"
        )
        sel = getch()
        if sel == "w" or sel == "W":
            mazeClient.send_command(command.MOVE_UP)
        elif sel == "s" or sel == "S":
            mazeClient.send_command(command.MOVE_DOWN)
        elif sel == "d" or sel == "D":
            mazeClient.send_command(command.MOVE_RIGHT)
        elif sel == "a" or sel == "A":
            mazeClient.send_command(command.MOVE_LEFT)
        elif sel == "e" or sel == "E":
            exit = True
        elif sel == "p" or sel == "P":
            frequency_distribution(explored_maze)
        else:
            print("Invalid")
Exemple #9
0
def exploration(command):

    explored_maze = []
    _exit = False
    getch = G._Getch()

    while not _exit:

        res = mazeClient.send_command(command.GET_STATE)
        pos = json.loads(res)
        print(pos)

        elm = {
            'x': pos["userX"],
            'y': pos["userY"],
            'val': pos["userVal"]
        }
        if is_in_maze(explored_maze, elm) is False:
            explored_maze.append(elm)

        for block in pos["Neighbors"]:
            if is_in_maze(explored_maze, block) is False:
                explored_maze.append(block)

        os.system("clear")
        print()
        print_map(explored_maze, elm)
        print()
        values = get_stats(explored_maze)
        print("Total: " + str(values["total"]) + ", red: " + str(values["red"]) + ", green: " + str(
            values["green"]) + ", blue: " + str(values["blue"]) + ", white: " + str(values["white"]))
        filter_neighbors(pos["Neighbors"], elm)
        print("Select option:\nW) Up\nS) Down\nR) Right\nA) Left\nE) Exit\nP) Plot stats\n")
        sel = getch()
        if sel in ["w", "W"]:
            mazeClient.send_command(command.MOVE_UP)
        elif sel in ["s", "S"]:
            mazeClient.send_command(command.MOVE_DOWN)
        elif sel in ["d", "D"]:
            mazeClient.send_command(command.MOVE_RIGHT)
        elif sel in ["a", "A"]:
            mazeClient.send_command(command.MOVE_LEFT)
        elif sel in ["e", "E"]:
            _exit = True
        elif sel in ["p", "P"]:
            frequency_distribution(explored_maze)
        else:
            print("Invalid")
Exemple #10
0
def controle():
	i=0;
	k='0';
	getch=Getch._Getch();
	p22=libport.Port(7, libport.Port.OUT);
	#pext=libport.ExtPort(7, 0x20, libport.ExtPort.OUT);
	servo=libservo.Servo(p22);
	#servo=libservo.Servo(pext);
	servo.start();
	while (not k=='c'):
		k=getch();
		if (k=='d'):
			i=i-1;
		elif (k=='q'):
			i=i+1;
		elif (k=='s'):
			i=0;
		print ("{0}° ".format(i));
		try:
			print servo._Tc+servo.rotate(i);
		except Exception:
			print "Error";
	servo.stop();
Exemple #11
0
"Demo the use of the _Getch class"

import Getch
getch = Getch._Getch()
while 1:
    print "Enter keystroke (or ESC to escape):"
    char = getch()
    esc = '\x1b'
    if char == esc:
        break
    print char
Exemple #12
0
from Util import *
from socket import *

# Defined ip address of Rpi
serverName = '192.168.1.10'
# Request for port number from Rpi
serverPort = int(input('Input the server port : '))
clientSocket = socket(AF_INET, SOCK_STREAM)
# connect to Rpi
clientSocket.connect((serverName, serverPort))

val = int(input("Enter 0 for text transfer or 1 for file transfer : "))
# Option to enter text chosen
if val == 0:
    print "Enter ESC to exit"
    getChObj = Getch._Getch()
    # reading from the keyboard
    ch = getChObj.__call__()
    # continuous read till ESC pressed
    while ch != chr(27):
        if ch == '\r':
            sys.stdout.write('\n')
        elif ch == chr(127):
            sys.stdout.write("\b")
        else:
            sys.stdout.write(ch)

        # send character to Rpi
        clientSocket.send(ch)
        # read next character
        ch = getChObj.__call__()
]

GameOver = [
    ' _____                        _____                ',
    '|  __ \                      |  _  |               ',
    '| |  \/ __ _ _ __ ___   ___  | | | |_   _____ _ __ ',
    '| | __ / _` | \'_ ` _ \ / _ \ | | | \ \ / / _ \ \'__|',
    '| |_\ \ (_| | | | | | |  __/ \ \_/ /\ V /  __/ |   ',
    ' \____/\__,_|_| |_| |_|\___|  \___/  \_/ \___|_|   '
]
'''
    Initialization of Board, Bomberman,
    a global object that has its instance and Enemies
'''

getch = Getch._Getch()
Global.init()
board = Board.Board()
bomber = Bomberman.Bomber()
Global.bomberwoman = bomber

for i in range(Global.level + 5):
    Global.enemies.append(Enemy.Enemy())
    Global.enemies[i].SetPosition(Global.enemyset[i][0], Global.enemyset[i][1])
''' Taking single character input using getch '''


def static_input():
    try:
        text = getch()
    except:
Exemple #14
0
 def __init__(self):
     self.map = [[self.startWall(j, i) for i in range(20)]
                 for j in range(10)]
     self.pos = Pos(5, 5)
     self.getch = g._Getch()
     self.hp = 9