def menu(filename): """ Start the menu component of the game """ planet, rover = load_level(filename) while True: #use infinity loop to get command, command can be one or #two characters command = input().split() #cut the command if command[0] == "SCAN": #use scan fuction print() rover.scan(command[1]) print() elif command[0] == "MOVE": #use move fuction rover.move(command[1], command[2]) elif command[0] == "WAIT": #use wait fuction rover.wait(command[1]) elif command[0] == "STATS": #use statistic fuction print() rover.statistic() print() elif command[0] == "FINISH": #use finish fuction and break print() rover.finish() print() break else: print() print("No menu item") print()
def menu_start_game(filepath): # start the game with the given file path file_info = (load_level(filepath)) if file_info == False: return False else: planet, rover = file_info[0], file_info[1] return (planet, rover)
def menu_start_game(filepath): """ Will start the game with the given file path """ #make planet, tile, and rover objects pla = load_level(filepath)[0] til = load_level(filepath)[1] rov = load_level(filepath)[2] # produce tiels on planet pla.make_tiles(til) # user interation menu game_run = True while game_run: user_input = input() if user_input == "SCAN shade": scan_shade(pla, til, rov) rov.track_tiles(pla) elif user_input == "SCAN elevation": scan_elevation(pla, til, rov) rov.track_tiles(pla) if user_input.startswith("SCAN"): if "elevation" not in user_input and "shade" not in user_input: print("Cannot perform this command") elif user_input == "FINISH": rov.get_explored(pla) menu() elif user_input.startswith("MOVE"): direction = user_input[5] cycles = user_input[7:] move(pla, til, rov, direction, cycles) elif user_input == "STATS": print() print("Explored: {}%".format(int(rov.tile_explored / pla.dim * 100))) print("Battery: {}/100".format(rov.battery)) print() elif user_input.startswith("WAIT"): cycles = user_input[5:] if not pla.tiles[rov.get_pos_y()][rov.get_pos_x()].is_shaded(): rov.add_battery(cycles) if rov.battery > 100: rov.set_battery(100)
def menu_start_game(filepath): ##Attempts to begin game, checks if valid file try: play = loader.load_level(filepath) if play == False: print("\nUnable to load level file\n") menu() gameplay(play) except IOError: print("\nLevel file could not be found\n") menu()
def _start_game(self): path = tk.simpledialog.askstring("Mario", "Configuration file:") self._game = loader.load_level(path) if self._game == None: tk.messagebox.showerror("Error", "Configuration file wrong.") self._master.destroy() # World builder world_builder = WorldBuilder( BLOCK_SIZE, gravity=(0, int(self._game["==World=="]["gravity"])), fallback=create_unknown) world_builder.register_builders(BLOCKS.keys(), create_block) world_builder.register_builders(ITEMS.keys(), create_item) world_builder.register_builders(MOBS.keys(), create_mob) self._builder = world_builder self._current_level = self._game["==World=="]['start'] self._world = load_world(self._builder, self._current_level) # Set tunnel/goal Flagpole._next_level = self._game[("==" + self._current_level + "==")]["goal"] Tunnel._next_level = self._game[("==" + self._current_level + "==")].get("tunnel", None) self._player = Player( max_health=int(self._game["==Player=="]["health"])) print(self._player.get_shape()) self._world.add_player(self._player, int(self._game["==Player=="]["x"]), int(self._game["==Player=="]["y"]), int(self._game["==Player=="]["mass"])) self._max_speed = int(self._game["==Player=="]["max_velocity"]) self._setup_collision_handlers() self._renderer = AnimatedMarioViewRenderer(BLOCK_IMAGES, ITEM_IMAGES, MOB_IMAGES) # Into Animated size = tuple( map(min, zip(MAX_WINDOW_SIZE, self._world.get_pixel_size()))) self._view = GameView(self._master, size, self._renderer) self._view.pack() self._status_view = StatusView(self._master, int(self._game["==Player=="]['health']), 0) self.bind()
def menu_start_game(filepath): """ Will start the game with the given file path """ is_levelcorrect, name, width, height, rover_cor, tiles = loader.load_level( filepath) if is_levelcorrect: plant = planet.Planet(name, width, height, tiles) rov = rover.Rover(rover_cor, plant) while not rov.isfinish: user_behavior = input("2") ##"Please choose what you want to do:\n1.SCAN <type>\n2.MOVE <direction> <sycles>\n3.WAIT <cycles>\n4.FINISH" # user_behavior="MOVE 10" input_elements = user_behavior.split(" ") if user_behavior.startswith("SCAN"): # input_elements=user_behavior.split(" ") if len(input_elements) == 2: rov.scan(input_elements[1]) else: print("Please input right command!") elif user_behavior.startswith("MOVE"): if len(input_elements) == 3: rov.move(input_elements[1], input_elements[2]) #rov.stats() else: print("Please input right command!") elif user_behavior.startswith("WAIT"): if len(input_elements) == 2: rov.wait(input_elements[1]) #rov.stats() else: print("Please input right command!") elif user_behavior.startswith("STATS"): if len(input_elements) == 1: rov.stats() else: print("Please input right command!") elif user_behavior.startswith("FINISH"): if len(input_elements) == 1: rov.finish() else: print("Please input right command!") else: print("Please input right command!")
def menu_start_game(filepath): """ Will start the game with the given file path """ planet = load_level(filepath) if planet is None: menu() while True: user_input = input() if user_input == "FINISH": print("") print("You explored {}% of {}".format( planet.get_percent_explored(), planet.get_name())) print("") return elif user_input == "STATS": print("DO STATS") elif user_input.startswith("MOVE"): input_list = user_input.split() direction = input_list[1] cycles = int(input_list[2]) move(planet, direction, cycles) elif user_input.startswith("WAIT"): input_list = user_input.split() cycles = int(input_list[1]) print("DO WAIT") elif user_input.startswith("SCAN"): if user_input == "SCAN shade": scan_shade(planet) elif user_input == "SCAN elevation": scan_elevation(planet) else: print("Cannot perform this command") else: print("Cannot perform this command")
def menu_start_game(filepath): """ Will start the game with the given file path """ load_level(filepath)
def setup(this): # Test level this.level = loader.load_level("entrancelvl.xml") this.level.set_tiles("tiles.xml") this.level.setup_tile_grids() for node in this.level.nodes: if (node.name == "scenery"): app = loader.load_appearance_factory(node.properties["app"]) obj = scene.Object(app) this.level.add_to_grid(obj, float(node.properties["depth"])) obj.gridPos = node.pos dust = Dust() this.level.background.add(dust) dust.gridPos = (13, 18) wraith = scene.Object(loader.load_appearance_factory("wraith")) this.level.midground.add(wraith) wraith.app.set_action("Idle") wraith.depth = 0 wraith.gravity = False wraith.gridPos = (20.5, 12.8) wraith.starty = wraith.pos[1] #st = effects.StoneObject(wraith) #st.replace_object() obj = scene.Creature(loader.load_appearance_factory("naga")) this.level.midground.add(obj) #obj.app.set_action("Walk") obj.app.direction = "east" obj.depth = 0 #obj.vel_x = 110 #obj.renderShadow = True #obj.gravity = False obj.gridPos = (14.5, 12.9) obj.set_fsm(NagaFSM()) #obj = scene.Object(loader.load_appearance_factory("blob")) #this.level.midground.add(obj) #obj.depth = 0 #obj.vel_x = 0 #obj.gridPos = (15.5, 12.8) #obj.set_fsm(BlobFSM()) this.gameInput = GameInput() #this.player.connect_input(gameInput) # Create the character this.player = Character(appf=loader.load_appearance_factory("wizard")) this.player.renderShadow = True this.level.midground.add(this.player) this.player.set_fsm(PlayerFSM(this.gameInput)) (x, y) = this.level.find_node("player start").pos this.player.gridPos = (x, y) #set_grid_pos((x, y)) #this.player.gridPos = (4,5) # Create a basic background this.backgroundImg = pygame.Surface(this.disp.get_size()).convert() this.backgroundImg.fill((0,0,0))