Exemple #1
0
def main():
    global Score

    s = w.Arduino_Controller("COM3")

    fumen = read_json()

    #print(json.dumps(fumen))
    thread = threading.Thread(target=play_music)
    thread.deamon = True
    thread.start()
    time.sleep(0.2)

    #Score = 0

    Sums = [0, 0, 0, 0]
    Pushed = [0, 0, 0, 0]

    for i in range(len(fumen)):

        for j in range(4):
            Sums[j] += fumen[i][str(i)][j]

        print(str(Sums) + " : " + str(Score))
        #s.show_state()

        #Print
        for offset in range(6):
            print_place = i + offset - 1
            if (print_place <= 0 or len(fumen) <= print_place):
                continue
            for j in range(4):
                print_data = fumen[print_place][str(print_place)][j]
                print_led = (5 - offset) + 6 * j
                if (print_data == 1 and not Pushed[j] == 1):
                    s.LED_switch(print_led, True)
                if (print_data == -1 or (offset == 0 and Pushed[j] == 1)):
                    s.LED_switch(print_led, False)

        #Score
        Pushed = [0, 0, 0, 0]
        for j in range(4):
            if (s.switch[j + 10] == 1):
                if (Sums[j] == 1):

                    #print("OK")

                    Score += 2
                    #押したらLED消す処理(手抜きなのでLEDどころか譜面が消し飛ぶが)
                    #fumen[i][j] = 0 #悪魔の力
                    #それはさすがにないわ。修正
                    Pushed[j] = 1

                else:
                    Score -= 1
                    """
		if(len(fumen) - i < 6) :
			continue

		for _n in range(6) :
			n = i + _n
			for j in range(4) :
				if(fumen[n][str(n)][j] == 1) :
					s.LED_switch((6 - _n) * 6 + j,True)
				else :
					s.LED_switch((6 - _n) * 6 + j,False)
		"""

        time.sleep(0.2)

    s.exit_code = False
    Voice()

    print(Score)
Exemple #2
0
import Wrapper as w
import time

s = w.Arduino_Controller("COM3")

for i in range(25):
    #s.LED_switch(i - 1,False)
    s.LED_switch(i, True)
    time.sleep(0.2)

for i in range(25):
    s.LED_switch(i, False)
time.sleep(2)
for i in range(25):
    s.LED_switch(i, True)
time.sleep(2)
for i in range(25):
    s.LED_switch(i, False)
time.sleep(2)
for i in range(25):
    s.LED_switch(i, True)

s.exit_code = False