Esempio n. 1
0
 def __init__(self, name, ui):
     self.name = name
     self.puzzels = []
     self.active = False
     self.done = False
     self.timer = pg.TimerObject()
     self.container = pg.FromDict(ui)
Esempio n. 2
0
 def __init__(self, name):
     self.name = name
     self.container = pg.Container(self.name + "Container",
                                   **TEMPLATE["SubContainer"])
     self.butContainer = pg.Container(self.name + "PuzButContainer",
                                      **ESPUI["ButtonContainer"])
     self.readyText = pg.Text(self.name + "ReadyText",
                              **ESPUI["SignedText"])
     self.readyText.text = "Ready: NO"
     self.container.addObject(self.readyText)
     self.container.addObject(self.butContainer)
     self.esps = []
     self.ready = False
     puzzleList.append(self)
Esempio n. 3
0
 def addESP(self, esp):
     self.esps.append(esp)
     self.but = self.container.addObject(
         pg.Button(self.name + esp.name + "Button",
                   **TEMPLATE["MiddleButton"]))
     self.but.text = esp.name
     self.butContainer.addObject(self.but)
def on_message(client, userdata, msg):
    # Convert the message to string. Original it is a byte printed as b'msg'
    msg.payload = str(msg.payload)[2:-1]
    print("New Message -> Topic: " + msg.topic + " Payload: " +
          str(msg.payload))
    if msg.topic == TOPICLIST[0]:
        pg.PlaySound(msg.payload)
Esempio n. 5
0
    def __init__(self, **kwargs):
        self.name = kwargs["sign"]
        self.topic = kwargs["topic"]
        self.container = pg.Container(self.name + "ESPContainer",
                                      **ESPUI["MainContainer"])
        self.butContainer = pg.Container(self.name + "ESPButContainer",
                                         **ESPUI["ButtonContainer"])
        self.container.addObject(self.butContainer)
        self.textbox = self.container.addObject(
            pg.TextBox(self.name + "ESPMqttTextBox",
                       **ESPUI["ESPMqttTextBox"]))
        self.container.title = self.name
        self.signedtext = pg.Text(self.name + "ESPsignedText",
                                  **ESPUI["SignedText"])
        self.container.addObject(self.signedtext)
        self.signed = False
        TOPICLIST.append(self.topic)
        ESPlist.append(self)

        if "outputs" in kwargs:
            pg.FromDict(kwargs["outputs"], self.butContainer)
Esempio n. 6
0
        CodeCheck("#")


pg.KeyMethod = keymethod
keywordlist = "null t1 t2 b1 b2	kr	kl	rSw	rP f1 f2 time repeat".split()
#0	t1 	t2 	b1	b2	kr	kl	rSw	rP	f1	f2 time repeat
orderlist = [
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 5],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0],
    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]

inputTimer = pg.TimerObject()

inputstate = [0] * 13

#Skip first command
state = 1
counter = 0


def checkInput(inp, msg):
    global state
    global counter
    print(inp + msg)
    if inp in keywordlist:
        inp_num = keywordlist.index(inp)
        inputstate[inp_num] = int(msg)
Esempio n. 7
0
                if msg.payload == esp.name:

                    DEBUGBOX.addLine("ESP found: " + esp.name)
                    esp.Sign()
                    break
            else:
                DEBUGBOX.addLine("ESP unknown")
        for p in puzzleList:
            p.checkReady()


#Connect to the broker
MQTTConnect(BROKERIP, PORT, on_connect, on_message)

#init pygame from the PygameUI module
pg.PyInit(1080, 720, FULLSCREENMODE=True)

gameTimer = pg.TimerObject()

pg.FromDict(HEADER)
pg.FromDict(MAINWINDOW)
DEBUGBOX = pg.TextBox("MainDebugTextBox", **TEXTBOXES["MainDebugTextBox"])

#Set button functions
pg.ObjectDict["NextRoomButton"].function = lambda: NextRoom()
pg.ObjectDict["MainWindowButton"].function = lambda: SetNewMainActiveBox(
    pg.ObjectDict["MainContainer"])
pg.ObjectDict["ResetButton"].function = lambda: resetESPS()
# pg.ObjectDict["StartGameButton"].function=lambda: StartGame()
pg.ObjectDict["FakeESPButton"].function = lambda: FakeAll()
    print("Connected with result code " + str(rc))
    for topic in TOPICLIST:
        client.subscribe(topic)  # Subscribe to the topic


def on_message(client, userdata, msg):
    # Convert the message to string. Original it is a byte printed as b'msg'
    msg.payload = str(msg.payload)[2:-1]
    print("New Message -> Topic: " + msg.topic + " Payload: " +
          str(msg.payload))
    if msg.topic == TOPICLIST[0]:
        pg.PlaySound(msg.payload)


#Connect to the broker
MQTTConnect(BROKERIP, PORT, on_connect, on_message)

#init pygame from the PygameUI module
pg.PyInit(1080, 720)

gameloop = True


def game():
    pass


while gameloop:
    game()
    gameloop = pg.GameLoop()