Open TIMBER2024 opened 1 month ago
from tkinter import Tk, Label
root = Tk() root.title("TimberTime") label = Label(root, text="Welcome to TimberTime!") label.pack() root.mainloop()
import time import random from tkinter import Tk, Label, Button, messagebox
tree_values = {"Oak": 1, "Pine": 2, "Birch": 3, "Maple": 5} difficulty = {"easy": (60, 0.2), "normal": (45, 0.1), "hard": (30, 0.05)}
def main(): print("Welcome to TimberTime!") print("Get ready to chop some virtual trees!")
trees_chopped = 0
score = 0
game_duration = 60 # Default to normal if not changed by difficulty selection
print("\nGame starts in:")
for i in range(3, 0, -1):
print(f"{i}...")
time.sleep(1)
print("\nGO!")
start_time = time.time()
while time.time() - start_time < game_duration:
input("Press Enter to chop a tree!")
trees_chopped += 1
tree_type = random.choice(list(tree_values.keys()))
score += tree_values[tree_type]
print(f"You chopped down a {tree_type} tree!")
if random.random() < special_chance: # Chance of finding a special item
special_item = random.choice(["Golden Axe", "Magic Seeds", "Woodland Sprite"])
import os
Inside the while loop
elapsed_time = int(time.time() - start_time) remaining_time = game_duration - elapsed_time os.system('cls' if os.name == 'nt' else 'clear') # Clear screen for Windows or Unix print(f"\nTime remaining: {remaining_time} seconds") print(f"Trees chopped: {trees_chopped}\n")
tree_values = {"Oak": 1, "Pine": 2, "Birch": 3, "Maple": 5}
When chopping a tree:
score = trees_chopped + tree_values.get(tree_type, 0) # Default value of 0 if tree type not in dict
def save_score(name, score): with open("leaderboard.txt", "a") as f: f.write(f"{name}: {score}\n")
At the end of the game:
name = input("Enter your name for the leaderboard: ") save_score(name, trees_chopped)
difficulty = {"easy": (60, 0.2), "normal": (45, 0.1), "hard": (30, 0.05)} level = input("Choose difficulty (easy/normal/hard): ").lower() if level in difficulty: game_duration, special_chance = difficulty[level] else: print("Defaulting to normal level") game_duration, special_chance = difficulty["normal"]
This is just an idea, would require actual implementation with a library
from tkinter import Tk, Label
root = Tk() root.title("TimberTime") label = Label(root, text="Welcome to TimberTime!") label.pack() root.mainloop()