wip, might not be good
This commit is contained in:
parent
f53879f961
commit
6d5bfaeeda
63 changed files with 1897 additions and 93 deletions
84
wyatt.py
Normal file
84
wyatt.py
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
import random
|
||||
import sys
|
||||
|
||||
# Initialize player attributes
|
||||
player = {
|
||||
"name": input("Enter your character's name: "),
|
||||
"health": 100,
|
||||
"food": 100,
|
||||
"x": 5,
|
||||
"y": 5,
|
||||
"day": 1,
|
||||
}
|
||||
|
||||
# Define game resources
|
||||
resources = {
|
||||
"food": 50,
|
||||
"water": 50,
|
||||
}
|
||||
|
||||
# Define game constants
|
||||
MAP_WIDTH, MAP_HEIGHT = 20, 10
|
||||
PLAYER_CHAR = "(o)"
|
||||
ENEMY_CHAR = "(?)"
|
||||
|
||||
# Game loop
|
||||
while player["health"] > 0:
|
||||
# Create the game map
|
||||
game_map = [[" " for _ in range(MAP_WIDTH)] for _ in range(MAP_HEIGHT)]
|
||||
game_map[player["y"]][player["x"]] = PLAYER_CHAR
|
||||
|
||||
# Place enemies randomly on the map
|
||||
for _ in range(random.randint(1, 3)):
|
||||
enemy_x = random.randint(0, MAP_WIDTH - 1)
|
||||
enemy_y = random.randint(0, MAP_HEIGHT - 1)
|
||||
game_map[enemy_y][enemy_x] = ENEMY_CHAR
|
||||
|
||||
# Print the game map
|
||||
for row in game_map:
|
||||
print("".join(row))
|
||||
|
||||
print(f"\nDay {player['day']}")
|
||||
print(f"Name: {player['name']}")
|
||||
print(f"Health: {player['health']} HP {'*' * player['health']}")
|
||||
print(f"Food: {player['food']} Hunger {'*' * player['food']}")
|
||||
print(f"Coordinates: ({player['x']}, {player['y']})")
|
||||
|
||||
# Player input for movement
|
||||
move = input("Move (W/A/S/D): ").upper()
|
||||
|
||||
# Update player position based on input
|
||||
if move == "W" and player["y"] > 0:
|
||||
player["y"] -= 1
|
||||
elif move == "S" and player["y"] < MAP_HEIGHT - 1:
|
||||
player["y"] += 1
|
||||
elif move == "A" and player["x"] > 0:
|
||||
player["x"] -= 1
|
||||
elif move == "D" and player["x"] < MAP_WIDTH - 1:
|
||||
player["x"] += 1
|
||||
|
||||
# Consume resources
|
||||
player["food"] -= random.randint(5, 15)
|
||||
|
||||
# Check if the player has enough resources
|
||||
if player["food"] < 0:
|
||||
player["food"] = 0
|
||||
player["health"] -= 10
|
||||
|
||||
# Check if the player encounters an enemy
|
||||
if game_map[player["y"]][player["x"]] == ENEMY_CHAR:
|
||||
enemy_damage = random.randint(10, 30)
|
||||
player["health"] -= enemy_damage
|
||||
print(f"You encountered an enemy and took {enemy_damage} damage!")
|
||||
|
||||
# Rest for the day
|
||||
player["day"] += 1
|
||||
|
||||
# Exit the game if health reaches zero
|
||||
if player["health"] <= 0:
|
||||
print("Game Over. You did not survive.")
|
||||
break
|
||||
|
||||
input("Press Enter to continue to the next day...")
|
||||
|
||||
sys.exit()
|
||||
Loading…
Add table
Add a link
Reference in a new issue