示例#1
0
def main(WIDTH,HEIGHT):
  # Uncomment this to center the window on the computer screen
  os.environ['SDL_VIDEO_CENTERED'] = '1'

  # Initialize Pygame
  pygame.init()
  pygame.mixer.pre_init()
  rain = pygame.mixer.Sound("sounds/rain.wav")
  beginsound= pygame.mixer.Sound("sounds/begin.wav")
  beginsound.set_volume(1)
  
  # Create a window of 800x600 pixels
  clock = pygame.time.Clock()
  LENGTH = WIDTH
  HEIGHT = HEIGHT
  clock = pygame.time.Clock()
  screen = pygame.display.set_mode((LENGTH, HEIGHT))

  # Set the window caption
  pygame.display.set_caption("RNG-RPG")

  # Load some images to use for sample buttons
  BKG = []
  for bkg in glob.glob("./images/bkg-*.png"):
    back= load_image(bkg,"",LENGTH,HEIGHT)
    BKG.append(back)
  
  # Create the menus. 
  menu0 = cMenu(HEIGHT/5, WIDTH/5, 20, 5, 'vertical', 100, screen,
              [('Play',      1, None),
              ('Directions',         3, None),
              ('Credits',         4, None),
              ('Exit',           9, None)])

  menu1 = cMenu(HEIGHT/5, WIDTH/5, 5, 5, 'vertical', 20, screen,
              [("Tutorial", 5, None),
              ('Sandbox', 6, None),
              ('Back', 0, None)])
  
  menu2 = cMenu(0, 0, 5, 5, 'vertical', 20, screen,
              [("WASD = MOVE", 3, None),
              ('I = INVENTORY', 3, None),
              ('Left Click = ATTACK', 3, None),
              ('Right Click = SPELL ATTACK', 3, None),
              ('F = TOGGLE FULLSCREEN', 3, None),
              ('P = PAUSE', 3, None),
              ('Esc = QUIT', 3, None),
              ('Back', 0, None)])

  menu3 = cMenu(0, 0, 20, 5, 'vertical', 20, screen,
              [('PRODUCER - Larry Patrizio',               4, None),
              ('LEAD GAME DESIGNER - Shawn Jiang',         4, None),
              ('LEAD PROGRAMMER- Mathias Kallick',         4, None),
              ('LEAD ARTIST- Ed Zhou',                     4, None),
              ('LEAD SOUND SPECIALIST- Raymond Chung',     4, None),
              ('',          4, None),
              ('Back',          0, None),
              ('Exit',               9, None)])

  # Place menus at the center of the screen
  menu2.set_center(True, True)
  menu3.set_center(True, True)

  # Create the state variables (make them different so that the user event is
  # triggered at the start of the "while 1" loop so that the initial display
  # does not wait for user input)
  state = 0
  prev_state = 1

  # rect_list is the list of pygame.Rect's that will tell pygame where to
  # update the screen (there is no point in updating the entire screen if only
  # a small portion of it changed!)
  rect_list = []

#<<<<<<< Updated upstream
#=======
# <<<<<<< HEAD
# =======
  # Ignore mouse motion (greatly reduces resources when not needed)

# >>>>>>> 3ebdb56ba0392653a34cdd50d8527e66374c88cb
#>>>>>>> Stashed changes
  # The main while loop
  y=0
  pygame.mixer.music.load("sounds/BKGmusic/MenuStart/TowardsFate.wav")
  pygame.mixer.music.play(-1,0)
  rain.play(-1)
  rain.set_volume(.5)
  
  while 1:
  # Check if the state has changed, if it has, then post a user event to
  # the queue to force the menu to be shown at least once
    if prev_state != state:
      pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key = 0))
      prev_state = state
    
      if state in [0, 1, 2, 3, 4]:
      # Reset the screen before going to the next menu.  Also, put a
      # caption at the bottom to tell the user what is going one
        screen.blit(BKG[0],(0,0))
        pygame.display.flip()

    # Get the next event
    e = pygame.event.wait()

    # Update the menu, based on which "state" we are in - When using the menu
    # in a more complex program, definitely make the states global variables
    # so that you can refer to them by a name
    if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
      if state == 0:
        rect_list, state = menu0.update(e, state)
      elif state == 1:
        rain.stop()
        beginsound.play()
        play.main()
      elif state == 2:
        rect_list, state = menu1.update(e, state)
      elif state == 3:
        rect_list, state = menu2.update(e, state)
      elif state == 4:
        rect_list, state = menu3.update(e, state)
      elif state == 5:
        rain.stop()
        play.tutorial()
      elif state == 6:
        rain.stop()
        play.sandbox()
      elif state == 9:
        pygame.quit()
        sys.exit()

    # Quit if the user presses the exit button
    if e.type == pygame.QUIT:
      pygame.quit()
      sys.exit()
    if e.type == pygame.KEYDOWN:
      if e.key == pygame.K_ESCAPE:
        pygame.quit()
        sys.exit()

    # Update the screen
    pygame.display.update(rect_list)
示例#2
0
def hello_world():
    main()
    return app.send_static_file('sleeping.html')
示例#3
0
def run():
    while crystalCup == False:
        if cl.Dragon.att > 55:
            cl.Dragon.att = 55
        if cl.Dragon.dfc > 30:
            cl.Dragon.att = 30
        if cl.Dragon.dog > 35:
            cl.Dragon.dog = 35
        if cl.Dragon.spd > 50:
            cl.Dragon.spd = 50
        if cl.Dragon.sta > 50:
            cl.Dragon.sta = 50
        statShow('')
        print(
            co.g +
            'Welcome to the Dragon Center! From here you can train your dragon, practice battling other trainers, play in tournaments, or \nplay with your dragon!'
        )
        print()
        action = input(
            co.b +
            'What would you like to do?\nTrain - 1\nPractice Battles - 2\nPlay in Tournaments - 3\nPlay with '
            + cl.Dragon.name + ' - 4\n >>> ')
        if action == '1':
            if cl.Dragon.hap < 20:
                print(
                    co.r + cl.Dragon.name +
                    ' is not happy enough to train with you. Try playing with them to increase their happiness.'
                )
                s(2)
                c()
            else:
                train.main()
        elif action == '2':
            if cl.Dragon.hap < 20:
                print(
                    co.r + cl.Dragon.name +
                    ' is not happy enough to train with you. Try playing with them to increase their happiness.'
                )
                s(2)
                c()
            else:
                prat.ask()
        elif action == '3':
            if cl.Dragon.lvl < 15:
                print(
                    co.r +
                    'Sorry, you must be level 15 or above to play in tournaments.'
                )
                s(2)
                c()
                run()
            else:
                if cl.Dragon.hap < 20:
                    print(
                        co.r + cl.Dragon.name +
                        ' is not happy enough to fight with you. Try playing with them to increase their happiness.'
                    )
                    s(2)
                    c()
                else:
                    tourney.main()
        elif action == '4':
            play.main()
        elif action == 'RESET':
            print(co.y + 'Reseting high scores...')
            s(2)
            c()
            run()
            cl.highScores.attack = 100000
            cl.highScores.defense = 100000
            cl.highScores.dodge = 100000
            cl.highScores.speed = 100000
            cl.highScores.stamina = 100000
        else:
            print(co.y + 'Please answer with a 1, 2, 3, or a 4.')
            s(2)
            c()
            run()
示例#4
0
def main(letters, freq, wpm, fs, prompt, outFile, length):
    message = ''.join((random.choice(letters) for i in range(length)))
    play.main(message, freq, wpm, fs, prompt, outFile)
示例#5
0
  def test_script_can_play_video(self):
    # Joe wants to play a video, he runs the script
    # with no commands and gets instructions on how to run in
    out = StringIO()
    with redirect_stdout(out):
      main()

    self.assertEqual(help, out.getvalue().strip())

    # After seeing the help, he tries to play a video, but
    # he enters a filename that doesn't exist and gets an error
    filename = 'sjgjhsgfjhvajhasjhfv'
    with self.assertRaises(FileNotFoundError):
      main(['play.py', filename])

    # Joe plays a file that exists
    filename = 'https://www.youtube.com/watch?v=B1WiYtAfNoQ'
    main(['play.py', filename])
    sleep(2)

    path = get('path')
    self.assertEqual(filename, path)

    # Joe needs to get a drink, so he pauses the video
    main(['play.py', 'pause'])
    sleep(1)

    paused = get('pause')
    self.assertEqual(True, paused)

    # Having lost interest in the video, Joe wants to know how long is left
    out = StringIO()
    with redirect_stdout(out):
      main(['play.py', 'get', 'percent-pos'])
    sleep(1)

    self.assertIsInstance(out.getvalue().strip(), str)

    # Not wanting to watch any longer, Joe stops the video
    main(['play.py', 'stop'])
示例#6
0
def alarm_task():
    play.main("budzik.wav")
示例#7
0
from datetime import datetime
from threading import Timer
import re

import speech_test
import record
import play

play.main("start.wav")
record.main()
play.main("stop.wav")
#print("Nagrane. Odtwarzam...")

speech_result = speech_test.main()
print("Odpowiedz z api: "+speech_result)
request = re.search('(?<=budzik )[0-9]{1,2} [0-9]{0,2}', speech_result)
words = str.split(request.group())

if not words[1]:
    words[1] = '0'

print("Budzik ustawiony na godzine "+words[0]+":"+words[1])

x=datetime.today()
y=x.replace(day=x.day, hour=int(words[0]), minute=int(words[1]), second=0, microsecond=0)
delta_t=y-x

secs=delta_t.seconds+1

def alarm_task():
    play.main("budzik.wav")
示例#8
0
文件: game.py 项目: aray-openai/azero
                return True
        return False

    def _valid(self, state, player):
        return tuple(s == -1 for s in state)

    def _view(self, state, player):
        view = np.zeros((self.n_player, self.m, self.n))
        for i in range(self.m):
            for j in range(self.n):
                k = state[i * self.m + j]
                if k >= 0:
                    p = (k - player) % self.n_player
                    view[p, i, j] = 1
        return view

    def _check(self, state, player):
        assert player == (len(state) - state.count(-1)) % self.n_player

    def human(self, state):
        str_state = (str(i) if i >= 0 else '-' for i in state)
        board = tuple(zip_longest(*([iter(str_state)] * self.m)))
        return '\n'.join(' '.join(row) for row in board)


games = [Null, Binary, Flip, Count, Narrow, Matching, Roshambo, Modulo, MNOP]

if __name__ == '__main__':
    from play import main  # noqa
    main()
def main():
    time.sleep(random.randrange(10))
    play.main()
示例#10
0
    arr = np.frombuffer(buf, dtype="uint8")
    print(arr.shape)
    arr = arr.reshape((shape0, shape1))
    #print(arr.shape)
    #print(arr)

    im = Image.fromarray(arr)
    #im.show()
    im_path = 'test_images/image{}.jpg'.format(idx)

    im.save('test_images/image{}.jpg'.format(idx))
    if action == 1:
        infer_and_match(im_path)
    elif action == 2:
        image = cv2.imread(im_path)
        res = process(image)
        print("result")
        print(res)
    elif action == 3:
        image = arr
        image = np.resize(image, (120, 160))
        res = main(image)

    clientsocket.close()
    print('finished!!')

print("exit while loop")

#print(client_socket.getsockname())
#client_socket.connect(("", 5005))