示例#1
0
 def __init__(self):
     super(Interface, self).__init__()
     self.new_file()
     self.camera = tile.Camera(self.obj_working, 10, 10, 0, 0)
     self.fps_display = pyglet.clock.ClockDisplay(color=(200.0, 200.0,
                                                         200.5, 128.0))
     pyglet.clock.set_fps_limit(40)
     self.save_button = menu.Button(0, 0, IMAGES["save"], self.save_file)
     self.load_button = menu.Button(
         self.save_button.x + self.save_button.width, 0, IMAGES["load"],
         self.load_file)
     self.new_button = menu.Button(
         self.load_button.x + self.load_button.width, 0, IMAGES["new"],
         self.new_file)
示例#2
0
    def multi_init(self):
        self.time_init = time.time()
        self.wait = 0

        self.objects = body.Group()
        self.planet = body.Planet()

        # for i in range(50):
        #     self.objects.add(body.Object())

        buttons = [
            menu.Button("Resume", 30,
                        (self.midpoint[0], self.midpoint[1] - 150)),
            menu.Button("Restart", 30,
                        (self.midpoint[0], self.midpoint[1] - 75)),
            menu.Button("Controls", 30, (self.midpoint[0], self.midpoint[1])),
            menu.Button("Main Menu", 30,
                        (self.midpoint[0], self.midpoint[1] + 75)),
            menu.Button("Quit", 30, (self.midpoint[0], self.midpoint[1] + 150))
        ]

        self.pause_menu = menu.Menu(buttons)

        self.restart_button = menu.Button(
            "Restart?", 30, (self.midpoint[0], self.midpoint[1] + 50))

        self.main_loop()
示例#3
0
    def __init__(self, scene):
        self.scene = scene
        self.mouse = menu.Mouse(self.scene)
        game.Soundtrack()


        found = bge.logic.globalDict['found']
        all_locs = bge.logic.globalDict['all']
        if len(found) == len(all_locs):
            additional = ""
        else:
            random.shuffle(all_locs)
            additional = NEXT_TIME_TEXT.format(
                next(p for p in all_locs if p not in found)
            )

        menu.TextBox(scene.objects["EndText"], END_TEXT.format(
            len(found),
            len(all_locs),
            additional
        ), 11)
        menu.Button(scene.objects["MenuButton"], "Menu").on_click.append(self._menu)
        menu.Button(scene.objects["QuitButton"], "Quit").on_click.append(self._quit)
示例#4
0
    def __init__(self):
        global started
        global fullscreen
        self.data = pygame.display.Info()
        self.max_res = self.data.current_w, self.data.current_h
        self.min_res = cfg.dim

        pygame.display.set_caption("Inception")
        pygame.display.set_icon(res.asteroid)
        pygame.mouse.set_visible(False)

        self.running = True
        self.clock = pygame.time.Clock()

        if fullscreen:
            self.surface = pygame.display.set_mode(cfg.dim, pygame.FULLSCREEN)
        else:
            self.surface = pygame.display.set_mode(cfg.dim)

        self.fps = 30
        self.fullscreen = False
        self.midpoint = (cfg.dim[0] / 2, cfg.dim[1] / 2)

        self.mouse = body.Mouse()

        buttons = [
            menu.Button("Start", 30,
                        (self.midpoint[0], self.midpoint[1] - 150)),
            menu.Button("Settings", 30,
                        (self.midpoint[0], self.midpoint[1] - 75)),
            menu.Button("Controls", 30, (self.midpoint[0], self.midpoint[1])),
            menu.Button("Credits", 30,
                        (self.midpoint[0], self.midpoint[1] + 75)),
            menu.Button("Quit", 30, (self.midpoint[0], self.midpoint[1] + 150))
        ]

        if not started:
            self.res_button = menu.CycleButton(
                ("1280 x 800", "1920 x 1080"), 30,
                (self.midpoint[0], self.midpoint[1] - 75))
            self.windowed_button = menu.CycleButton(
                ("Windowed", "Fullscreen"), 30,
                (self.midpoint[0], self.midpoint[1]))
            started = True

        self.apply_button = menu.Button(
            "Apply", 30, (self.midpoint[0], self.midpoint[1] + 75))
        self.res_button.center = (self.midpoint[0], self.midpoint[1] - 75)
        self.windowed_button.center = (self.midpoint[0], self.midpoint[1])

        self.main_menu = menu.Menu(buttons)

        self.main_menu_loop()

        self.multi_init()
示例#5
0
windowHeight = 22
screen = pygame.display.set_mode(
    (windowWidth * configs.zoom, windowHeight * configs.zoom))
pygame.display.set_caption("Tetris")
#===========[ Create Window - End ]=======================

import menu
import gamemode

mainMenuScale = 1
menuMenuWidth = 10

# "mainMenuItemList" = [[vertical menu, menu items ...] menu areas]
mainMenuItemList = [[
    True,
    menu.Button("Singleplayer", 1, mainMenuScale, menuMenuWidth, True,
                "singleplayer", True),
    menu.Button("Coop", 1, mainMenuScale, menuMenuWidth, True, "coop", False),
    menu.Button("Coop 2 vs 2", 1, mainMenuScale, menuMenuWidth, True,
                "coop_2vs2", False),
    menu.Button("2 vs 2", 1, mainMenuScale, menuMenuWidth, True, "2vs2",
                False),
    menu.Button("Death Match", 1, mainMenuScale, menuMenuWidth, True,
                "deathmatch", False),
    menu.Button("Options", 1, mainMenuScale, menuMenuWidth, True, "options",
                False),
    menu.Button("Exit", 1, mainMenuScale, menuMenuWidth, True, "exit", True)
]]

singleplayerMenuScale = 1
singleplayerMenuWidth = 9
singleplayerMenuValueWidth = 3
示例#6
0
def mmenu(SCREEN):
    """main menu"""
    show_fps = True if '--fps' in sys.argv else False
    show_rects = True if '--show_rects' in sys.argv else False
    fps = 60 if '--no_limit' in sys.argv else 240
    running = True
    fps_clock = pygame.time.Clock()

    background = menu.Background()
    moon = menu.Moon((240, 110))
    font = pygame.font.Font("gfx/ui/Game_font.ttf", 50)
    spielen = menu.Button((50, 75))
    info = menu.Button((50, 165))
    optionen = menu.Button((50, 255))
    sound_txt = menu.SimpleText(font, "Sound :", C_GREY, (50, 255))
    sound_val = menu.Button((250, 255))
    highscores = menu.Button((50, 345))
    beenden = menu.Button((50, 435))
    spielen.add_text(font, "Spielen", C_GREY, C_WHITE)
    info.add_text(font, "Info", C_GREY, C_WHITE)
    optionen.add_text(font, "Optionen", C_GREY, C_WHITE)
    sound_val.add_text(font, "Aus", C_GREY, C_WHITE)
    highscores.add_text(font, "Highscores", C_GREY, C_WHITE)
    beenden.add_text(font, "Beenden", C_GREY, C_WHITE)
    buttons = spielen, info, sound_val, highscores, beenden
    active_button = 0

    while running:
        pygame.event.pump()
        events = pygame.event.get()
        keys_pressed = pygame.key.get_pressed()
        for event in events:
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    running = False
                elif event.key == pygame.K_UP:
                    if active_button > 0: active_button -= 1
                    else: active_button = len(buttons) - 1
                    if SOUND: MENU_SOUND.play()
                elif event.key == pygame.K_DOWN:
                    if active_button < len(buttons) - 1: active_button += 1
                    else: active_button = 0
                    if SOUND: MENU_SOUND.play()
                elif event.key == pygame.K_RETURN:
                    if SOUND: MENU_SOUND.play()
                    if active_button == 0:
                        run(SCREEN)
                    elif active_button == 1:
                        minfo(SCREEN)
                    elif active_button == 2:
                        global SOUND
                        sound_val.add_text(font, "Aus" if SOUND else "An",
                                           C_GREY, C_WHITE)
                        if SOUND:
                            SOUNDTRACK.stop()
                            SOUND = False
                        else:
                            SOUNDTRACK.play(-1)
                            SOUND = True
                    elif active_button == 3:
                        mhighscores(SCREEN)
                    elif active_button == 4:
                        running = False
            elif event.type == pygame.QUIT:
                sys.exit()

        advanced_draw(SCREEN, background.image, background.rect, show_rects)
        advanced_draw(SCREEN, moon.image, moon.rect, show_rects)
        advanced_draw(SCREEN, sound_txt.image, sound_txt.rect, show_rects)
        for button in buttons:
            if button == buttons[active_button]:
                button.update("active")
            else:
                button.update("passive")
            advanced_draw(SCREEN, button.image, button.rect, show_rects)

        deltat = fps_clock.tick(fps) / 1000.0
        if show_fps:
            print 1 / deltat
        pygame.display.update()
示例#7
0
                           'resources/button_holder.png')
menu_pic = menu.Picture((0, 0), (WIDTH * 0, HEIGHT * 0),
                        "resources/MainMenuPhoto.png")
button1 = menu.PictureButton((476, 300), (200, 35), "  Играть  ",
                             "resources/menu_button.png")
button2 = menu.PictureButton((476, 350), (0, 35), " Правила ",
                             "resources/menu_button.png")
button3 = menu.PictureButton((476, 400), (0, 35), "Настройки",
                             "resources/menu_button.png")
button4 = menu.PictureButton((476, 450), (200, 35), "  Выход  ",
                             "resources/menu_button.png")
menu_buttons = [
    menu_pic, logo_pic, buttons_pic, button1, button2, button3, button4
]
# Common buttons
left_button = menu.Button((521, 362), (25, 25), (30, 30, 200), "<")
plus_minusPT = menu.PlainText((556, 362), (30, 25), (140, 140, 140), "0")
right_button = menu.Button((596, 362), (25, 25), (30, 30, 200), ">")
back_b = menu.PictureButton((952, 690), (200, 30), "Назад",
                            "resources/menu_button.png")
desc_pmPT = menu.PicturePlainText(
    (406, 320), (350, 30), "Бомбим этого игрока:", "resources/menu_button.png")
do_smthB = menu.PictureButton((476, 465), (200, 30), "В атаку!",
                              "resources/menu_button.png")
basic_choose_sc = [
    buttons_pic, left_button, right_button, back_b, desc_pmPT, plus_minusPT,
    do_smthB
]
# Next turn buttons
click_on_me_b = menu.Button((276, 312), (600, 100), (200, 30, 30),
                            "Нажми на меня, чтобы начать следующий ход")
import configs
import game
import pygame
import menu
import functions

gameMenuScale = 1
gameMenuWidth = 8
gameFiledBorderDistanceX = 1.5
gameFiledBorderDistanceY = 1

# "gameMenuItemList" = [[vertical menu, menu items ...] menu areas]
gameMenuItemList = [[
    True,
    menu.Button("Resume", 1, gameMenuScale, gameMenuWidth, True, "resume",
                True),
    menu.Button("Main Menu", 1, gameMenuScale, gameMenuWidth, True,
                "main_menu", True),
    menu.Button("Exit", 1, gameMenuScale, gameMenuWidth, True, "exit", True)
]]


class SinglePlayer:
    gameList = []  # the list of all needed games
    gameInput = None  # the local game
    screen = None
    level = 0
    itemsEnabled = False

    gameover_font = None
    text_gameover = None