CoolFace
Apppublic

11dayanbutt/Gaming

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py42 linesDownload Raw Back to root
1import streamlit as st2from PIL import Image3import random4import time5 6# Setup the game window7st.title("Bird Game")8st.subheader("Click the flying birds to score points!")9 10# Define game parameters11bird_images = ["bird1.png", "bird2.png", "bird3.png"]12game_score = 013bird_positions = [(100, 200), (300, 400), (500, 100), (700, 300)]14 15# Function to display the birds16def display_bird(bird_image, pos_x, pos_y):17    bird = Image.open(bird_image)18    st.image(bird, use_column_width=True, width=100, caption="Flying Bird", output_format="PNG")19 20# Main game loop21def game_loop():22    global game_score23    for i in range(5):  # Let's simulate 5 rounds24        bird_image = random.choice(bird_images)25        pos_x, pos_y = random.choice(bird_positions)26        27        # Display bird at random position28        display_bird(bird_image, pos_x, pos_y)29 30        # Add interaction31        click_pos = st.slider("Click the bird!", 0, 100, step=1)  # This simulates a click interaction32        if click_pos == pos_x:  # If the user clicks near the bird, score a point33            game_score += 134            st.write("You scored a point!")35        36        time.sleep(1)  # Simulate time between birds flying37        38    st.write(f"Game Over! Your total score is: {game_score}")39 40# Run the game41game_loop()42``