def checkSecondaryMenuClick(): global isInSecondaryMenu if quitRec.collidepoint(pygame.mouse.get_pos()): pygame.quit() return True if saveRec.collidepoint(pygame.mouse.get_pos()): pygame.draw.rect(window, (255, 255, 0), saveRec) Save.Save(player, map, playerInventory, map.index(currentRoom)) isInSecondaryMenu = False
def Photo(e, tred, token, flag): try: pipe = rs.pipeline() color = rs.colorizer() ctx = rs.context() dev = ctx.query_devices() i = 0 while True: if dev[i].get_info(rs.camera_info.ip_address) == tred["IP"]: break i = i + 1 if i == len(dev): raise Exception('This camera is not avaiable') cfg = rs.config() cfg.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) cfg.enable_device(dev[i].get_info(rs.camera_info.serial_number)) print("3D cam started.") #Getting the depth sensor's depth scale (see rs-align example for explanation) while e.is_set(): if (synchronizer.Synchro(token) == 1): try: pipe.start(cfg) # This call waits until a new coherent set of frames is available on a device # Calls to get_frame_data(...) and get_frame_timestamp(...) on a device will return stable values until wait_for_frames(...) is called for j in range(0, 15): frames = pipe.wait_for_frames() depth_frame = frames.get_depth_frame() filename = "3D_%d" % (int(time.time())) if (flag == 1): depth_col = color.colorize(depth_frame) depth_data = np.asanyarray(depth_col.get_data(), dtype=np.uint16) Save.Save(filename, depth_data) else: depth_data = np.asanyarray(depth_frame.get_data(), dtype=np.uint16) Save.Savebw(filename, depth_data) print("immagine 3d") tred["acquiredImages"] = tred["acquiredImages"] + 1 tred["timestamp"] = str(time.gmtime().tm_year) + "-" + str( time.gmtime().tm_mon) + "-" + str( time.gmtime().tm_mday) + "T" + str( time.gmtime().tm_hour) + ":" + str( time.gmtime().tm_min) + ":" + str( time.gmtime().tm_sec) pipe.stop() synchronizer.Update() except Exception as exc: tred["error"] = str(exc) synchronizer.Update() break except Exception as err: tred["error"] = str(err) tred["status"] = "error" synchronizer.removefromQueue(token) e.clear()
def load(number): try: saveFile = io.open("Saves/save" + str(number) + ".txt", "r", encoding="UTF-8") lines = saveFile.readlines() saveFile.close() s = Save.Save( loadImage(number), # image lines[0][0:len(lines[0]) - 1], # type lines[1][0:len(lines[1]) - 1], # scene int(lines[2][0:len(lines[2]) - 1]), # line lines[3], # date de creation number) return s except OSError: return None
def Photo(e, usb, token, exp): try: cam = xiapi.Camera() #start communication cam.open_device() img = xiapi.Image() #setting exposure if (exp == "auto"): cam.enable_aeag() else: cam.set_exposure(int(exp)) #start data acquisition print('Starting data acquisition...\n') cam.start_acquisition() cam.set_imgdataformat('XI_RGB24') while e.is_set(): if (synchronizer.Synchro(token) == 1): try: cam.get_image(img) data_num = img.get_image_data_numpy(invert_rgb_order=True) filename = 'USB_%d' % (int(time.time())) Save.Save(filename, data_num) print("New usb image...") usb["timestamp"] = str(time.gmtime().tm_year) + "-" + str( time.gmtime().tm_mon) + "-" + str( time.gmtime().tm_mday) + "T" + str( time.gmtime().tm_hour) + ":" + str( time.gmtime().tm_min) + ":" + str( time.gmtime().tm_sec) synchronizer.Update() usb["acquiredImages"] = usb["acquiredImages"] + 1 print("token: " + str(token)) except Exception as exc: usb["error"] = str(exc) synchronizer.Update() #stop data acquisition print('Usb Cam: Stopping acquisition...') cam.stop_acquisition() except Exception as err: usb["error"] = str(err) usb["status"] = "error" synchronizer.removefromQueue(token) e.clear() cam.close_device()
def get(self, controls, thread_num=100, host='127.0.0.1', port=6379): thread_pool = ThreadPoolExecutor(max_workers=thread_num) save = Save.Save(host, port) log = Log.Log() for control in controls: url = control['control_get']['url']['url'] regular = control['control_get']['url']['regular'] pages = control['control_get']['pages'] sleep_time = control['control_get']['sleep_time'] times = control['control_get']['times'] timeout = control['control_get']['timeout'] timeout_num = control['control_get']['timeout_num'] control_catch = control['control_catch'] catch = Catch.Catch(url, control_catch) for page in range(1, pages + 1): page_url = regular % (url, page) thread = thread_pool.submit(self.__get, catch, save, log, page_url, sleep_time, times, timeout, timeout_num) thread_pool.shutdown() save.finish() log.catch_redis_log(self.__num)
def Load_level_1(screen, choice, P, Approval_SpecialDraw, Screen_Diff, ScreeX): #Creates the level L.Screen_DiffX = Screen_Diff[0] L.Screen_DiffY = Screen_Diff[1] if choice == "normal": E1 = level(20, 948, 100, 20, black) El = [E1] L.i = 0 return El, L.i elif choice == "save": import Save L.El, L.EnemyGroup, PowerUpGroup = Save.Save(screen) L.i = 2 return L.El, L.i, L.StarL, L.EnemyGroup, PowerUpGroup elif choice == "custom": if L.w == 0: Trump_Wall = level(screen, 0, 0 - Screen_DiffX, 0 - Screen_DiffY, 40, 1680, black, False, True, Block_Image) Origin_Block = level(screen, 0, -1 - Screen_DiffX, 0 - Screen_DiffY, 1, 1, white, True) L.Done = level(screen, 0, 1480 - Screen_DiffX, 940 - Screen_DiffY, 200, 40, green, True) E1 = level(screen, 0, OPS.width / 2, 948 - Screen_DiffY, 100, 20, black, True) L.El.append(L.Done) L.El.append(E1) L.El.append(Origin_Block) L.El.append(Trump_Wall) L.w = 1 #for i in range(0, random.randint(2,12)): # print("Haga: ", i) # L.Star[i]=SC.Points(screen) # L.StarL.append(L.Star[i]) if pygame.mouse.get_pressed()[0] == True: #Left Click and drag to draw if L.id == 0: L.x, L.y = pygame.mouse.get_pos() print(L.x) print(L.y) L.j = 1 L.id = 1 if pygame.mouse.get_pressed()[2] == True: #Left Click and drag to draw if L.id == 1: E = {} L.x1, L.y1 = pygame.mouse.get_pos() if L.x > L.x1: Tx = L.x L.x = L.x1 L.x1 = Tx if L.y > L.y1: Ty = L.y L.y = L.y1 L.y1 = Ty print(L.x1) print(L.y1) PrevX1 = L.x1 width = L.x1 - L.x height = L.y1 - L.y E[L.st] = level(screen, PrevX1, L.x - ScreeX, L.y, width, height, black, True) L.El.append(E[L.st]) L.st += 1 L.j == 2 L.id = 0 if random.randint(0, 100) < 20: Double = {} Double[L.st] = C.Power_Ups(rand.Randomize("Power_Ups"), random.randint(L.x, L.x1), L.y - 33) Double[L.st].Hitbox(screen) L.Power_UpsGroup.append(Double[L.st]) if pygame.mouse.get_pressed( )[1] == True and L.Cant_Enemy == False: #Middle click to create enemies L.x1, L.y1 = pygame.mouse.get_pos() Enemy = {} Enemy[L.StEnemy] = SC.Enemy(L.x1, L.y1) Enemy[L.StEnemy].Hitbox(screen) L.EnemyGroup.append(Enemy[L.StEnemy]) L.StEnemy += 1 L.T1 = time.clock() L.Cant_Enemy = True if time.clock() - L.T1 > 0.25: L.Cant_Enemy = False if len(L.El) > 1000: L.i = 0 L.El.remove(L.Done) if L.j == 2: L.j == 0 if L.x > 1480 and L.x < 1720 and L.y > 940 and L.y < 1020: L.i = 2 L.El.remove(L.Done) return L.El, L.i, L.StarL, L.EnemyGroup, L.Power_UpsGroup
from GameState import * from Save import * from Record import * pygame.mixer.pre_init(44100, -16, 1, 512) pygame.init() pygame.display.set_caption('Magic Rush') pygame.display.set_icon(ICON) scores = 0 health = 2 game_state = GameState() info = Save() if info.get_data('hs') == 0: info.add('hs', 0) if info.get_data('rec') == 0: info.add('rec', {}) records = Record(info.get_data('rec')) max_scores = info.get_data('hs') def start(): """In accordance with the established states, calls the basic functions. Args: None.
def Load_level_1(screen, choice, P): #Creates the level if choice == "normal": E1 = level(20, 948, 100, 20, black) El = [E1] L.i = 0 return El, L.i elif choice == "save": import Save L.El, L.EnemyGroup = Save.Save(screen) L.i = 2 return L.El, L.i, L.StarL, L.EnemyGroup elif choice == "custom": if L.w == 0: Trump_Wall = level(0, 0, 0, 40, 1680, black, False, True, Block_Image) Origin_Block = level(0, -1, 0, 1, 1, white, True) L.Done = level(0, 1480, 940, 200, 40, green, True) E1 = level(0,40, 948, 100, 20, black, True) L.El.append(L.Done) L.El.append(E1) L.El.append(Origin_Block) L.El.append(Trump_Wall) L.w = 1 Done.cert = Done.draw(screen, P) #for i in range(0, random.randint(2,12)): # print("Haga: ", i) # L.Star[i]=SC.Points(screen) # L.StarL.append(L.Star[i]) if pygame.mouse.get_pressed()[0] == True: #Left Click and drag to draw if L.id == 0: L.x, L.y = pygame.mouse.get_pos() print (L.x) print (L.y) L.j = 1 L.id = 1 if pygame.mouse.get_pressed()[2] == True: #Left Click and drag to draw if L.id == 1: E = {} L.x1, L.y1 = pygame.mouse.get_pos() if L.x > L.x1: Tx =L.x L.x = L.x1 L.x1 = Tx if L.y > L.y1: Ty =L.y L.y = L.y1 L.y1 = Ty print (L.x1) print (L.y1) PrevX1 = L.x1 width = L.x1 - L.x height = L.y1 - L.y E[L.st] = level(PrevX1, L.x, L.y, width, height, black, True) if len(L.El) < 1000: L.El.append(E[L.st]) L.st +=1 L.j == 2 L.id = 0 if pygame.mouse.get_pressed()[1] == True and L.Cant_Enemy == False: #Middle click to create enemies L.x1, L.y1 = pygame.mouse.get_pos() Enemy = {} Enemy[L.StEnemy] = SC.Enemy(L.x1, L.y1) Enemy[L.StEnemy].Hitbox(screen) L.EnemyGroup.append(Enemy[L.StEnemy]) L.StEnemy += 1 L.T1= time.clock() L.Cant_Enemy = True if time.clock() - L.T1 > 0.25: L.Cant_Enemy = False if len(L.El) > 1000: L.i = 0 L.El.remove(L.Done) if L.j == 2: L.j == 0 if L.x > 1480 and L.x < 1720 and L.y > 940 and L.y < 1020: L.i = 2 L.El.remove(L.Done) return L.El, L.i, L.StarL, L.EnemyGroup
def new(self, mapPath): self.mapPath = mapPath self.map = tiledMap(mapPath) self.mapImg = self.map.makeMap(self) self.mapRect = self.mapImg.get_rect() self.camera = Camera(self.mapRect.x, self.mapRect.y) self.frontSprites = pygame.sprite.Group() self.backSprites = pygame.sprite.Group() self.allSprites = pygame.sprite.Group() self.triggers = pygame.sprite.Group() self.holes = pygame.sprite.Group() self.players = pygame.sprite.Group() self.walls = pygame.sprite.Group() self.spikes = pygame.sprite.Group() self.bullets = pygame.sprite.Group() self.enemies = pygame.sprite.Group() self.enemyBullet = pygame.sprite.Group() self.chests = pygame.sprite.Group() self.allUpgrades = pygame.sprite.Group() self.allDrops = pygame.sprite.Group() self.savers = pygame.sprite.Group() self.texts = {} self.hasBoss = False if name == 'nt': if mapPath == '../Maps\\mapBoss1.tmx': self.hasBoss = True else: if mapPath == '../Maps/mapBoss1.tmx': self.hasBoss = True if self.hasBoss: self.boss = BossController(self) for i in self.map.tmdata.objects: if i.name == 'spawn': self.player = Player(self, 1, i.x, i.y) if self.hasBoss: self.boss.setSpawn(i.x, i.y) elif i.name == 'wall': Wall(self, i.x, i.y, i.width, i.height) elif i.name == 'end': End(self, i.x, i.y, i.width, i.height) elif i.name == 'hole': Hole(self, i.x, i.y, i.width, i.height) elif i.name == 'spike': Spike(self, i.x, i.y, i.width, i.height, i.type) elif i.name == 'enemy': if not self.hasBoss: Enemy(self, i.x, i.y, i.width, i.height) else: self.boss.addEnemiesArena(i.x, i.y, i.width, i.height) elif i.name == 'chest': Chest(self, i.x, i.y, i.width, i.height) elif i.name == 'save': Save(self, self.menu, i.x, i.y, i.width, i.height) elif i.name == 'boss': self.boss.setPos(i.x, i.y) elif i.name == 'bossCopy': self.boss.addCopy(i.x, i.y) elif i.name == 'spawn1': self.boss.setSpawn1(i.x, i.y) elif i.name == 'spawn2': self.boss.setSpawn2(i.x, i.y) elif i.name == 'bossSpawn': self.boss.setBossSpawn(i.x, i.y) elif i.name == 'enemyAfter': self.boss.addEnemiesAfter(i.x, i.y) self.hud = Hud(self) self.camera = Camera(self.mapRect.width, self.mapRect.height) print(self.walls) print(self.triggers) print(self.mapsAlreadyPlayed)
file.close() print("Terminado...") print(f'{bot.user.name} estoy en funcionamiento.') @bot.event async def on_error(event, *args, **kwargs): with open('files/err.log', 'a') as f: if event == 'on_message': f.write(f'Unhandled message: {args[0]}\n') else: raise @bot.event async def on_command_error(ctx, error): if isinstance(error, commands.errors.CheckFailure): await ctx.send(f'Error en el comando o falta de permisos.') if __name__ == "__main__": bot.add_cog(Admin()) bot.add_cog(Custom()) bot.add_cog(Extra()) bot.add_cog(Save()) print("Conectando al servidor...") TOKEN = os.getenv('DISCORD_TOKEN') bot.run(TOKEN)