TIMBER2024 / TimberTime

Project ♠️♾️TimberTime🧬
Apache License 2.0
0 stars 0 forks source link

TimberTime Game #2

Open TIMBER2024 opened 2 hours ago

TIMBER2024 commented 2 hours ago

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()

TIMBER2024 commented 2 hours ago

from tkinter import Tk, Label

root = Tk() root.title("TimberTime") label = Label(root, text="Welcome to TimberTime!") label.pack() root.mainloop()

TIMBER2024 commented 2 hours ago

!/usr/bin/env python3

import time import random from tkinter import Tk, Label, Button, messagebox

Game parameters

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"])
       ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​