[Python] Python logic and sounds [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I got a game code

    import pygame as pg
    import os
    import time


    import sprites_config as sc
    import music_config as mc

    from screeninfo import get_monitors
    for monitor in get_monitors():
    WIDTH = monitor.width
    HEIGHT = monitor.height



    ....


    if (total_mouse_pos[0] >= WIDTH * 0.5 - sc.spr_exit.export()[1] * 0.5 and
    total_mouse_pos[0] <= WIDTH * 0.5 + sc.spr_exit.export()[1] * 0.5 and
    total_mouse_pos[1] >= HEIGHT / 4 * 3.5 and
    total_mouse_pos[1] <= HEIGHT / 4 * 3.5 + sc.spr_exit.export()[2]):
    exit_is_shiny = sc.spr_exit_shiny.export()[4]
    navodka_sound.play()

    else:
    exit_is_shiny = sc.spr_exit.export()[4]


    if (total_mouse_pos[0] >= WIDTH * 0.5 - sc.spr_play.export()[1] * 0.55 and
    total_mouse_pos[0] <= WIDTH * 0.5 + sc.spr_play.export()[1] * 0.55 and
    total_mouse_pos[1] >= HEIGHT / 4 * 2.60 and
    total_mouse_pos[1] <= HEIGHT / 4 * 2.60 + sc.spr_play.export()[2]):
    play_is_shiny = sc.spr_play_shiny.export()[4]
    navodka_sound.play()
    else:
    play_is_shiny = sc.spr_play.export()[4]

    if (total_mouse_pos[0] >= WIDTH * 0.5 - sc.spr_menu.export()[1] * 0.55 and
    total_mouse_pos[0] <= WIDTH * 0.5 + sc.spr_menu.export()[1] * 0.55 and
    total_mouse_pos[1] >= HEIGHT / 4 * 3 and
    total_mouse_pos[1] <= HEIGHT / 4 * 3 + sc.spr_menu.export()[2]):
    menu_is_shiny = sc.spr_menu_shiny.export()[4]
    navodka_sound.play()
    ....



    And i have a problem. When i got a mouse on button it does inf ammount of repeating navodka_sound.play() What can i do for repeating this only once before it gets on button next times Can you write a function or smth like this to fix this loop?

    I tried some functions from other's guys but it didn't work. Help asap plzz

    Continue reading...

Compartilhe esta Página