Exemple #1
0
        elif event.type == pygame.MOUSEBUTTONDOWN and event.button == RIGHT:
            print 'Restart'
            firstInstrument.reset_parameters()
            secondInstrument.reset_parameters()
            thirdInstrument.reset_parameters()
            fourthInstrument.reset_parameters()

        # trig the instruments
        elif event.type == pygame.KEYDOWN:
   
            if event.key == pygame.K_ESCAPE:
                pygame.quit()
                sys.exit()
            
            elif event.key == pygame.K_3:
                thirdInstrument.set_flag(True)
                inputData = 6.8
                thirdInstrumentdegAngle = -20*inputData + 220

            elif event.key == pygame.K_4:
                fourthInstrument.set_flag(True)
                inputData = 3.8
                fourthInstrumentdegAngle = -20*inputData + 220

        # set instrument 1 and 2 via mouse position
        elif event.type == pygame.MOUSEMOTION:
            # the factor 107: k = (1400-1) / (12-1)
            # the factor 46:  k = (600-1) / (12-1)
            # The size of the window is 1400x600

            mouseDataX = float(event.pos[0]) / 107.0
Exemple #2
0
            mouseDataX = float(event.pos[0]) / 107.0
            mouseDataY = float(event.pos[1]) / 46.0

            # check boundaries
            if mouseDataX < 1.0:
                mouseDataX = 1.0
            elif mouseDataX > 12.0:
                mouseDataX = 12.0

#            if mouseDataY < 1.0:
#                mouseDataY = 1.0
#            elif mouseDataY > 12.0:
#                mouseDataY = 12.0

            #print float("{0:.1f}".format(mouseDataX))
            #print float("{0:.1f}".format(mouseDataY))

            firstInstrument.set_flag(True)
            inputData = float("{0:.1f}".format(mouseDataX))
            firstInstrumentdegAngle = int(-20*inputData + 220)
            print '1st angle:',firstInstrumentdegAngle

#            secondInstrument.set_flag(True)
#            inputData = float("{0:.1f}".format(mouseDataY))
#            secondInstrumentdegAngle = -20*inputData + 220

    pygame.display.update()
    fpsClock.tick(30)