def main(): r_instance.R = Robot() set_debug_mode(True) dump_battery() # Initialise modules task.pool = task.TaskPool() control.control = control.Control() vision.vision = vision.Vision() arduino_interface.arduino = arduino_interface.Arduino() game_map.game_map = game_map.Map() # Move initial token task.pool.execute(control.MoveTask(1.2)) task.pool.execute(control.MoveTask(-0.6)) tokens = vision.vision.capture()[0] our_marker_id = 0 if len(tokens) > 0: our_marker_id = tokens[0].info.code log("Robot", "our_marker_id = {0}".format(our_marker_id)) task.pool.execute(control.MoveTask(-0.7)) # Look at remaining tokens and move into them task.pool.execute(control.RotateTask(-math.pi * 0.35)) # Attempt to correct itself task.pool.execute(TokenCorrection(our_marker_id)) task.pool.execute(control.MoveTask(0.775)) for i in xrange(2): task.pool.execute(control.RotateTask(math.pi * 0.4, 3.0)) task.pool.execute(control.MoveTask_Stepper(2.0, 3.0, 8)) """ # Move away, turn 180 degrees then calibrate task.pool.add( control.MoveTask( -1.5 ) ) task.pool.add( control.RotateTask( -math.pi * 0.5 ) ) task.pool.add( control.MoveTask( 2, 0.75 ) ) # Now we know where we are, move to where our tokens reside and grab one target_point = game_map.game_map.starting_position target_point.x = 8 - target_point.x task.pool.add( FigureOutPosition() ) task.pool.add( MoveToNextPoint( target_point ) ) task.pool.add( SearchForToken() ) task.pool.add( control.RotateTask( -math.pi * 0.5 ) ) task.pool.add( control.MoveTask( 2 ) ) task.pool.add( control.MoveTask( -1 ) ) # Move to the middle square task.pool.add( FigureOutPosition() ) task.pool.add( MoveToNextPoint( Position( 5, 5 ) ) ) """ # Enter the main loop task.pool.execute(task.ExitLoop()) task.pool.run() # Final words.. log("Robot", "Task queue finished executing, exiting...") dump_battery()
def test_map_validity(): """Ensure that map remains valid even when generating new terrain""" map_var = game_map.Map() for i in range(0, variables.MAP_WIDTH): map_var.step() for i in range(0, variables.MAP_WIDTH): assert map_var.map[i] >= 0 and map_var.map[i] <= 10
def restart(self): pro = self.load_pro("game_properties.json") self.map = game_map.Map(pro["map"]) self.entity_list = [] self.init_players(pro["players"], pro["map"]["gravity"]) self.camera = Camera() self.camera.follow(self.entity_list[0]) self.resize() self.entity_list[0].rect.x += 32
def __init__(self): """ Initialize game state for a new game""" self.game_map = gm.Map() self.player = p.Player(8, self.game_map.map[8]) self.speed = 0 terminal.save() self.inpoll = select.poll() self.inpoll.register(stdin, select.POLLIN) self.score = 0
def __init__(self, game_window, loaded_map=None): super().__init__(game_window) if loaded_map != None: self.map = loaded_map else: # not map loaded # creating a new one self.map = game_map.Map(settings.default_mapsize, settings.default_mapsize, gw=self.gw)
def mouse_input(self, mx, my, dx, dy): hit = self.check_buttons(mx, my) if hit != None: if hit.id == self.button_new.id: print("create new map...") self.gw.change_menu(Mapedit_modeselect(self.gw)) for mb in self.buttons_maps: if hit.id == mb.id: #load that map sd = savedata.Savedata("maps/" + hit.text + "/", "mapdata") sd.load() loaded_map = game_map.Map(gw=self.gw, savedata=sd) sd.save() self.gw.change_menu(Mapedit_modeselect( self.gw, loaded_map))
def main(): game_manager = dungeon_master.Dungeon_Master( ) #game manager is a reference variable, Dungeon Master creates an object...game_manager points to the object (colloquially, game_manager is also called an object...but to be 100% correct, game_manager is a reference variable) game_manager.create_enemies() game_manager.game_map = game_map.Map(game_manager.enemies) game_manager.create_player() game_manager.game_map.map_entrance.room_content.player = game_manager.player game_manager.clear_terminal() while (True): game_manager.print_current_room_info() player_action = game_manager.request_and_handle_player_action() if (player_action.lower() == 'exit'): print( "Thank you for playing \"Knife in Chicago\".\nBe sure to smash that like button and subscribe for more content!\nhttps://www.youtube.com/channel/UCyRSaiIh7wFL9VhShOqSNUw\nShoutouts: Duke, because he basically made this whole thing, heh." ) break
game_state.screen.blit(game_state.active_map.background.image, [background_left, background_top]) if selected_tile is not None: selected_coords = utilities.get_screen_coords(selected_tile.column, selected_tile.row, game_state.active_map.x_shift, game_state.active_map.y_shift, background_top, background_x_middle) game_state.screen.blit(art.selected_tile_image, [selected_coords[0], selected_coords[1]]) game_state.active_map.draw_to_screen(game_state.screen) population_stamp = tiny_font.render("Pop:{0}".format(population), True, utilities.colors.white) mouse_stamp = tiny_font.render("{0}".format(mouse_pos), True, utilities.colors.white) game_state.screen.blit(message, [game_state.screen_width / 2 - (message.get_width() / 2), 2]) game_state.screen.blit(population_stamp, [2, 2]) game_state.screen.blit(mouse_stamp, [2, 14]) pygame.display.flip() game_state.clock.tick(60) game_state.time += 1 game_state = GameState(1000, 600) game_state.active_map = game_map.Map((20, 20), (game_state.screen_width, game_state.screen_height)) game_state.active_map.map_generation() main(game_state)
def generate_map(self, size_x, size_y): # TODO: Fancify via kwargs return game_map.Map(size_x, size_y)
win_w = 600 win_h = 800 win = pygame.display.set_mode((win_w, win_h)) bachground = pygame.Surface((win_w, win_h)) boss_screen = pygame.Surface((win_w, win_h)) font = pygame.font.Font("font\\pixle_font\\Pixle_Font.ttf", 24) attk_exists = False attk_timer = 2 attk_type = 0 mode = "title" leaderboard = Leaderboard.Leaderboard() clock = pygame.time.Clock() game_ui = gameui.GameUI(win) ball = ball.Ball(0, 0, win, leaderboard) paddle = paddle.Paddle(win, 400, 700, ball) cur_map = game_map.Map("BossMaps\\Litch.tmx") background = pygame.image.load("images\\Background.png") done = False collide_list = [ball] left_attk = None atk_volume = 0.8 hit_sound_dict = { 0: pygame.mixer.Sound("Sounds\\hit_0.ogg"), 1: pygame.mixer.Sound("Sounds\\hit_1.ogg"), 2: pygame.mixer.Sound("Sounds\\hit_2.ogg"), 3: pygame.mixer.Sound("Sounds\\hit_3.ogg"), 4: pygame.mixer.Sound("Sounds\\hit_4.ogg") } dash_sound_dict = { 0: pygame.mixer.Sound("Sounds\\Dash_0.ogg"),
def test_map_instantiation(): """Make sure that map instantiation creates a map of a valid size""" map_var = game_map.Map() assert len(map_var.map) == variables.MAP_WIDTH
if selected_tile: st_pixel_coordinates = util.get_screen_coords(map_xy[0], map_xy[1]) st_screen_coordinates = st_pixel_coordinates[ 0] + game_state.background_x_middle + ( tile_width / 2) - 20, st_pixel_coordinates[1] + game_state.background_top screen.blit(art.selected_tile_image, [st_screen_coordinates[0], st_screen_coordinates[1]]) pygame.display.flip() screen_width = 800 screen_height = 600 game_state = state.GameState(screen_width, screen_height) game_state.active_map = game_map.Map([25, 25], [screen_width, screen_height]) game_state.active_map.mapgen() new_tree = plant.Tree(0, 0, game_state.active_map.game_tile_rows[0][0]) game_state.active_map.plants.append(new_tree) def main(): active_map = game_state.active_map active_map.x_shift = game_state.screen_width / 2 - ( game_state.background_width / 2) active_map.y_shift = game_state.screen_height / 2 - ( game_state.background_height / 2) while True: pos = pygame.mouse.get_pos() map_xy = util.get_map_coords(pos, game_state.active_map.x_shift, game_state.active_map.y_shift,