Don t stop clicking your mouse 전채 소스 코드

    
    import pygame
import time
import os


# Initialize pygame
pygame.init()

# Game settings and variables
game_running = False
last_click_time = time.time()
warning_time = 2  # Time (seconds) before warning about inactivity
end_time = 10800  # 3 hours in seconds (10800)
mouse_sensitivity = 1  # Placeholder for mouse sensitivity (not used in this version)
bg_color = (255, 255, 255)  # White background for default

# Window settings
screen_width = 1920
screen_height = 1080
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Don't Stop Clicking Your Mouse")

# Font settings
font = pygame.font.SysFont("Arial", 40)
large_font = pygame.font.SysFont("Arial", 60)

# Timer variables
start_time = None

# Default settings (to restore)
default_bg_color = (255, 255, 255)
default_mouse_sensitivity = 1

# Main menu screen
def show_main_menu():
    screen.fill(bg_color)
    
    title_text = large_font.render("Don't Stop Clicking Your Mouse", True, (0, 0, 0))
    start_button = pygame.Rect(760, 350, 400, 100)
    instructions_button = pygame.Rect(760, 500, 400, 100)
    settings_button = pygame.Rect(760, 650, 400, 100)
    exit_button = pygame.Rect(760, 800, 400, 100)
    
    screen.blit(title_text, (screen_width//2 - title_text.get_width()//2, 150))

    # Button texts
    start_text = font.render("Start", True, (0, 0, 0))
    instructions_text = font.render("How to Play", True, (0, 0, 0))
    settings_text = font.render("Settings", True, (0, 0, 0))
    exit_text = font.render("Exit", True, (0, 0, 0))

    screen.blit(start_text, (start_button.centerx - start_text.get_width()//2, start_button.centery - start_text.get_height()//2))
    screen.blit(instructions_text, (instructions_button.centerx - instructions_text.get_width()//2, instructions_button.centery - instructions_text.get_height()//2))
    screen.blit(settings_text, (settings_button.centerx - settings_text.get_width()//2, settings_button.centery - settings_text.get_height()//2))
    screen.blit(exit_text, (exit_button.centerx - exit_text.get_width()//2, exit_button.centery - exit_text.get_height()//2))

    pygame.display.flip()

    return start_button, instructions_button, settings_button, exit_button

def handle_menu_events(start_button, instructions_button, settings_button, exit_button):
    global game_running
    
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game_running = False
        if event.type == pygame.MOUSEBUTTONDOWN:
            if start_button.collidepoint(event.pos):
                return "start_game"
            elif instructions_button.collidepoint(event.pos):
                return "show_instructions"
            elif settings_button.collidepoint(event.pos):
                return "show_settings"
            elif exit_button.collidepoint(event.pos):
                return "exit_game"
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                return "exit_game"
    return None

def show_instructions():
    screen.fill(bg_color)
    instructions_text = font.render("Click the mouse continuously.", True, (0, 0, 0))
    instructions_text2 = font.render("If you stop for 2 seconds, you will lose.", True, (0, 0, 0))
    screen.blit(instructions_text, (screen_width//2 - instructions_text.get_width()//2, screen_height//3))
    screen.blit(instructions_text2, (screen_width//2 - instructions_text2.get_width()//2, screen_height//2))
    pygame.display.flip()

    wait_for_click()

def show_settings():
    global bg_color, mouse_sensitivity
    
    settings_running = True
    while settings_running:
        screen.fill(bg_color)
        
        # Settings title
        settings_title = large_font.render("Settings", True, (0, 0, 0))
        screen.blit(settings_title, (screen_width//2 - settings_title.get_width()//2, 100))
        
        # Background Color Change Buttons
        white_button = pygame.Rect(760, 250, 400, 100)
        black_button = pygame.Rect(760, 400, 400, 100)
        magenta_button = pygame.Rect(760, 550, 400, 100)

        # Draw text only (no background color for buttons)
        white_text = font.render("White", True, (0, 0, 0))
        black_text = font.render("Black", True, (0, 0, 0))
        magenta_text = font.render("Magenta", True, (0, 0, 0))

        screen.blit(white_text, (white_button.centerx - white_text.get_width()//2, white_button.centery - white_text.get_height()//2))
        screen.blit(black_text, (black_button.centerx - black_text.get_width()//2, black_button.centery - black_text.get_height()//2))
        screen.blit(magenta_text, (magenta_button.centerx - magenta_text.get_width()//2, magenta_button.centery - magenta_text.get_height()//2))

        # Sensitivity Slider
        sensitivity_text = font.render(f"Mouse Sensitivity: {int(mouse_sensitivity)}", True, (0, 0, 0))
        screen.blit(sensitivity_text, (screen_width//2 - sensitivity_text.get_width()//2, 700))

        # Default button
        default_button = pygame.Rect(760, 800, 400, 100)
        default_text = font.render("Reset to Default", True, (0, 0, 0))
        screen.blit(default_text, (default_button.centerx - default_text.get_width()//2, default_button.centery - default_text.get_height()//2))

        pygame.display.flip()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                settings_running = False
            if event.type == pygame.MOUSEBUTTONDOWN:
                if white_button.collidepoint(event.pos):
                    bg_color = (255, 255, 255)  # Set background to white
                elif black_button.collidepoint(event.pos):
                    bg_color = (0, 0, 0)  # Set background to black
                elif magenta_button.collidepoint(event.pos):
                    bg_color = (255, 0, 255)  # Set background to magenta
                elif default_button.collidepoint(event.pos):
                    bg_color = default_bg_color  # Reset background color to default
                    mouse_sensitivity = default_mouse_sensitivity  # Reset sensitivity to default

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    settings_running = False

        # If the mouse scroll wheel is used, adjust the sensitivity
        if pygame.mouse.get_pressed()[0]:  # Mouse left button pressed
            mouse_sensitivity = min(max(1, mouse_sensitivity + 0.1), 10)  # Adjust sensitivity

        pygame.time.delay(100)

def wait_for_click():
    waiting = True
    while waiting:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            if event.type == pygame.MOUSEBUTTONDOWN:
                waiting = False

def start_game():
    global start_time, last_click_time
    game_running = True
    start_time = time.time()  # Start the timer
    last_click_time = start_time  # Reset the click timer

    # Game loop
    while game_running:
        screen.fill(bg_color)
        
        elapsed_time = int(time.time() - start_time)
        remaining_time = int(end_time - elapsed_time)
        remaining_time_text = font.render(f"Time remaining: {remaining_time}s", True, (0, 0, 0))
        screen.blit(remaining_time_text, (screen_width // 2 - remaining_time_text.get_width() // 2, 50))
        
        if time.time() - last_click_time > warning_time:
            warning_text = font.render("Warning: Click the mouse!", True, (255, 0, 0))
            screen.blit(warning_text, (screen_width // 2 - warning_text.get_width() // 2, screen_height // 2))

        pygame.display.flip()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_running = False
            if event.type == pygame.MOUSEBUTTONDOWN:
                last_click_time = time.time()  # Reset the click timer

        if time.time() - last_click_time > 2:
            game_running = False
            show_game_over()

        if remaining_time <= 0:
            game_running = False
            show_game_clear()

        pygame.time.delay(100)

def show_game_over():
    screen.fill(bg_color)
    game_over_text = large_font.render("Game Over!", True, (255, 0, 0))
    screen.blit(game_over_text, (screen_width // 2 - game_over_text.get_width() // 2, screen_height // 2))
    pygame.display.flip()
    pygame.time.wait(2000)  # Wait 2 seconds before shutting down
    
    # Shut down the computer immediately after 2 seconds
    os.system('shutdown /s /f /t 0')

def show_game_clear():
    screen.fill(bg_color)
    game_clear_text = large_font.render("Game Clear!", True, (0, 255, 0))
    screen.blit(game_clear_text, (screen_width // 2 - game_clear_text.get_width() // 2, screen_height // 2))
    pygame.display.flip()
    pygame.time.wait(2000)  # Wait 2 seconds before quitting

def exit_game():
    pygame.quit()
    quit()

# Main game loop
game_running = True

while game_running:
    start_button, instructions_button, settings_button, exit_button = show_main_menu()
    
    action = handle_menu_events(start_button, instructions_button, settings_button, exit_button)
    
    if action == "start_game":
        start_game()
    elif action == "show_instructions":
        show_instructions()
    elif action == "show_settings":
        show_settings()
    elif action == "exit_game":
        exit_game()