Untitled
unknown
plain_text
a year ago
1.8 kB
0
Indexable
Never
# Very Basic Text-based Minecraft "Clone" # Initialize player position player_position = [0, 0, 0] # Initialize world dimensions world_width = 10 world_height = 5 world_depth = 10 # Create a world filled with air blocks world = [[[0 for _ in range(world_depth)] for _ in range(world_height)] for _ in range(world_width)] # Place a stone block at the player's position def place_block(x, y, z, block_type): if 0 <= x < world_width and 0 <= y < world_height and 0 <= z < world_depth: world[x][y][z] = block_type # Print the world def print_world(): for y in range(world_height): print("Layer", y) for z in range(world_depth): for x in range(world_width): block_type = world[x][y][z] if block_type == 0: print(".", end="") elif block_type == 1: print("#", end="") print() print() # Main game loop while True: print_world() # Get player input action = input("Enter an action (move/build/quit): ").lower() if action == "quit": print("Goodbye!") break elif action == "move": direction = input("Enter a direction (up/down/left/right): ").lower() if direction == "up": player_position[1] += 1 elif direction == "down": player_position[1] -= 1 elif direction == "left": player_position[0] -= 1 elif direction == "right": player_position[0] += 1 elif action == "build": x = int(input("Enter X coordinate: ")) y = int(input("Enter Y coordinate: ")) z = int(input("Enter Z coordinate: ")) block_type = int(input("Enter block type (0=air, 1=stone): ")) place_block(x, y, z, block_type)