Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- pygame.font.init()
- x = 1440 # Length of Macbook Pro 13" screen
- y = 805 # height of Macbook Pro 13" screen
- screenSize = (x, y) # Creates a tuple containing screen dimensions
- screen = pygame.display.set_mode(screenSize) # Creates a screen with dimensions (x,y) px
- pygame.display.set_caption('Piano Tutor') # Sets the name of the window
- clock = pygame.time.Clock() # Initialises the Pygame clock
- colours = {"white": (255, 255, 255), "black": (0, 0, 0), "dark_green": (0, 150, 0), "light_green": (0, 255, 0),
- "light_dark_blue": (72, 94, 108)} # A colour dictionary that returns RBG colour values
- font = pygame.font.SysFont(None, 48) # Sets the font to the default font (hence 'None') and gives it a size
- small_font = pygame.font.SysFont(None, 20)
- ########################################################################################################################
- song = ['A','B','C','D','E','F','END']
- current_count = -1
- next_count = 0
- done = False
- while True: # When any subprogram finishes, the program lands here
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
- screen.fill((255, 255, 255))
- for item in song: # For each note in the song array...
- current_count = current_count + 1
- next_count = next_count + 1
- if item != "END": # If it isn't the terminating item...
- current_note = item # Sets the current note to the item being iterated over in the list. This is done for readability
- text_current_note = font.render(current_note, True, colours["black"])
- next_note = song[next_count] # Sets the next note to the next position along in the list
- text_next_note = font.render(next_note, True, colours["black"])
- if next_note == song[-1]: # If the next_note is "END"
- next_note = " " # Displays a blank space rather than END
- text_next_note = font.render(next_note, True, colours["black"])
- if current_note == song[0]: # If the current note is the beginning
- previous_note = " " # Displays a blank space in the previous note space (prevents errors too!)
- text_previous_note = font.render(previous_note, True, colours["black"])
- else: # If the current note is not at the beginning
- previous_note = song[current_count - 1] # Sets the previous note to the previous position in the list
- text_previous_note = font.render(previous_note, True, colours["black"])
- #print("| {0} | {1} | {2} |".format(previous_note, current_note, next_note)) # Displays the notes
- #played_note = input(">").upper() # Gets the input
- screen.blit(text_previous_note, (250, 385))
- screen.blit(text_current_note, (400, 385))
- screen.blit(text_next_note, (550, 385))
- pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement