def open_login(logged_in): clock = pygame.time.Clock() login_win = pygame.display.set_mode((1920, 1080)) pygame.display.set_caption("Log In") game_background = pygame.image.load("assets/game/game_background.jpg") username_text = Text(500, 375, "freesansbold", 70) username_text.set_text("Username: "******"freesansbold", 70) password_text.set_text("Password: "******"Login", 66) texts_to_draw = [username_text, password_text] input_boxes = [username_input, password_input] login_run = True while login_run: clock.tick(60) login_win.blit(game_background, (0, 0)) events = pygame.event.get() for event in events: pos = pygame.mouse.get_pos() if event.type == pygame.MOUSEBUTTONDOWN: if login_button.isOver(pos): print(f"username - {username_input.text}") print(f"password - {password_input.actual_text}") user = db.log_in(username_input.text, password_input.actual_text) if not user: logged_in = False else: logged_in = True print("Logged in is {}".format(logged_in)) mixer.fadeout(1) run_menu(user, logged_in, music=False) exit() if event.type == pygame.MOUSEMOTION: if login_button.isOver(pos): login_button.color = (54, 150, 90) else: login_button.color = (53, 189, 103) if event.type == pygame.QUIT: login_run = False for box in input_boxes: box.handle_event(event) #exit() for box in input_boxes: box.draw(login_win) for text in texts_to_draw: text.draw(login_win) login_button.draw(login_win, outline=True) pygame.display.update()
# # Create the turtle B - draw a dimond # b = turtle.Turtle() # b.shape("turtle") # b.color("blue") # b.speed(0) # for _ in range (1, 360 // 8 + 1): # draw_diamond(b) # b.right(8) # # # Create the turtle C - draw many triangles # c = turtle.Turtle() # c.shape("turtle") # c.color("green") # c.speed(0) # for _ in range (1, 5): # draw_fractal_tri(c, 400, 4) # c.rt(90) window.exitonclick() # from threading import Thread # def go(): # time.sleep(5) # mixer.fadeout(5) # # Thread(target=go).start() draw_art() mixer.fadeout(5)
#music mixer.init() mixer.music.load('/home/syfgwc/Desktop/FantasticalEnd/intro.ogg') mixer.music.play() #paths pathChoice = "" pathChoice = input("Choose 1, 2, or 3 ") #1 is homeless, 2 is teen, 3 is DID Office if pathChoice == "1": #stops loop used for error correction from running startGame = 2 #music for path 1 mixer.fadeout(3000) mixer.init() mixer.music.load('/home/syfgwc/Desktop/FantasticalEnd/homeless.ogg') mixer.music.play() print( """\n\nIt’s the crack of dawn, you are beside the river bank idly picking at the bugs on your skin. Meanwhile, you are staring meaninglessly at the scrap of blankets and trash you call a home. Suddenly, you hear a familiar voice, it’s the voice of one of your old high school teachers. He is yelling at you to jump in the river, to help get the bugs off your skin. He murmurs under his breath for you to stay in the river.\n\n""") #choice to obey voice or not playerChoice = input("Refuse to listen (1) or do as he says (2). ") #if player does not obey if playerChoice == "1": mixer.fadeout(3000)
from pygame import mixer from os import system from time import sleep import time mixer.init() mixer.music.load('Exercicio#021.mp3') mixer.music.set_volume(1) mixer.music.play() mixer.fadeout(2) song = f'0:00' m = s = 0 while (mixer.music.get_busy()): system('cls') song = f'{m}:{s:0>2}' print(song) s += 1 if s == 60: m += 1 s = 0 sleep(1)
def fade(self, num): return mixer.fadeout(num)
def fadeout(): mixer.fadeout(1000)
#yaw = math.degrees(fusionPose[2]) #print("r: %f p: %f y: %f" % (math.degrees(fusionPose[0]), # math.degrees(fusionPose[1]), math.degrees(fusionPose[2]))) roll_rad = fusionPose[0] pitch_rad = fusionPose[1] yaw_rad = fusionPose[2] chan = channel_from_euler(roll_rad, pitch_rad, yaw_rad, verbosity=1) rotating = is_rotating(data) if chan == OFF_CHANNEL and not rotating: if cur_chan != OFF_CHANNEL: print "Pausing" pm.fadeout(1000) cur_chan = OFF_CHANNEL count = 0 elif chan != cur_chan and not rotating: print "Switching to channel {}".format(chan) pm.fadeout(2500) start_sounds(sound_files[chan]) cur_chan = chan count = 0 time.sleep(poll_interval * 1.0 / 1000.0) count += 1
def stop(self): mixer.fadeout() mixer.music.unload()
#roll = math.degrees(fusionPose[0]) #pitch = math.degrees(fusionPose[1]) #yaw = math.degrees(fusionPose[2]) #print("r: %f p: %f y: %f" % (math.degrees(fusionPose[0]), # math.degrees(fusionPose[1]), math.degrees(fusionPose[2]))) roll_rad = fusionPose[0] pitch_rad = fusionPose[1] yaw_rad = fusionPose[2] chan = channel_from_euler(roll_rad, pitch_rad, yaw_rad, verbosity=1) rotating = is_rotating(data) if chan == OFF_CHANNEL and not rotating: if cur_chan != OFF_CHANNEL: print "Pausing" pm.fadeout(1000) cur_chan = OFF_CHANNEL count = 0 elif chan != cur_chan and not rotating: print "Switching to channel {}".format(chan) pm.fadeout(2500) start_sounds(sound_files[chan]) cur_chan = chan count = 0 time.sleep(poll_interval*1.0/1000.0) count += 1