Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.9 kB
1
Indexable
Never
    # Menu for the space space game
    # libaries
    import pygame
    import pygame_menu
    from pygame_menu import sound
    from pygame_menu.examples import create_example_window
    from typing import Tuple, Any
    from pygame  import mixer
    import os.path as path
    from pathlib import Path
    __all__ = ['main'] 
    
    pygame.init()
    class space_menu():
        op: str  # Operation
        prev: str  # Prev value
        curr: str  # Current value
        menu: 'pygame_menu.Menu'
        screen: 'pygame_menu.widgets.Label'
        surface: 'pygame.Surface'
        def __init__(self) -> None:
            self.surface = create_example_window('Example - Calculator', (3840,2160))
    
            # Menu sound
            engine = sound.Sound()
            engine.set_sound(sound.SOUND_TYPE_WIDGET_SELECTION, r"C:\Users\yigit\Desktop\python\space_space\sound\Menu Selection Click.wav")
            # configure theme
            space_theme  = pygame_menu.Theme()
            # play music
            def background_music():
                #backround music for pygame
                mixer.init()
                mixer.music.load(r"C:\Users\yigit\Desktop\python\space_space\sound\MyVeryOwnDeadShip.ogg")
                mixer.music.set_volume(1)
                mixer.music.play(loops=-1)
            background_music()
            '''
            <BACKGROUND IMAGE>
            '''
            background_image = pygame.image.load(r'C:\Users\yigit\Desktop\python\space_space\img\space.jpg')
            def main_background():
                self.surface.blit(background_image,(0,0))
            main_background()
            '''
            <FONTS SIZE> |AND| <FONT NAME> |FOR| <WIDGETS> |AND| <TITLE>  
            '''
            # Font for widgets 
            space_theme.widget_font = pygame_menu.font.FONT_8BIT
            # Font size for widget 
            space_theme.widget_font_size = 36
            # Font for title 
            space_theme.title_font = pygame_menu.font.FONT_8BIT
            '''
            Colors 
            '''
            #space_theme.selection_color = (255,255,255)    
            # border colour 
            #pygame_menu.BaseImage
    
            # background color
            #pygame_menu.background_color = pygame_menu
    
            # menubar style 
            space_theme.title_bar_style = pygame_menu.widgets.MENUBAR_STYLE_ADAPTIVE
            # title font siz  
            space_theme.background_color = ((93, 113, 193)) 
            # initilaze menu 
            self.menu = pygame_menu.Menu(
                width= 750,
                height= 750,
                title="Space Space",
                theme= space_theme,)
            self.menu.set_sound(engine, recursive = True)
            def set_difficulty(selected: Tuple, value: Any) -> None:
                pass
            def start_the_game() -> None:
                pass 
            def settings():
                pass
            # sub menu settings
            self.menu.add.button('Play', start_the_game)
            self.menu.add.button('Settings' )
            self.menu.add.button('Quit', pygame_menu.events.EXIT)
        def mainloop(self, test: bool) -> None:
            self.menu.mainloop(self.surface, disable_loop=test)
        def background_music(self):
            # backround music for pygame
            mixer.init()
            mixer.music.load(r"C:\Users\yigit\Desktop\python\space_space\sound\MyVeryOwnDeadShip.ogg")
            mixer.music.play()
    def main(test: bool = False)  -> 'space_menu':
        """
        Main function.
        :param test: Indicate function is being tested
        :return: App object
        """
        app = space_menu()
        app.mainloop(test)
        return app
    
    
    # define the main loop 
    if __name__ == '__main__':
        main()