Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #All rights reserved for A-MAN a.k.a Mr.A
- #Coded in python
- #uses pygame library
- import pygame, sys, os, time
- from pygame.locals import *
- from winsound import Beep
- def Close():
- pygame.quit()
- sys.exit()
- def collide_w_mouse(x, y, rect):
- if (x > rect.left) and (x < rect.right) and (y > rect.top) and (y < rect.bottom):
- return True
- else:
- return False
- def collide_w_mouse2(x, y, polygon1):
- if (x > polygon1[0][0]) and (x < polygon1[1][0]) and (y > polygon1[1][1]) and (y < polygon1[2][1]):
- return True
- else:
- return False
- def collide_w_mouse3(x, y, polygon1):
- if (x < polygon1[0][0]) and (x > polygon1[1][0]) and (y > polygon1[1][1]) and (y < polygon1[2][1]):
- return True
- else:
- return False
- def main():
- global freq, beep1, beep2, beep3, beep4, beep5, beep6, beep7, beep8, beep9, Clock, FPS
- APPNAME= 'A-PIANO'
- freq= 0
- COLORS = {'black' : (0 , 0 , 0 ), 'red' : (150, 0 , 0 ),
- 'blue' : (0 , 0 , 150), 'green' : (0 , 150, 0 ),
- 'orange': (150, 50 , 0 ), 'purple': (50 , 0 , 150),
- 'yellow': (150, 150, 0 ), 'aqua' : (0 , 150, 150),
- 'teal' : (0 , 50 , 50 ), 'grey' : (100, 100, 100),
- 'white' : (255, 255, 255), 'brown' : (128, 64 , 0 ),
- 'pink' : (155, 0 , 155), 'sred' : (255, 0 , 0 ),
- 'sgreen': (0 , 255, 0 ), 'sblue' : (0 , 0 , 255)}
- LIGHTCOLORS = {'light red' : (250, 100, 100), 'light blue' : (100, 100, 250),
- 'light green' : (100, 250, 100), 'light orange': (250, 150, 100),
- 'light purple': (150, 50 , 250), 'light yellow': (250, 250, 100),
- 'light aqua' : (100, 250, 250), 'light teal' : (100, 150, 150),
- 'light grey' : (200, 200, 200), 'light white' : (50 , 50 , 50 ),
- 'light brown' : (228, 164, 100), 'light pink' : (255, 0 , 255)}
- pygame.init()
- pygame.display.set_caption(APPNAME)
- DISPLAYSURF = pygame.display.set_mode((780, 600), 0, 32)
- instructions1 = 'You can either use the mouse to click on the buttons'
- instructions2 = 'or use the keyboard keys: A S D F G H J K L ; \' \\ '
- instructions3 = 'and the left and right buttons to change the frequency average.'
- thecopyright = 'All rights reserved for the A-MAN (c)2011-2012'
- WELCOMINGFONT = pygame.font.SysFont(None, 100)
- NORMALFONT = pygame.font.SysFont(None, 30 )
- COPYRIGHTFONT = pygame.font.SysFont(None, 20 )
- FREQFONT = pygame.font.SysFont(None, 40 )
- BGCOLOR = COLORS['black']
- MenuText = WELCOMINGFONT.render('A-PIANO', True, COLORS['white'], BGCOLOR)
- MenuTextrect = MenuText.get_rect()
- InstText1 = NORMALFONT.render(instructions1, True, COLORS['blue'], BGCOLOR)
- InstTextrect1 = InstText1.get_rect()
- InstText2 = NORMALFONT.render(instructions2, True, COLORS['blue'], BGCOLOR)
- InstTextrect2 = InstText2.get_rect()
- InstText3 = NORMALFONT.render(instructions3, True, COLORS['blue'], BGCOLOR)
- InstTextrect3 = InstText3.get_rect()
- CopyRText = NORMALFONT.render(thecopyright, True, COLORS['yellow'], BGCOLOR)
- CopyRTextrect = CopyRText.get_rect()
- FREQLABEL = WELCOMINGFONT.render(str(freq), True, COLORS['sgreen'], BGCOLOR)
- FREQLABELrect = FREQLABEL.get_rect()
- MenuTextrect.centerx = DISPLAYSURF.get_rect().centerx
- MenuTextrect.top = DISPLAYSURF.get_rect().top + 100
- InstTextrect1.center = DISPLAYSURF.get_rect().center
- InstTextrect2.center = DISPLAYSURF.get_rect().center
- InstTextrect2.centery= DISPLAYSURF.get_rect().centery+50
- InstTextrect3.center = DISPLAYSURF.get_rect().center
- InstTextrect3.centery= DISPLAYSURF.get_rect().centery+100
- CopyRTextrect.centerx= DISPLAYSURF.get_rect().centerx
- CopyRTextrect.bottom = DISPLAYSURF.get_rect().bottom - 20
- FREQLABELrect.centerx= DISPLAYSURF.get_rect().centerx - 40
- FREQLABELrect.centery= 470
- buttonsize = {'1' : pygame.Rect(35 , 200, 50, 200), '2' : pygame.Rect(95 , 200, 50, 200), '3' : pygame.Rect(155, 200, 50, 200),
- '4' : pygame.Rect(215, 200, 50, 200), '5' : pygame.Rect(275, 200, 50, 200), '6' : pygame.Rect(335, 200, 50, 200),
- '7' : pygame.Rect(395, 200, 50, 200), '8' : pygame.Rect(455, 200, 50, 200), '9' : pygame.Rect(515, 200, 50, 200),
- '10': pygame.Rect(575, 200, 50, 200), '11': pygame.Rect(635, 200, 50, 200), '12': pygame.Rect(695, 200, 50, 200),
- '13': ((200, 470),(250, 420), (250, 520)), '14': ((580, 470),(530, 420), (530, 520))}
- buttons = {'1' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'red\'], buttonsize[\'2\'], 10)',
- '2' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'blue\'], buttonsize[\'3\'], 10)',
- '3' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'green\'], buttonsize[\'4\'], 10)',
- '4' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'orange\'], buttonsize[\'5\'], 10)',
- '5' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'purple\'], buttonsize[\'6\'], 10)',
- '6' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'yellow\'], buttonsize[\'7\'], 10)',
- '7' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'aqua\'], buttonsize[\'8\'], 10)',
- '8' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'teal\'], buttonsize[\'9\'], 10)',
- '9' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'white\'], buttonsize[\'1\'], 10)',
- '10' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'brown\'], buttonsize[\'10\'], 10)',
- '11' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'pink\'], buttonsize[\'11\'], 10)',
- '12' : 'pygame.draw.rect(DISPLAYSURF, COLORS[\'grey\'], buttonsize[\'12\'], 10)',
- 'bleft' : 'pygame.draw.polygon(DISPLAYSURF, COLORS[\'sred\'], buttonsize[\'13\'], 10)',
- 'bright' : 'pygame.draw.polygon(DISPLAYSURF, COLORS[\'sblue\'], buttonsize[\'14\'], 10)'}
- beep1, beep2, beep3, beep4, beep5, beep6, beep7, beep8, beep9, beep10, beep11, beep12 = False, False, False, False, False, False, False, False, False, False, False, False
- light1,light2,light3,light4,light5,light6,light7,light8,light9, light10, light11, light12 = False, False, False, False, False, False, False, False, False, False, False, False
- light13, light14 = False, False
- FPS = 100
- Clock = pygame.time.Clock()
- window = 1
- DISPLAYSURF.fill(BGCOLOR)
- while True:
- DISPLAYSURF.fill(BGCOLOR)
- if window == 1:
- DISPLAYSURF.blit(MenuText, MenuTextrect)
- DISPLAYSURF.blit(InstText1, InstTextrect1)
- DISPLAYSURF.blit(InstText2, InstTextrect2)
- DISPLAYSURF.blit(InstText3, InstTextrect3)
- DISPLAYSURF.blit(CopyRText, CopyRTextrect)
- for event in pygame.event.get():
- if event.type == QUIT:
- Close()
- if event.type == KEYDOWN:
- if event.key == K_RETURN:
- window += 1
- DISPLAYSURF.fill(BGCOLOR)
- if event.key == K_ESCAPE:
- Close()
- if window == 2:
- FREQLABEL= WELCOMINGFONT.render(str(freq+600), True, COLORS['sgreen'], BGCOLOR)
- DISPLAYSURF.blit(MenuText, MenuTextrect)
- DISPLAYSURF.blit(MenuText, MenuTextrect)
- DISPLAYSURF.blit(CopyRText, CopyRTextrect)
- DISPLAYSURF.blit(FREQLABEL, FREQLABELrect)
- for a in buttons:
- exec(buttons[a])
- COLORS = {'black' : (0 , 0 , 0 ), 'red' : (150, 0 , 0 ),
- 'blue' : (0 , 0 , 150), 'green' : (0 , 150, 0 ),
- 'orange': (150, 50 , 0 ), 'purple': (50 , 0 , 150),
- 'yellow': (150, 150, 0 ), 'aqua' : (0 , 150, 150),
- 'teal' : (0 , 50 , 50 ), 'grey' : (100, 100, 100),
- 'white' : (255, 255, 255), 'brown' : (128, 64 , 0 ),
- 'pink' : (155, 0 , 155), 'sred' : (255, 0 , 0 ),
- 'sgreen': (0 , 255, 0 ), 'sblue' : (0 , 0 , 255)}
- for event in pygame.event.get():
- if event.type == QUIT:
- Close()
- if event.type == MOUSEBUTTONDOWN:
- if event.button == 1:
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['1']):
- light1 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['2']):
- light2 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['3']):
- light3 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['4']):
- light4 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['5']):
- light5 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['6']):
- light6 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['7']):
- light7 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['8']):
- light8 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['9']):
- light9 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['10']):
- light10 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['11']):
- light11 = True
- if collide_w_mouse(event.pos[0], event.pos[1], buttonsize['12']):
- light12 = True
- if collide_w_mouse2(event.pos[0], event.pos[1], buttonsize['13']):
- light13 = True
- if collide_w_mouse3(event.pos[0], event.pos[1], buttonsize['14']):
- light14 = True
- if event.type == MOUSEBUTTONUP:
- if event.button == 1:
- beep1, beep2, beep3, beep4, beep5, beep6, beep7, beep8, beep9, beep10, beep11, beep12 = False, False, False, False, False, False, False, False, False, False, False, False
- light1,light2,light3,light4,light5,light6,light7,light8,light9, light10, light11, light12 = False, False, False, False, False, False, False, False, False, False, False, False
- light13, light14 = False, False
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- Close()
- if event.key == K_RIGHT:
- light14 = True
- if event.key == K_LEFT:
- light13 = True
- if event.key == ord('a') or event.key == ord('A'):
- light1 = True
- if event.key == ord('s') or event.key == ord('S'):
- light2 = True
- if event.key == ord('d') or event.key == ord('D'):
- light3 = True
- if event.key == ord('f') or event.key == ord('F'):
- light4 = True
- if event.key == ord('g') or event.key == ord('G'):
- light5 = True
- if event.key == ord('h') or event.key == ord('H'):
- light6 = True
- if event.key == ord('j') or event.key == ord('J'):
- light7 = True
- if event.key == ord('k') or event.key == ord('K'):
- light8 = True
- if event.key == ord('l') or event.key == ord('L'):
- light9 = True
- if event.key == ord(';'):
- light10= True
- if event.key == ord('\''):
- light11= True
- if event.key == ord('\\'):
- light12= True
- if event.type == KEYUP:
- if event.key == ord('a') or event.key == ord('A'):
- beep1 = False
- light1 = False
- if event.key == ord('s') or event.key == ord('S'):
- beep2 = False
- light2 = False
- if event.key == ord('d') or event.key == ord('D'):
- beep3 = False
- light3 = False
- if event.key == ord('f') or event.key == ord('F'):
- beep4 = False
- light4 = False
- if event.key == ord('g') or event.key == ord('G'):
- beep5 = False
- light5 = False
- if event.key == ord('h') or event.key == ord('H'):
- beep6 = False
- light6 = False
- if event.key == ord('j') or event.key == ord('J'):
- beep7 = False
- light7 = False
- if event.key == ord('k') or event.key == ord('K'):
- beep8 = False
- light8 = False
- if event.key == ord('l') or event.key == ord('L'):
- beep9 = False
- light9 = False
- if event.key == ord(';'):
- beep10 = False
- light10= False
- if event.key == ord('\''):
- beep11 = False
- light11= False
- if event.key == ord('\\'):
- beep12 = False
- light12= False
- if event.key == K_RIGHT:
- light14 = False
- if event.key == K_LEFT:
- light13 = False
- if beep1 == True:
- COLORS['white'] = LIGHTCOLORS['light white']
- Beep(1200+ freq, 100)
- if beep2 == True:
- COLORS['red'] = LIGHTCOLORS['light red']
- Beep(1350+ freq, 100)
- if beep3 == True:
- COLORS['blue'] = LIGHTCOLORS['light blue']
- Beep(1500+ freq, 100)
- if beep4 == True:
- COLORS['green'] = LIGHTCOLORS['light green']
- Beep(1650+ freq, 100)
- if beep5 == True:
- COLORS['orange'] = LIGHTCOLORS['light orange']
- Beep(1800+ freq, 100)
- if beep6 == True:
- COLORS['purple'] = LIGHTCOLORS['light purple']
- Beep(1950+ freq, 100)
- if beep7 == True:
- COLORS['yellow'] = LIGHTCOLORS['light yellow']
- Beep(2100+ freq, 100)
- if beep8 == True:
- COLORS['aqua'] = LIGHTCOLORS['light aqua']
- Beep(2250+ freq, 100)
- if beep9 == True:
- COLORS['teal'] = LIGHTCOLORS['light teal']
- Beep(2400+ freq, 100)
- if beep10 == True:
- COLORS['brown'] = LIGHTCOLORS['light brown']
- Beep(2550+ freq, 100)
- if beep11 == True:
- COLORS['pink'] = LIGHTCOLORS['light pink']
- Beep(2600+ freq, 100)
- if beep12 == True:
- COLORS['grey'] = LIGHTCOLORS['light grey']
- Beep(2750+ freq, 100)
- if light1 == True:
- COLORS['white'] = LIGHTCOLORS['light white']
- beep1= True
- if light2 == True:
- COLORS['red'] = LIGHTCOLORS['light red']
- beep2= True
- if light3 == True:
- COLORS['blue'] = LIGHTCOLORS['light blue']
- beep3= True
- if light4 == True:
- COLORS['green'] = LIGHTCOLORS['light green']
- beep4= True
- if light5 == True:
- COLORS['orange'] = LIGHTCOLORS['light orange']
- beep5= True
- if light6 == True:
- COLORS['purple'] = LIGHTCOLORS['light purple']
- beep6= True
- if light7 == True:
- COLORS['yellow'] = LIGHTCOLORS['light yellow']
- beep7= True
- if light8 == True:
- COLORS['aqua'] = LIGHTCOLORS['light aqua']
- beep8= True
- if light9 == True:
- COLORS['teal'] = LIGHTCOLORS['light teal']
- beep9= True
- if light10 == True:
- COLORS['brown'] = LIGHTCOLORS['light brown']
- beep10= True
- if light11 == True:
- COLORS['pink'] = LIGHTCOLORS['light pink']
- beep11= True
- if light12 == True:
- COLORS['grey'] = LIGHTCOLORS['light grey']
- beep12= True
- if light13 == True:
- COLORS['sred'] = COLORS['white']
- if freq > -599:
- freq -= 1
- if light14 == True:
- COLORS['sblue'] = COLORS['white']
- if freq < 3001:
- freq += 1
- pygame.display.update()
- Clock.tick(FPS)
- if __name__ == '__main__':
- main()
- else:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement