Ejemplo n.º 1
0
def main():
    print("ÖLBRYGGNING")
    menu1 = Menu()
    menu1.show_menu()
    menu1.menu_choice()
Ejemplo n.º 2
0
 def go_to_main_menu(self):
     utils.set_scene(Menu())
Ejemplo n.º 3
0
from os import system, name 
  
# define our clear function 
def clear(): 
  
    # for windows 
    if name == 'nt': 
        _ = system('cls') 
  
    # for mac and linux(here, os.name is 'posix') 
    else: 
        _ = system('clear') 


#Create instances of coffee and money machines and a menu
menu = Menu()
coffee_maker = CoffeeMaker()
money_machine = MoneyMachine()

clear()
print(logo)

turn_off = False
while not turn_off:
    user_choice = input(f"What would you like? ({menu.get_items()}): ").lower()
    if user_choice == "off":
        turn_off = True
    elif user_choice == "report":
        coffee_maker.report()  
        money_machine.report()
    else:
Ejemplo n.º 4
0
import requests
import json
import os
from menu import Menu

if __name__ == "__main__":
  Menu().run()
Ejemplo n.º 5
0
def main():
    db.connect()
    menu = Menu(MENU_OPTIONS, launch)
    menu.wait_for_input()
Ejemplo n.º 6
0
def quests(string):
    print()
    Quest.showCurrentQuests()
    print()
    return [True, False]


def wait(string):
    return [True, True]


def exit(string):
    return ["E", "ND"]


MainMenu = Menu(
)  #(self,displayname,commandname,outputfunc,helpdescription,expectedinput)
MainMenu.addMenuOption("go", "go", go, "moves you in the given direction",
                       "direction", "g")
MainMenu.addMenuOption("exit", "exit", exit, "ends the game", None, "ex")
MainMenu.addMenuOption("inventory", "inventory", inventory,
                       "opens your inventory", None, "i")
MainMenu.addMenuOption(
    "pick up",
    "pick",
    pickup,
    "picks up the item",
    "item",
    "p",
)
MainMenu.addMenuOption("talk to", "talk", talkto, "talks to the npc", "npc",
                       "t")
Ejemplo n.º 7
0
from record_store import Album, Artist, Store
from menu import Menu

artists = set()


def add_inventory():
    pass


def sell_album():
    pass


def add_artist():
    name = input("What is the name of the artist? ")
    artists.add(Artist(name))


def discount_album():
    pass

m = Menu()
m.register("Add Artist", add_artist)
m.register("Add Inventory", add_inventory)
m.register("Sell Album(s)", sell_album)
m.register("Discount Album", discount_album)
m.register("Show Artists", lambda: print(*sorted(artists), sep="\n"))
m.register("Show Inventory", Store.list_inventory)
m.display()
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)

        # init file system
        self.file = File()

        # Whether or not the window exclusively captures the mouse.
        self.exclusive = False

        # create player
        self.player = Player((0, 0))

        # create player model
        dx, dy, dz = self.player.get_sight_vector()
        x, y, z = self.player.position
        self.player_model = PlayerModel(
            (x + ND * dx, y - VIEW_DIFF, z + ND * dz), self.player.rotation)

        # Which sector the player is currently in.
        self.sector = None

        # The crosshairs at the center of the screen.
        self.reticle = None

        # The current block the user can place. Hit num keys to cycle.
        self.block = None

        # Convenience list of num keys.
        self.num_keys = [key._1, key._2, key._3, key._4]

        # Instance of the model that handles the world.
        self.model = Model()

        #label
        self.label = pyglet.text.Label('',
                                       font_name='Arial',
                                       font_size=18,
                                       x=self.width,
                                       y=self.height,
                                       anchor_x='right',
                                       anchor_y='top',
                                       color=(0, 0, 0, 255))

        #tool label
        self.tool_label = pyglet.text.Label('',
                                            font_name='Arial',
                                            font_size=18,
                                            x=0,
                                            y=self.height,
                                            anchor_x='left',
                                            anchor_y='top',
                                            color=(0, 0, 0, 255))

        #block zoom label
        self.zoom_label = pyglet.text.Label('',
                                            font_name='Arial',
                                            font_size=18,
                                            x=self.width // 2,
                                            y=0,
                                            anchor_x='center',
                                            anchor_y='bottom',
                                            color=(0, 0, 0, 255))

        #create menu
        self.menu = Menu(self.width, self.height)

        # The crosshairs at the center of the screen.
        self.crosshair = None
        self.crosshair_loc = [self.width // 2, self.height // 2, 0]

        #mouse postion
        self.mouse_pos = (0, 0)

        self.freeze = False
        self.open_bag = False
        self.open_menu = False
        self.open_map = False

        # This call schedules the `update()` method to be called
        # TICKS_PER_SEC. This is the main game event loop.
        pyglet.clock.schedule_interval(self.update, 1.0 / TICKS_PER_SEC)
Ejemplo n.º 9
0
        :param search_string: search string
        :return: task list
        """

        return [task for task in self.tasks if task.match(search_string)]

    def _find_task(self, task_id):
        """Find a task by task.id

        :param task_id: The task.id for the task to find.
        :return: a task object if found, otherwise None
        """

        for task in self.tasks:
            if str(task.id) == str(task_id):
                return task
        return None

    def _renumber_tasks(self):
        """Renumber all of the tasks. Useful when a task is deleted."""

        Task.last_id = 0
        for task in self.tasks:
            Task.last_id += 1
            task.id = Task.last_id


if __name__ == '__main__':
    from menu import Menu
    Menu().run()  # replace with a call to unit tests?
Ejemplo n.º 10
0
state = State()

resources = {
    'Weatherstack':
    WeatherstackResource(config.WEATHERSTACK_ACCESS_KEY),
    'Openweathermap':
    OpenweathermapResource(config.OPENWEATHERMAP_ACCESS_KEY),
    'Worldweatheronline':
    WorldweatheronlineResource(config.WORLDWEATHERONLINE_ACCESS_KEY),
    'Sinoptik':
    SinoptikResource()
}

main_menu = Menu([
    WebSelectItem([
        WeatherstackItem(state),
        OpenweathermapItem(state),
        WorldweatheronlineItem(state),
        SinoptykItem(state),
        ExitItem()
    ]),
    CityItem(state),
    ShowWeatherItem(state, resources),
    ExitItem()
])
main_menu.start()

#провайдер возвращает все в цельсиях
#почистить лишнее
#пофиксить провайдеров
#сделать возврат температуры в браузере и в json
Ejemplo n.º 11
0
from constants import Direction

pygame.init()

window_size = window_width, window_height = 800, 600

map_size = map_width, map_height = 800, 545

black = 200, 200, 200

window = pygame.display.set_mode(window_size)
map_screen = window.subsurface((0, 0), map_size)
# screen = pygame.display.set_mode(window_size)
menu_bar_screen = window.subsurface((0, 545), (800, 55))

menu_bar = Menu()

rh = ResourceHandler(pathlib.Path("images"))
game_map = Map(Room.Room(0, 0, rh), rh)
current_room = game_map.start
current_room.highlight(True)

running = True
map_draw = True
menu_draw = False

EXITMODE = 1
BOMBMODE = 2
LINKMODE = 3
wasd_mode = EXITMODE
Ejemplo n.º 12
0

def test():
    print('Студентов нет')


if __name__ == '__main__':
    studentRegistry = StudentRegistry()
    # student = Student('Иванов','Иван','Иванович','34',{'химия': 5,'математика':5})
    # student1 = Student('Потапов','Игрорь','Владимирович','32',{'физика':3,'информатика':5})
    # student2 = Student('Максимов','Максим','Максимович','11',{'физика':4,'информатика':4})
    # studentRegistry.addStudents(student)
    # studentRegistry.addStudents(student1)
    # studentRegistry.addStudents(student2)
    studentRegistry.load()
    main_menu = Menu()

    file_menu = main_menu.addItems('Список студентов', listStudentCommand)
    file_menu = main_menu.addItems('Добавить студента', addStudent)

    file_menu = main_menu.addSubMenu('Редактировать студента')

    file_menu.Select(SelectS)
    file_menu.Show(ShowS)
    file_menu.Deselect(DeselectS)

    file_menu.addItems('Изменить фамилию', EditL)
    file_menu.addItems('Изменить имя', EditF)
    file_menu.addItems('Изменить отчество', EditM)
    file_menu.addItems('Изменить группу', EditG)
    file_menu.addItems('Добавить оценку', AddMark)
Ejemplo n.º 13
0
from menu import Menu
from menuitem import MenuItem

menuItem1 = MenuItem('Chicken Popcorn', 98, 4.1)
menuItem2 = MenuItem('Zinger Burger', 258, 4.6)
menuItem3 = MenuItem('Chicken Pizza', 298, 4.0)
menuItem4 = MenuItem('Lime Krusher', 75, 4.3)
menuItem5 = MenuItem('Chicken Popcorn', 60, 4.1)
menuItem6 = MenuItem('Chicken Popcorn', 60, 4.1)

print(menuItem1)
print(menuItem1 == menuItem5)
print(menuItem5 == menuItem6)

menu = Menu([menuItem1, menuItem2, menuItem3, menuItem4, menuItem5, menuItem6])

print(len(menu))

print(menu)
list.sort(menu.menuitems, reverse=True)
print(menu)
Ejemplo n.º 14
0
 def add_message(self, message: str, subtitle: str = "") -> None:
     if self.win is not None:
         # no need for extra messages
         return
     self._events.append(Menu(title=message, subtitle=subtitle))
     self.request_notify({"events": self._events})
Ejemplo n.º 15
0
 def __init__(self):
     super().__init__()
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setWindowOpacity(0.01)
     #set background
     self.background = Background()
     self.background.showFullScreen()
     #set initial screen shot
     self.cutok = False
     self.fullPixmap = ImageGrab.grab()
     self.fullPixmap = self.fullPixmap.resize(
         (int(NSScreen.mainScreen().frame().size.width),
          int(NSScreen.mainScreen().frame().size.height)), Image.ANTIALIAS)
     self.fullPixmap = self.fullPixmap.toqpixmap()
     self.setMouseTracking(True)
     # Create rectLabel
     self.rectLabel = QLabel(self)
     self.rectLabel.hide()
     self.rectLabel.setMouseTracking(True)
     # Create second layer of rectLabel
     self.opaqueRectLabel = RectLabel()
     self.opaqueRectLabel.showFullScreen()
     # Create buttons for dragging
     self.topRightResize = QPushButton()
     self.topLeftResize = QPushButton()
     self.bottomRightResize = QPushButton()
     self.bottomLeftResize = QPushButton()
     self.topRightResize.setObjectName("resizeBtn")
     self.topLeftResize.setObjectName("resizeBtn")
     self.bottomRightResize.setObjectName("resizeBtn")
     self.bottomLeftResize.setObjectName("resizeBtn")
     # Create selectRect
     self.selectRect = QRect()
     # Boolean to see if selection exists
     self.selectionExists = False
     # Booleans for resizing
     self.resizeOK = False
     self.initialShiftWindow = True
     self.topRightResizeOK = False
     self.topLeftResizeOK = False
     self.bottomRightResizeOK = False
     self.bottomLeftResizeOK = False
     self.topResizeOK = False
     self.leftResizeOK = False
     self.bottomResizeOK = False
     self.rightResizeOK = False
     # Booleans for drawing arrows
     self.drawArrowOK = False
     self.drawingArrow = False
     self.drawArrowHead = False
     self.allArrows = []
     # Booleans for underlining
     self.underlineOK = False
     self.underlining = False
     self.underlineEnd = False
     self.allLines = []
     # Booleans for drawing
     self.drawOK = False
     self.drawing = False
     self.drawingEnd = False
     self.drawLines = []
     self.tempDrawLines = []
     self.destination = None
     #List for all drawings
     self.allDrawings = []
     self.deleted = []
     # Create path and file name
     self.savePath = ""
     # Create helpWidget
     helpText = u'''
 Drag to select 
 Right click to undo selection or quit
 Double left click to save 
     '''
     self.helpWin = QLabel()
     self.helpWin.setText(helpText)
     self.helpWin.setWindowFlags(Qt.FramelessWindowHint)
     self.helpWin.setFixedSize(QSize(250, 100))
     self.helpWin.setStyleSheet("color: rgb(255, 255, 255);"
                                "background-color:rgb(69,119,170);")
     screen = QDesktopWidget().screenGeometry()
     screenWidth = screen.width()
     screenHeight = screen.height()
     helpWin = self.helpWin.geometry()
     helpWidth = helpWin.width()
     helpHeight = helpWin.height()
     self.helpWin.move(screenWidth - helpWidth, 0)
     self.helpWin.show()
     #menu widgets
     self.openMenuBtn = QPushButton("Menu")
     self.openMenuBtn.setWindowFlags(Qt.FramelessWindowHint
                                     | Qt.WindowStaysOnTopHint)
     self.openMenuBtn.setAttribute(Qt.WA_TranslucentBackground)
     self.openMenuBtn.setObjectName("openMenuBtn")
     stylesheetFile = "stylesheet.qss"
     with open(stylesheetFile, "r") as file:
         self.openMenuBtn.setStyleSheet(file.read())
     self.openMenuBtn.clicked.connect(self.openMenuFunc)
     self.menu = Menu()
     self.menu.setWindowFlags(Qt.FramelessWindowHint
                              | Qt.WindowStaysOnTopHint)
     self.menu.setMouseTracking(True)
     #menu button functions
     self.menu.arrowBtn.clicked.connect(self.arrowBtnFunc)
     self.menu.underlineBtn.clicked.connect(self.underlineBtnFunc)
     self.menu.undoBtn.clicked.connect(self.undoBtnFunc)
     self.menu.redoBtn.clicked.connect(self.redoBtnFunc)
     self.menu.saveBtn.clicked.connect(self.saveBtnFunc)
     self.menu.drawBtn.clicked.connect(self.drawBtnFunc)
Ejemplo n.º 16
0
def main():
    pygame.init()


    host = input("Enter host IP (leave blank for localhost): ")
    if host == "":
        host = None

    #host = "3.17.188.254"
    client, username, game_board, players = connect(host=host, port=4832)


    client_player = players[username]

    WIDTH, HEIGHT = game_board.get_dimensions()
    print(WIDTH, HEIGHT)
    screen = pygame.display.set_mode((WIDTH, HEIGHT))
    clock = pygame.time.Clock()

    font = pygame.font.SysFont("Arial", 50)

    def update_fps():
        fps = str(int(clock.get_fps()))
        fps_text = font.render(fps, 1, pygame.Color("green"))
        return fps_text

    menu = Menu(screen)
    controllers = controller.init()
    # controls = Menu(screen, "Controls")
    controls = ControlsMenu(screen, ["Player1", "Player2", "Player3"], ControlsMenu.CONTROLS)
    menu.add_menu(controls)
    menu.add_button("Exit Game", lambda: pygame.event.post(pygame.event.Event(pygame.QUIT, dict())))
    menus = [menu, controls]

    actions = {
        "up": {
            True: UpdateDirection(client_player, 0, True),
            False: UpdateDirection(client_player, 0, False)
        },
        "left": {
            True: UpdateDirection(client_player, 2, True),
            False: UpdateDirection(client_player, 2, False)
        },
        "down": {
            True: UpdateDirection(client_player, 4, True),
            False: UpdateDirection(client_player, 4, False)
        },
        "right": {
            True: UpdateDirection(client_player, 6, True),
            False: UpdateDirection(client_player, 6, False)
        },
        "place bomb": {
            True: PlaceBomb(client_player),
            False: None
        },
        "punch": {
            True: Punch(client_player),
            False: None
        },
        "detonate": {
            True: None,
            False: None
        },
    }

    binding = KeyBinds(actions)
    binding.load_controls("controller_default.json")

    game_queue = Queue()

    KEYS = [pygame.K_w, pygame.K_a, pygame.K_s, pygame.K_d]

    t = threading.Thread(target=input_thread, args=(client, input_callback, username), name="client chat input")
    t.setDaemon(True)
    t.start()
    convert_sheets()

    times_test = []
    warmup = True
    running = True
    while running:
        for message in client.collect_messages():

            if message[0] == 0:     # reset player list
                names = message[1].split(",")
                game_board.clear_players()
                players = load_players(names, game_board)
                client_player = players[username]

            elif message[0] == 1:   # game command
                objects = players.copy()
                objects[game_board.get_id()] = game_board
                c = deserialize(message[1], objects)
                print(message[1])
                game_queue.put(c)

            elif message[0] == 2:   # chat message
                print(message[1])

            elif message[0] == 3:   # board update
                print("loaded board")
                game_board = Board.from_string(message[1])

            elif message[0] == 4:   # remove player
                del players[message[1]]

            elif message[0] == 5:   # add player
                name, id  = message[1].split(",")

        for cont in controllers:
            cont.generate_events()
            cont.post_events()


        for event in pygame.event.get():
            [menu.update(event) for menu in menus]
            binding.push_event(event)

            if event.type == pygame.QUIT:
                running = False

            if event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
                command = SetPosition(client_player, client_player.x, client_player.y)
                game_queue.put(command)
                client.send_message([1, command.serialize()])

        binding.update_keystate()
        for command in binding.get_commands():
            if command is not None:
                game_queue.put(command)
                print(command.serialize())
                client.send_message([1, command.serialize()])


        while not game_queue.empty():
            command = game_queue.get()
            command.execute()


        game_board.update()
        board_surface = draw_board(game_board)


        for player in players.values():
            player.update()
            board_surface = draw_player(board_surface, player)

        board_surface = pygame.transform.scale(board_surface, (WIDTH, HEIGHT))

        screen.blit(board_surface, (0, 0))
        screen.blit(update_fps(), (10, 0))
        [menu.draw() for menu in menus]
        pygame.display.update()
        screen.fill((16, 120, 48))
        clock.tick(60)

    print("broken")
    client.close()
    print("CLOSED")
    pygame.quit()
    print("QUIT")
Ejemplo n.º 17
0
 def cambiar_escena(self):
     self.sonido_boton.reproducir()
     pilas.cambiar_escena(Menu(self.nombre))
 def __init__(self):
     self.useMysql = UsePyMysql()
     self.menu = Menu()
Ejemplo n.º 19
0
def start():
    Menu().start()
Ejemplo n.º 20
0
from assets.PPlay.window import Window
from assets.PPlay.keyboard import Keyboard
from pygame.time import Clock
from menu import Menu
from play import Play
from fps import Fps
from rank import Rank
from difficulty import Difficulty
import GVar

window = Window(GVar.WIDTH, GVar.HEIGHT)
window.set_title("Space Invaders")
window.set_background_color((0, 0, 0))

keyboard = Keyboard()
menu = Menu(window)
play = Play(window, "./assets/lvl/level_1.txt")
difficulty_menu = Difficulty(window)
rank = Rank(window)
clock = Clock()
fps = Fps(window)

window.update()
while GVar.STATE != 4:
    window.set_background_color((0, 0, 0))
    if keyboard.key_pressed("esc"):
        GVar.STATE = 0
        play.__init__(window, "./assets/lvl/level_1.txt")
    if GVar.STATE == 0:
        menu.run()
    if GVar.STATE == 1:
Ejemplo n.º 21
0
    def __init__(self):
        """initialise the engine"""
        ShowBase.__init__(self)
        base.notify.info("Version {}".format(versionstring))
        FSM.__init__(self, "FSM-Game")

        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        # disable pandas default camera driver
        self.disableMouse()
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # get the displays width and height for later usage
        self.dispWidth = self.pipe.getDisplayWidth()
        self.dispHeight = self.pipe.getDisplayHeight()

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if particles should be enabled
        # NOTE: If you use the internal physics engine, this always has
        #       to be enabled!
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()

        def setFullscreen():
            """Helper function to set the window fullscreen
            with width and height set to the screens size"""
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(self.dispWidth, self.dispHeight)
            # request the new properties
            base.win.requestProperties(props)
            # Set the config variables so we correctly store the
            # new size and fullscreen setting later
            winSize = ConfigVariableString("win-size")
            winSize.setValue("{} {}".format(self.dispWidth, self.dispHeight))
            fullscreen = ConfigVariableBool("fullscreen")
            fullscreen.setValue(True)
            # Render a frame to make sure the fullscreen is applied
            # before we do anything else
            self.taskMgr.step()
            # make sure to propagate the new aspect ratio properly so
            # the GUI and other things will be scaled appropriately
            aspectRatio = self.dispWidth / self.dispHeight
            self.adjustWindowAspectRatio(aspectRatio)

        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            setFullscreen()
        # automatically safe configuration at application exit
        #base.exitFunc = self.__writeConfig

        #
        # INITIALIZE GAME CONTENT
        #
        base.cTrav = CollisionTraverser("base collision traverser")
        base.pusher = CollisionHandlerPusher()
        self.menu = Menu()
        self.credits = Credits()
        self.charSelection = CharacterSelection()
        self.levelSelection = LevelSelection()
        self.koScreen = KoScreen()
        self.hud = Hud()
        self.menuMusic = loader.loadMusic("assets/audio/menuMusic.ogg")
        self.menuMusic.setLoop(True)
        self.fightMusic = loader.loadMusic("assets/audio/fightMusic.ogg")
        self.fightMusic.setLoop(True)
        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

        #
        # EVENT HANDLING
        #
        # By default we accept the escape key
        self.accept("escape", self.__escape)

        #
        # ENTER GAMES INITIAL FSM STATE
        #
        self.request("Menu")
Ejemplo n.º 22
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Importar modulos
import pygame
import director
from director import *
from menu import Menu

if __name__ == '__main__':

    # Inicializamos la libreria de pygame
    pygame.init()
    pygame.mixer.pre_init(44100,16,2,4096)
    pygame.mixer.init()
    # Creamos el director
    director = Director()
    # Creamos la escena con la pantalla inicial
    escena = Menu(director)
    # Le decimos al director que apile esta escena
    director.apilarEscena(escena)
    # Y ejecutamos el juego
    director.ejecutar()
    # Cuando se termine la ejecución, finaliza la librería
    pygame.quit()
Ejemplo n.º 23
0
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode(
            (self.screen_width * self.screen_scale,
             self.screen_height * self.screen_scale))
        pygame.display.set_caption("InfoWest Tower Security")
        self.clock = pygame.time.Clock()
        self.graphics = Graphics()
        self.canvas = Canvas(self)

        self.timer = Timer()

        self.turn_counter = TurnCounter()
        self.game_objects[State.STATE_GAME_BATTLE].append(self.turn_counter)

        # === Game Objects ===
        self.title_screen = Object(self, (0, 0), self.screen_size,
                                   Graphic([self.graphics.title_screen], [0]))
        self.background = Object(self, (0, 0), self.screen_size,
                                 Graphic([self.graphics.background], [0]))
        self.player = Player(
            self,
            (((self.screen_width / self.sprite_width) / 2) * self.sprite_width,
             self.screen_height - self.sprite_height), (32, 32),
            Graphic([
                self.graphics.player_walk_0, self.graphics.player_walk_1,
                self.graphics.player_walk_2
            ], [10, 10, 10]))
        self.heart = Object(self, (self.screen_width - 18, 2), (16, 16),
                            Graphic([self.graphics.heart_full], [0]))
        self.heart_bar = Object(self, (self.screen_width - 14, 22), (8, 38),
                                color=(250, 15, 15))
        self.armour = Object(self, (self.screen_width - 18, 64), (16, 16),
                             Graphic([self.graphics.armour], [0]))
        self.armour_bar = Object(self, (self.screen_width - 14, 84), (8, 38),
                                 color=(100, 100, 100))
        self.ladder = Ladder(self, int(self.screen_width / self.sprite_width),
                             int(self.screen_height / self.sprite_height),
                             (0, 0))
        self.game_over = Object(self, (0, 0), self.screen_size,
                                Graphic([self.graphics.game_over], [0]))
        self.game_objects[State.STATE_GAME_MENU].append(self.title_screen)
        self.game_objects[State.STATE_GAME_CLIMB].append(self.background)
        for i in range(7):
            cloudtype = randint(0, 2)
            types = [
                self.graphics.cloud_1, self.graphics.cloud_2,
                self.graphics.cloud_3
            ]
            cloud = Object(self, (randint(
                0, self.screen_width), randint(0, self.screen_height - 75)),
                           (24, 24), Graphic([types[cloudtype]], [0]))
            cloud.set_velocity(random.uniform(1, 1.5), 0)
            self.clouds.append(cloud)
            self.game_objects[State.STATE_GAME_CLIMB].append(cloud)

        self.game_objects[State.STATE_GAME_CLIMB].append(self.player)
        self.game_objects[State.STATE_GAME_CLIMB].append(self.heart)
        self.game_objects[State.STATE_GAME_CLIMB].append(self.heart_bar)
        self.game_objects[State.STATE_GAME_CLIMB].append(self.armour)
        self.game_objects[State.STATE_GAME_CLIMB].append(self.armour_bar)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.background)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.player)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.heart_bar)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.heart)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.armour)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.armour_bar)
        self.game_objects[State.STATE_GAME_OVER].append(self.game_over)
        self.game_objects[State.STATE_GAME_CLIMB].append(self.ladder)

        timer_lengths = []
        for i in range(self.timer.max):
            timer_lengths.append(self.timer.max / 8)
        self.action_timer = ActionTimer(
            self, (0, 0), self.sprite_size,
            Graphic([self.graphics.timer_face], [0]),
            Graphic([
                self.graphics.timer_needle_n, self.graphics.timer_needle_ne,
                self.graphics.timer_needle_e, self.graphics.timer_needle_se,
                self.graphics.timer_needle_s, self.graphics.timer_needle_sw,
                self.graphics.timer_needle_w, self.graphics.timer_needle_nw
            ], timer_lengths))
        self.game_objects[State.STATE_GAME_CLIMB].append(self.action_timer)

        self.menu_battle = Menu(self, (0, self.screen_height),
                                ["Attack", "Defend", "Item"],
                                pointer=Graphic([self.graphics.menu_arrow],
                                                [0]))
        self.game_objects[State.STATE_GAME_BATTLE].append(self.menu_battle)

        self.game_objects[State.STATE_GAME_CLIMB].append(self.player)
        self.game_objects[State.STATE_GAME_BATTLE].append(self.player)

        self.floor_text = Text(self, (4, self.screen_height - 28),
                               str(self.player.floor), 24, (255, 255, 255))
        self.game_objects[State.STATE_GAME_CLIMB].append(self.floor_text)
from menu import Menu, MenuItem
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine

coffee_maker=CoffeeMaker()
money_machine=MoneyMachine()
coffee_menu=Menu()
coffeemachine_is_on=True
while coffeemachine_is_on:
    choice=input("What would you like? "+coffee_menu.get_items()+":​ ")
    sufficient_resources=True
    if choice=="off":
         coffeemachine_is_on=False
    elif choice=="report":
        coffee_maker.report()
        money_machine.report()
    else:
        drink=coffee_menu.find_drink(choice)
        if drink != None:
            sufficient_resources=coffee_maker.is_resource_sufficient(drink)
            if sufficient_resources == True:
                money_machine.make_payment(drink.cost)
                coffee_maker.make_coffee(drink)

Ejemplo n.º 25
0
 def setUp(self):
     option = MenuOption('a', 'First Option', WorkLog(), 'add_task')
     self.menu = Menu()
     self.menu.options.append(option)
Ejemplo n.º 26
0
from pyimagesearch.keyclipwriter import KeyClipWriter
from imutils.video import VideoStream
import argparse
import datetime
import imutils
import time
import cv2

from upload import upload
from menu import Menu

mn = Menu()

print("[INFO] Esquentando a câmera")
vs = VideoStream(usePiCamera=mn.parametros['camera'] > 0).start()
time.sleep(2.0)

kcw = KeyClipWriter(mn.parametros['buffer'])
consecFrames = 0 #conta o numero de frames que não contém um evento de interesse

while True:

    #pega o frame atual, redimensiona
    frame = vs.read()
    frame = imutils.resize(frame, width = mn.parametros['resolucao_w'])
    updateConsecFrames = True

    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1) & 0xFF

    if key == ord('q'): #finaliza o monitoramento
Ejemplo n.º 27
0
size = (1400, 900)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Moon Patrol")


def goto_menu():
    global current_scene
    current_scene = menu


def goto_game():
    global current_scene
    current_scene = Game(screen)


menu = Menu(screen, goto_game)
current_scene = menu

done = False
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        eventmanager.execute_events(event)

    current_scene.tick()
    current_scene.draw()
Ejemplo n.º 28
0
    def __init__(self, AGREE_TIME, WIN_TIME, COOLDOWN_TIME, STALE_TIME,
                 TOTAL_TIME, FAILURE_TIME, NUM_WINS, keys, p_list_rect,
                 scoreboard_rect, top_rect, top_rect_left, top_rect_right,
                 game_rect, bottom_rect, shadow_dist, sys_font):
        # -- IMPORTS --
        self.keys = keys
        self.top_rect_left = top_rect_left
        self.top_rect_right = top_rect_right
        self.bottom_rect = bottom_rect
        self.AGREE_TIME = AGREE_TIME
        self.NUM_WINS = NUM_WINS
        self.shadow_dist = shadow_dist

        # -- MATCH INFO --
        self.match_num = 0
        self.big_f_agree = self.big_j_agree = 0
        self.f_wins = self.j_wins = 0
        self.score_streak = 0

        # -- NECESSARY CLASSES --
        self.p_list = PlayerList(p_list_rect, shadow_dist, sys_font)
        self.game = Game(WIN_TIME, COOLDOWN_TIME, STALE_TIME, TOTAL_TIME,
                         FAILURE_TIME, self.keys, game_rect, shadow_dist,
                         sys_font)
        self.wheel = Wheel(game_rect, shadow_dist, sys_font)
        self.hud = Hud(top_rect, bottom_rect, shadow_dist, sys_font)
        self.scoreboard = Scoreboard(scoreboard_rect, shadow_dist, sys_font,
                                     self.p_list)
        self.menu = Menu(p_list_rect, self.keys, shadow_dist, sys_font)
        self.match_state = MatchState(MatchState.PLAYER_LIST,
                                      self.state_response)

        # -- MENU ACTIONS --
        self.menu.add_item(
            "[2]", "PRACTICE MODE", 0.5,
            lambda: self.match_state.set_state(MatchState.PRACTICE_MODE))
        self.menu.add_item(
            "[3]", "RESET MATCHUP", 0.5,
            lambda: self.match_state.set_state(MatchState.NEW_OPPONENT,
                                               same_match=True))
        self.menu.add_item(
            "[4]", "NEXT OPPONENT", 0.5,
            lambda: self.match_state.set_state(MatchState.NEW_OPPONENT,
                                               next=True))
        self.menu.add_item(
            "[5]", "CHANGE PLAYERS", 0.5,
            lambda: self.match_state.set_state(MatchState.PLAYER_LIST))

        # -- RENDERING --
        # bottom bar
        self.f_name_text = TextRenderer(
            sys_font, 2, (top_rect_left.centerx, bottom_rect.centery),
            shadow_dist)
        self.j_name_text = TextRenderer(
            sys_font, 2, (top_rect_right.centerx, bottom_rect.centery),
            shadow_dist)
        self.streak_text = TextRenderer(
            sys_font, 1, (bottom_rect.width * 0.08,
                          bottom_rect.centery + bottom_rect.height * 0.25),
            shadow_dist)

        self.practice_mode_text = TextRenderer(sys_font, 2, bottom_rect.center,
                                               0)
        self.practice_inst_rect = Rect(
            (game_rect.left + game_rect.height * 0.05,
             game_rect.top + game_rect.height * 0.05),
            (game_rect.width, game_rect.height * 0.25))
        self.practice_inst_0 = ShadowedPressable.make_pressable_key(
            "1. Hold your key to build your bar.", sys_font, 1,
            GameColor.Pink)[0].convert_alpha()
        self.practice_inst_1 = ShadowedPressable.make_pressable_key(
            "2. Press [SPACE] to reset moving bars.", sys_font, 1,
            GameColor.Cyan)[0].convert_alpha()
        self.practice_inst_2 = ShadowedPressable.make_pressable_key(
            "3. Build the biggest bar to win!", sys_font, 1,
            GameColor.Yellow)[0].convert_alpha()

        # vs
        self.new_match_text = TextRenderer(
            sys_font, 4,
            (game_rect.centerx, game_rect.top + game_rect.height / 6),
            shadow_dist, GameColor.White)

        self.vs_left_bar = Rect((0, game_rect.y + game_rect.height / 3),
                                (top_rect_left.width, game_rect.height / 5))
        self.vs_right_bar = Rect(
            (game_rect.centerx, self.vs_left_bar.bottom),
            (self.vs_left_bar.width, self.vs_left_bar.height))
        vs_par_width = game_rect.height / 7
        self.vs_parallelogram = ((game_rect.centerx, self.vs_left_bar.top),
                                 (game_rect.centerx - vs_par_width,
                                  self.vs_right_bar.bottom),
                                 (game_rect.centerx, self.vs_right_bar.bottom),
                                 (game_rect.centerx + vs_par_width,
                                  self.vs_left_bar.top))
        self.f_name_big_text = TextRenderer(
            sys_font, 4, (top_rect_left.centerx + shadow_dist,
                          self.vs_left_bar.centery + shadow_dist), shadow_dist,
            GameColor.F.Dark)
        self.j_name_big_text = TextRenderer(
            sys_font, 4, (top_rect_right.centerx + shadow_dist,
                          self.vs_right_bar.centery + shadow_dist),
            shadow_dist, GameColor.J.Dark)
        self.vs_text = TextRenderer(sys_font, 2,
                                    (game_rect.centerx + shadow_dist,
                                     self.vs_left_bar.bottom + shadow_dist),
                                    shadow_dist)
        self.vs_left_bar.move_ip((top_rect_left.width, 0))

        big_f, big_f_shadow = ShadowedPressable.make_pressable_key(
            "[F]", sys_font, 4)
        self.big_f = ShadowedPressable(
            big_f.convert_alpha(), big_f_shadow,
            (top_rect_left.centerx, game_rect.top + game_rect.height * 0.85),
            shadow_dist)
        big_j, big_j_shadow = ShadowedPressable.make_pressable_key(
            "[J]", sys_font, 4)
        self.big_j = ShadowedPressable(
            big_j.convert_alpha(), big_j_shadow,
            (top_rect_right.centerx, game_rect.top + game_rect.height * 0.85),
            shadow_dist)

        # counter
        self.counter = TextRenderer(sys_font, 4, game_rect.center, shadow_dist)
        self.ready_text = TextRenderer(
            sys_font, 2,
            (game_rect.centerx, game_rect.top + game_rect.height * 0.35),
            shadow_dist)

        # win rects
        win_rect_size = top_rect.height * 0.15
        self.win_rect = Rect(top_rect.centerx - win_rect_size / 2,
                             win_rect_size, win_rect_size, win_rect_size)
        self.win_rect_shadows = [
            self.win_rect.move(self.win_rect.width * 2 * idx, 0)
            for idx in [-3, -2, -1, 1, 2, 3]
        ]
        self.f_win_rects = []
        self.j_win_rects = []

        # win text
        self.f_win_loss_text = TextRenderer(
            sys_font, 4,
            (top_rect_left.centerx, game_rect.top + game_rect.height * 0.35),
            shadow_dist)
        self.j_win_loss_text = TextRenderer(
            sys_font, 4,
            (top_rect_right.centerx, game_rect.top + game_rect.height * 0.35),
            shadow_dist)
        self.f_plus_minus_text = TextRenderer(
            sys_font, 4,
            (top_rect_left.centerx, game_rect.top + game_rect.height * 0.65),
            shadow_dist)
        self.j_plus_minus_text = TextRenderer(
            sys_font, 4,
            (top_rect_right.centerx, game_rect.top + game_rect.height * 0.65),
            shadow_dist)
        self.f_enc_cons_text = TextRenderer(
            sys_font, 1,
            (top_rect_left.centerx, game_rect.top + game_rect.height * 0.5),
            shadow_dist / 8)
        self.j_enc_cons_text = TextRenderer(
            sys_font, 1,
            (top_rect_right.centerx, game_rect.top + game_rect.height * 0.5),
            shadow_dist / 8)

        # tweens
        self.vs_bar_w = Tweener(
            {
                "retracted": 0,
                "extended": top_rect_left.width
            }, "retracted")
        self.f_name_big_x = Tweener(
            {
                "out": 0,
                "in": self.f_name_big_text.center[0]
            }, "out")
        self.j_name_big_x = Tweener(
            {
                "out": game_rect.right,
                "in": self.j_name_big_text.center[0]
            }, "out")

        # -- SOUND --
        self.vs_sound = pygame.mixer.Sound("SFX/VS.wav")
        self.timer_sound = pygame.mixer.Sound("SFX/beep.wav")
        self.begin_sound = pygame.mixer.Sound("SFX/begin_game.wav")
        self.climax_sound = pygame.mixer.Sound("SFX/climax.wav")
        self.victory_sounds = [
            pygame.mixer.Sound("SFX/vic{0}.wav".format(i)) for i in range(3)
        ]
        self.win_sound = pygame.mixer.Sound("SFX/win.wav")

        self.reset()
Ejemplo n.º 29
0
def buildRooms():

    MainEntrance = Room([2,6,10,12],
                        "Main Entrance",
                        "This is the main entrance of the building. In front of you is a grand staircase. There is a door to your left, one to the right, and also a door under the stairs.")
    GrandeLounge = Room([1,3],
                        "Grande Lounge",
                        "This is a large social area complete with a wet bar.")
    DiningRoom = Room([2,6],
                      "Dining Room",
                      "This is a large dining room complete with a long dinner table set with food.")
    Storage = Room([5],
                   "Storage",
                   "Storage pantry with plenty of food.")
    ServantsQuarters = Room([4,6],
                             "Servant's Quarters",
                             "A small cot and a few magazines are surrounded by dirty clothes" )
    Kitchen = Room([3,5,7,1],
                   "Kitchen",
                   "Large kitchen complete with an island and all appliances.")
    Freezer = Room([6],
                   "Freezer",
                   "Walk in freezer. Relatively empty")
    BallRoom = Room([6,9],
                    "Ball Room",
                    "Large ball room that has been decorated for some event. There is a stage in the corner, and an open ceiling that looks up to a balcony.")
    Restroom = Room([8,10],
                    "Restroom",
                    "Large fancy restroom with marble floors and a couch. Contains two entrances.")
    SideRoom = Room([1,9,11],
                    "Side Room",
                    "Large room that has recently been used for storage. There appears to be another small closet in the corner.")
    Nook = Room([10],
                "Nook",
                "A small closet which contains a large table with physics experiments on top")
    LargeHallway = Room([13,14,15,16,17,18],
                        "Large Hallway",
                        "A large hallway at the top of the stairs")
    BallRoomOverLook = Room([12,23],
                            "Ball Room OverLook",
                            "An open balcony the looks down on the ballroom")
    GuestBath1 = Room([12],
                      "Guest Bath 1",
                      "Small bathroom with a sink and tub")
    GuestBath2 = Room([12],
                      "Guest Bath 2",
                      "Small bathroom with a sink and tub")
    GuestRoom1 = Room([18],
                      "Guest Room 1",
                      "Guest bedroom one of 4 identical")
    GuestRoom2 = Room([18],
                      "Guest Room 2",
                      "Guest bedroom one of 4 identical")
    GuestRoom3 = Room([18],
                      "Guest Room 3",
                      "Guest bedroom one of 4 identical")
    GuestRoom4 = Room([18],
                      "Guest Room 4",
                      "Guest bedroom one of 4 identical")
    MasterBath = Room([17],
                      "Master Bath",
                      "Master Bathroom. Two sinks and a shower with water that falls from the ceiling")
    MasterBedRoom = Room([12,16,24],
                         "Master BedRoom",
                         "Master bedroom. King size bed. There appears to be a double door that opens to a balcony")
    Hallway = Room([12,19,20,21,22],
                   "Hallway",
                   "Narrow hallway")
    Library = Room([13],
                   "Library",
                   "A very interesting library. There are four rows of books, mostly math and science.")
    MasterBalcony = Room([17],
                         "Master Balcony",
                         "A small balcony that overlooks a fountain in the garden")
    Building = Room(description=" A large mansion that holds many secrets")

    roomList = [Building,MainEntrance,GrandeLounge,DiningRoom,Storage,ServantsQuarters,Kitchen,Freezer,BallRoom,
                Restroom,SideRoom,Nook,LargeHallway,BallRoomOverLook,GuestBath1,GuestBath2,MasterBath,
               MasterBedRoom,Hallway,GuestRoom1,GuestRoom2,GuestRoom3,GuestRoom4,Library,MasterBalcony]
      
    for room in roomList:
        leave_options = [Option("Enter {}".format(roomList[index].name), roomList[index].display) for index in room.adjacentRooms]
        leave_options.append(Option("Stay in {}".format(room.name), room.display))
        room.leave_menu = Menu(leave_options, "Where would you like to enter?")
        
        action_options = [Option("Look at Map",printLayout)]
        action_options.append(Option("Read journal", journal.read))
        action_options.append(Option("Add journal entry", journal.player_entry))
        action_options.append(Option("Consult your pal Heisenburg",askBurg))
        action_options.append(Option("Look at an item more closely",itemInteract))
        action_options.append(Option("Back",room.display))
        
        room.action_menu = Menu(action_options, "What action will you perform?")

        room.menu = Menu([Option("Inpect {}".format(room.name), room.inspectShit),
				   Option("Perform an action",room.action_menu.display),
                          Option("Leave {}".format(room.name), room.leave_menu.display)],
                          "You are in the {}.".format(room.name))

    return roomList
Ejemplo n.º 30
0
    return True


TILE_SIZE = 10
ROWS = 70
COLUMNS = 120

pygame.init()
screen = pygame.display.set_mode((COLUMNS * TILE_SIZE, ROWS * TILE_SIZE))
clock = pygame.time.Clock()

setup = Setup(screen, TILE_SIZE, ROWS, COLUMNS)

loop = True

menu = Menu(screen, TILE_SIZE, ROWS, COLUMNS)
settings = menu.display_menu(screen)

game_map = settings["Map"]
game_speed = settings["Speed"]
probability_of_alive = settings["Probability"]

while loop:
    event = pygame.event.poll()

    if event.type == pygame.QUIT:
        break

    if event.type == pygame.KEYDOWN:
        key = event.dict["key"]
        loop = input_handler(key)