def start(self): self.hud = loading.Loading(my.ENGINE.screen) self.map = map.Map(self.width, self.height, self.seed) self.map.generate() self.hud.setStatus('Carregando entidades...', 80) spawnX = randint(50, self.width - 50) self.player = entities.Player(self, self.playerConfigurations[0], tank.TankDefault(), (spawnX, self.map.getMaxHeight(spawnX))) self.entities = camera.CameraAwareLayeredUpdates( self.player, pygame.Rect(0, 0, self.width, self.height)) self.entities.add( self.map ) # Adicionando o mapa em entidades para poder ser scrollado for i in range(0, self.enemiesCount): x = randint(50, self.width - 50) self.entities.add( entities.Enemy(self, tank.TankDefault(), (x, self.map.getMaxHeight(x)))) self.hud.setStatus('Carregando interface...', 99) self.hud = hud.Hud(self, my.ENGINE.screen) my.ENGINE.interface = self.hud self.turncontroller = turn.TurnController(self) self.turncontroller.start() self.wind = wind.Wind(self) self.running = True
def __init__(self, size=(700, 700)): super().__init__() self.geometrie = collision.Collision() self.x_mouse, self.y_mouse = 0, 0 self.size = size self.fps = 60 self.map = map.Map(self.size, 0) self.map.startPoint, self.map.finishPoint = QPoint(-100, -100), QPoint( -100, -100) self.poly = [] self.distance_min = 20 self.title = 'untitled' self.mode_edition = 0 self.distance_selection = 20 self.selectedPoint = (False, 0) self.style_base = QPen(Qt.white, 2, Qt.SolidLine) self.style_gris = QPen(Qt.gray, 2, Qt.SolidLine) self.style_fin = QPen(Qt.red, 2, Qt.SolidLine) self.style_rouge = QPen(Qt.red, 4, Qt.SolidLine) self.style_vert = QPen(Qt.green, 2, Qt.SolidLine) self.style_jaune = QPen(Qt.yellow, 2, Qt.SolidLine) title_font = QtGui.QFont() title_font.setFamily("Cooper Black") title_font.setPointSize(14) self.initWindow() self.timer = QTimer(self) self.timer.timeout.connect(self.update) self.timer.start(1000 / self.fps)
def _make_update(self, data): if not self._seen_update: self._seen_update = True self._map = map.Map(self._start_data, data) return self._map return self._map.update(data)
def nextMap ( self, currentLevel ): random = False if len(self.mapList) > 0: fullpath = os.path.join('data','map',self.mapList.pop()) try: nextMap = map.Map(fullpath) except: random = True else: random = True if random: mapgenerator = mapgenerate.MapGenerator(MAP_SIZE) mapgenerator.createMap('random.map') fullpath = os.path.join('data','map','random.map') nextMap = map.Map(fullpath) self.currentLevel += 1 return nextMap
def TestIndexMap(): saveMap = map.Map([3, 3, 3, 3], [True, True, True, True], 0) for i in range(0, 3): for j in range(0, 3): for k in range(0, 3): for m in range(0, 3): saveMap[i][j][k][m] = str(i) + str(j) + str(k) + str(m) saveMap.saveMap('Maps/testIndexMap.map')
def __init__( s, screen, level, teams ): cfg = loader.cfgloader.get( level ) s.screen = screen s.level = level s.map = map.Map( cfg['map'] ) s.teams = teams s.cursorSprite = sprite.Sprite( "cursor.sprite" ) s.cursorSprite.setAnim( "normal" )
def gliderTest(): saveMap = map.Map([12, 10], [True, True], 0) saveMap[2][1] = 1 saveMap[3][2] = 1 saveMap[1][3] = 1 saveMap[2][3] = 1 saveMap[3][3] = 1 saveMap.saveMap('Maps/Conways/gliderTest.map')
def main(): header.Meny_DR() global Map global ai_map Map = map.Map() ai_map = ai.Map() g = Game() g.start_choice()
def handleReset(self): self.isRunning = False self.status.setText('Map reset \nChoose your start node') time.sleep(0.1) self.mapa = map.Map(self.mapWidth, self.mapHeight) self.begIsSet = False self.endIsSet = False self.repaint()
def Diagonal2D(): saveMap = map.Map([6, 5], [False, False], 0) saveMap[0][0] = 1 saveMap[1][1] = 1 saveMap[2][2] = 1 saveMap[3][3] = 1 saveMap[4][4] = 1 saveMap.saveMap('Maps/diagonal2d.map')
def __init__(self, simulator): self.simulator = simulator self.map = map.Map() self.algo = algo.algoFactory(self, algoName='LHR') if config.robot_simulation: self.robot = robot_simulator.RobotSimulator(self) self.__do_read() else: self.robot = robot_connector.Connector()
def __init__(self, players): self.map = map.Map() self.nations = {n: nation.Nation(n, self.map) for n in static.NATION_TURN_LIST} self.players = players self.next_investor_player_index = 0 self.nation_to_player_map = {} self.active_nation = self.nations['RUSSIA'] self.bonds_by_player_by_nation = {player.id: {n: [] for n in self.nations} for player in self.players} self.ply_count = 0
def __init__(self, filemap=None): self._conf = config.Config() self._screen = pygame.display.set_mode(self._conf.DISPLAY_SIZE) self._matrix = [[0 for aux in range(self._conf.MAP_DIMX)] for aux2 in range(self._conf.MAP_DIMY)] self._rectMap = map.Map(self._conf.MAP_DIMS, self._conf.RECT_DIMS_px, self._matrix, 'creation') self._currentValue = 1 self._filemap = filemap
def __init__(self, size): super().__init__() self.size = self.width, self.height = size self.image = pygame.Surface(size) self.rect = self.image.get_rect() self.image.fill([255, 0, 255]) self.map_data = map.Map('../assets/maps/map.dat', size).get_map() self.sprite_map = pygame.sprite.Group() self.selected = [] self.draw_map()
def __init__(self): if Interface.__first: Interface.__first = False pygame.init() self.window = pygame.display.set_mode(Interface.__window) self.player_plane = None # self.bg_img = pygame.image.load(Interface.bg_img) self.logo_img = pygame.image.load(Interface.icon_img) self.map = map.Map() self.enemy = [enemy.Enemy() for i in range(6)]
def initialize(self): self.themap = map.Map(self.map_filename[self.currentmap], self.tiles, self.screen, self.view_size_x, self.view_size_y) # initialize the player (size_x, size_y) = self.themap.getSize() start_x = self.tile_size_x start_y = self.tile_size_y * (size_y - 2) self.theguy = guy.Guy(self.tiles, self.themap, self.screen, start_x, start_y)
def __init__(self): self.maps = [] #Creates a 2 dimensional array of maps. for x in range(self.WORLD_WIDTH): ylist = [ ] for y in range(self.WORLD_HEIGHT): ylist.append(map.Map(x,y)) self.maps.append(ylist)
def __init__(self, inputobj, params): self.input = inputobj self.counter = 0 self.params = params self.stepOn = True self.ekf_filter = None self.m_map = map.Map() self.m_ransac = ransac.Ransac() self.end = False self.frame = None pass
def __init__(self): self.sensors = sensors.Sensors() self.map = map.Map(240, 240, 10) self.api = api.API() self.driver = driver.Driver() self.turns = 0 self.direction = True self.LANE_WIDTH = 12 self.FORWARD_DIST = 120 self.PROXIMITY_DIST = 10 self.MIN_UNVISITED_AREA = 10
def newMap(self, x): self.level += 1 self.map = map.Map() self.map.generateMap(int(x / self.map.size[0])) self.map.prepare_landing(x) self.player.position = [x, 1] self.map.addEntity(self.player) self.map.generateMonsters(10 + 2 * self.level, E.DEFAULT_MONSTER) self.map.revealCellsFromEntity(self.player) for entity in self.map.contents: if entity.type == "Monster": entity.chasing = False
def main(): MAP = map.Map(4) MOVE = Move(4) MAP.setTestMap_2() MAP.printMap() # mapchange = MOVE.movedown(MAP) # mapchange = MOVE.moveright(MAP) # mapchange = MOVE.moveleft(MAP) mapchange = MOVE.moveup(MAP) MAP.printMap() print(mapchange)
def Axis2DTest(): saveMap = map.Map([5, 5], [False, False], 0) saveMap[0][0] = 1 saveMap[1][0] = 1 saveMap[2][0] = 1 saveMap[3][0] = 1 saveMap[4][0] = 1 saveMap[0][1] = 1 saveMap[0][2] = 1 saveMap[0][3] = 1 saveMap[0][4] = 1 saveMap.saveMap('Maps/axis2dtest.map')
def load_map(obj): mapp = map.Map() mapp._turn_limit = None if obj['turn_limit'] == 'None' else obj[ 'turn_limit'] mapp._terrain = obj['terrain'] mapp._can_save = obj['can_save'] mapp._can_escape = obj['can_escape'] mapp._max_view_distance = obj['max_view_distance'] mapp._entities = {} for (k, v) in obj['entities'].items(): mapp._entities[k] = load_entity(v) return mapp
def map(self): poligonn = map.Map(20, 20, 10, 10, (100, 100, 100), 5) self.keydown_handlers[pygame.K_LEFT].append(poligonn.handle) self.keydown_handlers[pygame.K_RIGHT].append(poligonn.handle) self.keydown_handlers[pygame.K_UP].append(poligonn.handle) self.keydown_handlers[pygame.K_DOWN].append(poligonn.handle) print(self.keydown_handlers) ## self.keyup_handlers[pygame.K_LEFT].append(poligonn.handle) ## self.keyup_handlers[pygame.K_RIGHT].append(poligonn.handle) self.objects.append(poligonn)
def update(): for game_objects in game_world.all_objects(): game_objects.update() global floorTriggers if floorTriggers is not None: if collide(floorTriggers, warrior): print('go to next stage') global maps global items global monsters warrior.x, warrior.y = TILE_SIZE * 2, 16 + TILE_SIZE * 12 game_world.remove_object(maps) maps = map.Map(2) game_world.add_object(maps, 0) maps.set_center_object(warrior) warrior.set_background(maps) boss = BossMonster(TILE_SIZE * 16, 16 + TILE_SIZE * 12) boss.set_background(maps) game_world.add_object(boss, 0) for item in items: game_world.remove_object(item) for monster in monsters: game_world.remove_object(monster) game_world.remove_object(floorTriggers) if items is not None: for item in items: if collide(item, warrior): eatSound.play(1) warrior.score += 3 print("collide") game_world.remove_object(item) items.remove(item) if item.var == 1: warrior.hp += clamp(10, warrior.maxHp // 5, 999) elif item.var == 2: warrior.atkDamage += 5 elif item.var == 3: warrior.maxHp += 10 warrior.hp += 10 for game_object in game_world.all_objects(): if game_object.hp <= 0: game_object.isDead = True if once.call == 0: once.print(game_object.type) once.call = 1 global hpPercent hpPercent = int(50 * warrior.hpPercent)
def new_level(map_w, map_h, entities, G_TRAP_CHARS, G_GLYPH_CHARS, player_floor=1): level_map = map.Map(map_w, map_h) paper_map = map.make_map(level_map, entities, G_TRAP_CHARS, player_floor) paper_map.walls_and_pits() for y in range(map_h): for x in range(map_w): if paper_map.t_[x][y].type == "wall": paper_map.t_[x][y].char += 64 if paper_map.t_[x][y].type == "pit": paper_map.t_[x][y].fg = COLORS["map-black"] paper_map.t_[x][y].bg = COLORS["map-white"] paper_map.t_[x][y].char += 64 if paper_map.t_[x][y].type == "floor": paper_map.t_[x][y].char = 32 if paper_map.t_[x][y].type == "solidwall": paper_map.t_[x][y].char = 32 paper_map.t_[x][y].fg = COLORS["map-white"] paper_map.t_[x][y].bg = COLORS["map-white"] for entity in entities: RAND_CHARS = [CHARS["gold"]] RAND_CHARS.extend(G_GLYPH_CHARS) if ((entity.x == x) and (entity.y == y) and entity.istrap): if entity.dispname not in ("gold", "Boulder", "stairs", "artifact"): paper_map.t_[x][y].char = G_GLYPH_CHARS[ entity.traptype] paper_map.t_[x][y].fg = COLORS["map-red"] paper_map.t_[x][y].type = "trap" elif entity.dispname == "gold": paper_map.t_[x][y].char = CHARS["gold"] paper_map.t_[x][y].fg = COLORS["map-red"] elif entity.dispname == "stairs": paper_map.t_[x][y].char = CHARS["stairs"] paper_map.t_[x][y].fg = COLORS["map-green"] elif entity.dispname == "artifact": paper_map.t_[x][y].char = CHARS["artifact"] paper_map.t_[x][y].fg = COLORS["map-green"] if entity.dispname not in ("stairs", "artifact"): if randint(0, player_floor) > 1: paper_map.t_[x][y].char = RAND_CHARS[randint( 0, len(RAND_CHARS) - 1)] return level_map, paper_map
def __load_next_map(self): '''Cleans all information from previous map and loads new one''' self.player = player.Player() self.enemies = [] self.map_ = map.Map(self.player) self.map_.load(f'{self.map_path}\\map{str(self.current_map)}.map') self.__load_enemies() self.graphics = graphics.Graphics(self.player, self.enemies, self.map_, self.current_map, len(self.maps)) self.movement = player_movement.Movement(self.player, self.enemies, self.map_, self.graphics) self.event_handler = events.EventHandler(self.player, self.enemies, self.map_, self.graphics, self.movement)
def _start_game(self): self._map = map.Map(self._window, self._map, self._scale, self._effect) if self._music: pygame.mixer.music.load("ressources/audio/music/game.ogg") pygame.mixer.music.play(loops=-1) pygame.key.set_repeat(1, 50) while self._playing: # try: self._clock.tick(60) if not self._recv_q.empty(): data = self._recv_q.get() self._received_data_proccess(data) for event in pygame.event.get(): if event.type == pygame.QUIT: self._send_q.put(("QUT", "")) pygame.quit() quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: self._send_q.put(("QUT", "")) pygame.quit() quit() if event.key == pygame.K_RETURN: self._send_q.put(("RST", "")) if not self._ended: if event.key == pygame.K_DOWN or event.key == pygame.K_s: self._send_q.put(("MOV", "B")) if event.key == pygame.K_UP or event.key == pygame.K_w or event.key == pygame.K_z: self._send_q.put(("MOV", "T")) if event.key == pygame.K_LEFT or event.key == pygame.K_a or event.key == pygame.K_q: self._send_q.put(("MOV", "L")) if event.key == pygame.K_RIGHT or event.key == pygame.K_d: self._send_q.put(("MOV", "R")) if event.key == pygame.K_SPACE: self._send_q.put(("BMB", "")) self._map.update() self._players_list.update() if self._ended: self._window.blit(self._winner[0], self._winner[1]) pygame.display.flip() pygame.quit() lobby.Lobby(self._send_q, self._recv_q, self._players_data, self._num)
def callback(self, raw_msgs): position = raw_msgs.pose.pose.position x = position.x y = position.y current_point = [x, y] # math transformation orientation = raw_msgs.pose.pose.orientation quaternion = [ orientation.x, orientation.y, orientation.z, orientation.w ] euler = tf.transformations.euler_from_quaternion(quaternion) self.yaw = euler[2] def rot(yaw): return np.array([[math.cos(yaw), -math.sin(yaw)], [math.sin(yaw), math.cos(yaw)]]) map = myMap.Map() lane = map.lanes[self.lane] goal_point = lane.lookahead_point(current_point, 0.5)[0] vector = goal_point - current_point map_point = np.matmul(rot(-self.yaw), vector) self.setpoint = np.arctan2(map_point[1], map_point[0]) # np.arccos(np.dot(current_point,goal_point)/(np.linalg.norm(current_point)*np.linalg.norm(goal_point))) Kp = 2.0 Ki = 0.0 Kd = 0.2 error = self.setpoint #- self.yaw self.acc_error = self.acc_error + error #accumulator for error current_time = rospy.Time.now() delta_time = (current_time - self.pre_time).to_sec() #Kp*error Ki*area Kd*slope PID = Kp * error + Ki * self.acc_error * delta_time + Kd * ( error - self.pre_error) / delta_time # PID = int(round(PID)) self.pre_time = current_time self.pre_error = error #pid value to steering message str_com = NormalizedSteeringCommand() str_com.value = PID self.str_pub.publish(str_com) #pub speed sp = SpeedCommand() sp.value = 0.3 self.speed_pub.publish(sp)
def initScreen(self): # try: # self.surface = pygame.display.set_mode( self._theme['screen']['size'] ) # except Exception: # pass # Fill background self._background = pygame.Surface(self.surface.get_size()) self._background = self._background.convert() self._background.fill((255, 255, 255)) self._display = TDisplay(self.surface) vbox = TVBoxLayout() tb = TToolbar() button1 = TButton('Connect', theme.Theme.loadImage('icon_connect.png')) button2 = TButton('Start', theme.Theme.loadImage('icon_connect.png')) button3 = TButton('Send armies', theme.Theme.loadImage('icon_connect.png')) button4 = TButton('1. Regroup', theme.Theme.loadImage('icon_connect.png')) button5 = TButton('2. Get card', theme.Theme.loadImage('icon_connect.png')) button6 = TButton('3. End turn', theme.Theme.loadImage('icon_connect.png')) button7 = TButton('View players', theme.Theme.loadImage('icon_connect.png')) tb.addWidget(button1) tb.addWidget(button2) tb.addSeparator() tb.addWidget(button3) tb.addWidget(button4) tb.addWidget(button5) tb.addWidget(button6) tb.addSeparator() tb.addWidget(button7) theMap = map.Map(self._theme) theToolbar = toolbar.Toolbar(self._theme['toolbar']) vbox.addWidget(tb) vbox.addWidget(theMap) vbox.addWidget(theToolbar) self.surface = pygame.display.set_mode(vbox.getSize()) self._display.addWidget(vbox) self._display.update() w = TWindow('Connect to server') w.setSize((300, 300)) w.setOrigin((120, 120)) w.update()