예제 #1
0
def get_action():
    getch = _Getch()
    k = getch()
    if k == 'w':
        return 'UP'
    elif k == 's':
        return 'DOWN'
    elif k == 'd':
        return 'RIGHT'
    elif k == 'a':
        return 'LEFT'
    elif k == 'x':
        return 'SPIN_CW'
    elif k == 'z':
        return 'SPIN_CCW'
    elif k == 'h':
        return 'SET_HOME'
    elif k == 'u':
        return 'TOGGLE_SMOOTH'
    elif k == 'o':
        return 'TOGGLE_ODOM'
    elif k == 'b':
        return 'BREAKPOINT'
    elif k == 'B':
        return 'BATTERY'
    elif k == 'H':
        return 'GO_HOME'
    elif k == 'G':
        return 'GO_TO_POINT'
    elif k == 'c':
        return 'TOGGLE_CNTRL'
    elif k == 'C':
        return 'CALIBRATION_MODE'
    elif k == ' ':
        return 'DIE'
예제 #2
0
파일: wordgame.py 프로젝트: wgml/wordgame
    def __init__(self, dim = 15):
        self.size = dim
        self.board = None
        #self.loadedWords = ["word", "test", "another", "much", "words", "blue", "etc"] #todo
        self.terminalSize = terminalsize.get_terminal_size()
        self.getchar = _Getch()
        self.cls = ClearScreen()

        self.loadWords()

        self.manageMenu()
예제 #3
0
파일: wordgame.py 프로젝트: wgml/wordgame
    def __init__(self, dim=15):
        self.size = dim
        self.board = None
        #self.loadedWords = ["word", "test", "another", "much", "words", "blue", "etc"] #todo
        self.terminalSize = terminalsize.get_terminal_size()
        self.getchar = _Getch()
        self.cls = ClearScreen()

        self.loadWords()

        self.manageMenu()
예제 #4
0
class Game:
    map = Map("map.txt", 24)
    hero = Hero()
    getch = _Getch()
    render3D = Render3D()

    def __init__(self):
        ConsoleTweaks.clearScreen()
        self.loop()

    def loop(self):
        while True:
            ConsoleTweaks.setCursorPos(0, 0)
            self.render3D.clearBuffer()
            image3D = self.render3D.render(self.hero, self.map)
            print(image3D)
            #while True:
            self.map.clearBuffor()

            #self.map.draw(self.hero.txt, self.hero.x, self.hero.y)

            #buffer = self.map.render2D(self.hero)

            #print(buffer)
            print("x: {}, y: {}     ".format(self.hero.x, self.hero.y))
            print("angle: {}".format(self.hero.angle))
            key = self.getch()
            if key == 'w':
                self.hero.y -= 0.1
            elif key == 's':
                self.hero.y += 0.1
            elif key == 'a':
                self.hero.x -= 0.1
            elif key == 'd':
                self.hero.x += 0.1
            elif key == 'k':
                self.hero.angle -= 1
            elif key == 'l':
                self.hero.angle += 1
            elif key == 'q':
                exit()
예제 #5
0
def getch():
    if os.name == "nt":
        return msvcrt.getche()
    else:
        _getch = _Getch()
        return _getch()
예제 #6
0
#    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
#
# Filename:  by: andrek
# Timesamp: 4/28/16 :: 9:19 PM

from sys import stdout, exit
from time import sleep
from socket import socket, AF_INET, SOCK_STREAM
from socket import error as socketError
from thread import start_new_thread
from thread import error as threadError
from Getch import _Getch
from pyperclip import copy
from pyperclip import paste

getch = _Getch()

HOST, PORT = "localhost", 9999
BEEP = True

# TODO: Replace exit(0) for socketErrors with something more effective.
# Right now they are not exiting because they are not being called from the
# 'main thread'
# See docs: http://docs.python.org/2/library/sys.html#sys.exit


class Client():
    """ A simple chat client """
    def __init__(self, connectionInfo):
        """ Initialize the client with connectionInfo = (HOST, PORT) """
예제 #7
0
#    You should have received a copy of the GNU General Public License
#    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
#
# Filename:  by: andrek
# Timesamp: 4/28/16 :: 9:19 PM

from sys import stdout, exit
from time import sleep
from socket import socket, AF_INET, SOCK_STREAM
from socket import error as socketError
from thread import start_new_thread
from thread import error as threadError
from Getch import _Getch
from pyperclip import copy
from pyperclip import paste
getch = _Getch()

HOST, PORT = "localhost", 9999
BEEP = True

# TODO: Replace exit(0) for socketErrors with something more effective.
# Right now they are not exiting because they are not being called from the
# 'main thread'
# See docs: http://docs.python.org/2/library/sys.html#sys.exit


class Client():
    """ A simple chat client """

    def __init__(self, connectionInfo):
        """ Initialize the client with connectionInfo = (HOST, PORT) """