Esempio n. 1
0
    "admin": sendToAdmin,
    "survivors": serverConn.getLiving,
    "status": serverConn.getStatus,
    "start": registerUser
}

#########################################
#	   	~~~Main~~~		#
#########################################
if __name__ == '__main__':
    # 1. Start whatsapp web handler (Uses commandline for confirmation)
    whatsappHandler.start()
    while not whatsappHandler.isReady():
        time.sleep(1)
    # 2. Start waiting for commandline commands
    inputHandler = InputHandler()
    inputHandler.start()
    # 3. Start network handler (Long Polling)
    serverConn.start()

    logFile = open(os.getcwd() + "/log.txt", "a")
    running = True

    while running:
        try:
            #Check for incoming commands
            incomingCommands = getFileCommands() + serverConn.getCommands()
            for command in incomingCommands:
                handleIncomingCommand(whatsappHandler, logFile, command)
                time.sleep(0.1)
            #Check for input commands
Esempio n. 2
0
# pygame init
pygame.mixer.pre_init(22050, -16, 1, 64)
pygame.mixer.init()
pygame.init()

from inputHandler import InputHandler
from guiMenu import GuiMenu
from guiSettings import GuiSettings
from pongGame import PongGame
from subprocess import call

# Hide the cursor
pygame.mouse.set_visible(False)

# Create objects here so settings stay remembered
input = InputHandler()
settings = GuiSettings(input)
menu = GuiMenu(input)

# Bug fix, the first sound the game plays doesn't make sound.
pygame.mixer.Sound('/home/pi/Desktop/pong2d/pong_8bit_scored.wav').play(0)

playGame = True
shutDown = False
while playGame:
    # get action from menu
    action = menu.handleMenu()
    # check if game needs to start
    if (action == menu.STATE_PLAY):
        # create game
        game = PongGame(input, settings.getMaxScore(), settings.getBallSpeed(),