12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301 |
-
- import random
- import time
- import pygame
-
- import pyaudio
- import wave
- import glob
- import os
- from itertools import cycle
- from datetime import datetime
- import ast
- #====================================
-
- State = type("State", (object,), {})
- #====================================
- class State(object):
- def __init__(self, FSM):
- self.FSM = FSM
- self.timer = 0
- self.startTime = 0
- def Enter(self):
- self.timer = 0
- self.startTime = 0
- def Execute(self):
- print('Executing')
- def Exit(self):
- print('Exiting')
-
- #====================================
-
- def play_seq(o, message):
- _id = 0
- for s in o.soundSlots:
- #print('mes ', message)
- #print('thi ', s.notes[message[0]][message[1]])
- #print(s.notes[message[0]])
-
- #if s.notes[message[1]][0] == 1:
- if s.notes[message[0]][message[1]][0] == 1:
- #o.soundSlots[_id].set_volume(s.notes[message[0]][message[1]][1])
- o.soundSlots[_id].play(s.notes[message[0]][message[1]][1])
- #print('play')
- #o.soundSlots[_id].play(s.notes[message[1]][1])
- #o.soundSlots[_id].play(s.notes[message[0]])
- _id += 1
-
- def draw_header(o):
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_text(o.header_text, o.h1, o.width, 25, o.light_grey)
- o.center_text("----------------------", o.h2, o.width, 55, o.light_grey)
- #o.draw.text((0, 0), o.header_text, font=o.h1, fill=o.light_grey)
- #o.disp.image(o.image, o.rotation)
-
- def text_box1(o, a, b):
- w1 = 0
- w2 = (o.width / 2) - 50
- h1 = 45
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box2(o, a, b):
- w1 = 0
- w2 = (o.width / 2) - 50
- h1 = 90
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box3(o, a, b):
- w1 = (o.width / 2) + 40
- w2 = o.width
- h1 = 45
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box4(o, a, b):
- w1 = (o.width / 2) + 40
- w2 = o.width
- h1 = 90
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_center(o, a, b):
- w1 = 0
- w2 = o.width
- h1 = 45
- h2 = h1 + 10
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_block(a, o.h1, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h1, [w1,h1+20,w2,h2+45], o.light_grey)
-
-
- def draw_menu1(o):
- #o = self.FSM.owner
- bpm_inc = 4
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
- _id = 0
- while _id < 16:
-
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.blue)
-
- if _id == 0:
- o.center_block("Main", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 1:
- o.center_block("Note", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 2:
- o.center_block("Patt", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 3:
- o.center_block("Song", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 4:
- o.center_block("File", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 5:
- o.center_block("Util", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- if _id == 6:
- o.center_block("Bank-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- if _id == 7:
- o.center_block("Bank+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- if _id == 8:
- o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- #if o.volume > 0:
- #o.volume -= 1
- if _id == 9:
- o.center_block("Vol+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- #if o.volume < 16:
- #o.volume += 1
- if _id == 11:
- o.center_block("Save", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 12:
- o.center_block("Play", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 13:
- o.center_block("Stop", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 14:
- o.center_block("BPM-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 15:
- o.center_block("BPM+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
-
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
-
-
- def draw_menu2(o):
- #o = self.FSM.owner
- bpm_inc = 4
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
- _id = 0
- while _id < 16:
-
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
-
- # if _id == 0:
- # o.center_block("Main", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 1:
- # o.center_block("Note", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 2:
- # o.center_block("Patt", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 3:
- # o.center_block("Song", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 4:
- # o.center_block("File", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 5:
- # o.center_block("Util", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- # if _id == 6:
- # o.center_block("Bank-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- # if _id == 7:
- # o.center_block("Bank+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- # if _id == 8:
- # o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # #if o.volume > 0:
- # #o.volume -= 1
- # if _id == 9:
- # o.center_block("Vol+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # #if o.volume < 16:
- # #o.volume += 1
- # if _id == 11:
- # o.center_block("Save", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 12:
- # o.center_block("Play", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 13:
- # o.center_block("Stop", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 14:
- # o.center_block("BPM-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- # if _id == 15:
- # o.center_block("BPM+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
-
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
-
-
-
-
-
- def menu1_actions(self, o):
- if o.keyState[16] == 2:
- if o.keyState[0] == 1:
- self.FSM.ToTransition('toMain')
- elif o.keyState[1] == 1:
- self.FSM.ToTransition('toEditSoundSequence')
- elif o.keyState[2] == 1:
- self.FSM.ToTransition('toSelectPattern')
- elif o.keyState[3] == 1:
- self.FSM.ToTransition('toEditSong')
- elif o.keyState[4] == 1:
- self.FSM.ToTransition('toFile')
- elif o.keyState[5] == 1:
- self.FSM.ToTransition('toClock')
- if o.keyState[12] == 1:
- o.start_playback()
- if o.keyState[13] == 1:
- o.stop_playback()
- if o.keyState[6] == 1:
- if o.note_bank > 0:
- o.note_bank -= 1
- if o.keyState[7] == 1:
- if o.note_bank < 4:
- o.note_bank += 1
- if o.keyState[8] == 1:
- if o.volume > 0:
- o.volume -= 1
- text_center(o, "Master Volume", str(o.volume))
- o.disp.image(o.image, o.rotation)
- if o.keyState[9] == 1:
- if o.volume < 16:
- o.volume += 1
- text_center(o, "Master Volume", str(o.volume))
- o.disp.image(o.image, o.rotation)
- if o.keyState[11] == 1:
- o.save_song()
- if o.keyState[14] == 1:
- if o.sconf.as_int('bpm') > 60:
- o.sconf['bpm'] = o.sconf.as_int('bpm') - o.bpm_inc
- o.update_bpm()
- text_center(o, "Master BPM", str(o.sconf['bpm']))
- o.disp.image(o.image, o.rotation)
- if o.keyState[15] == 1:
- if o.sconf.as_int('bpm') < 240:
- o.sconf['bpm'] = o.sconf.as_int('bpm') + o.bpm_inc
- o.update_bpm()
- text_center(o, "Master BPM", str(o.sconf['bpm']))
- o.disp.image(o.image, o.rotation)
-
-
- class Example(State):
- def __init__(self,FSM):
- super(Example, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- super(Example, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- #self.FSM.ToTransition('toLand')
-
- def Exit(self):
- pass
-
- #====================================
-
- class Startup(State):
- def __init__(self,FSM):
- super(Startup, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- self.birth = time.perf_counter()
- super(Startup, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- print('startup state')
-
- if hasattr(self, 'birth'):
- pass
- else:
- self.birth = time.perf_counter()
-
- self.FSM.ToTransition('toIntro')
-
- def Exit(self):
- pass
-
- #====================================
-
- class Intro(State):
- def __init__(self,FSM):
- super(Intro, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- self.FSM.owner.draw.rectangle((0, 0, self.FSM.owner.width, self.FSM.owner.height), outline=0, fill=o.blue)
- super(Intro, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- o = self.FSM.owner
- self.FSM.ToTransition('toLoadDefault')
- self.FSM.owner.draw.rectangle((0, 0, self.FSM.owner.width, self.FSM.owner.height), outline=0, fill=o.blue)
- #self.FSM.owner.draw.text((0, 0), str(self.FSM.owner.playhead), font=self.FSM.owner.font, fill="#FFFFFF")
- self.FSM.owner.draw.text((0, 0), str(self.FSM.owner.playhead), font=self.FSM.owner.font, fill="#FF0000")
-
- def Exit(self):
- pass
-
- #====================================
-
- class LoadDefault(State):
- def __init__(self,FSM):
- super(LoadDefault, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
-
-
- o = self.FSM.owner
- o.load_song()
-
-
-
- self.bank = 0
- self.sounds = []
- self.globbed = glob.glob('/home/pi/skull/*.wav') + glob.glob('/home/pi/skull/*.mp3')
- self.globbed.sort()
- obj_id = 0
- # for f in self.globbed:
- # #self.sounds.append(pygame.mixer.Sound(f))
- # p1 = self.FSM.owner.SoundSlot(f, obj_id)
- # self.FSM.owner.soundSlots.append(p1)
- # obj_id += 1
-
- # self.sound_names = [os.path.basename(x) for x in self.globbed]
-
- for s in o.sconf['sounds']:
- #print('aaaaaayyy, ', s)
- p1 = self.FSM.owner.SoundSlot(s, obj_id, o)
- self.FSM.owner.soundSlots.append(p1)
- obj_id += 1
-
- #print(self.globbed)
- #print(self.FSM.owner.soundSlots)
- #pygame.mixer.Sound.play(self.FSM.owner.sounds[(self.FSM.owner.bank * 2)])
- #self.FSM.owner.soundSlots[2].play()
-
- #o.sconf.to_list(o.sconf['notes'])
- #lst = o.sconf.as_list('notes')
-
- _iter = 0
-
- lst = ast.literal_eval(o.sconf['notes'][0])
- print('length ', len(lst))
-
- for n in o.soundSlots:
- #print(lst[_iter])
- #print(n.notes)
- #print('---', len(n.notes[0]), _iter)
- m = []
- lst = ast.literal_eval(o.sconf.as_list('notes')[_iter])
- #n.notes = lst[_iter]
- n.notes = lst
- _iter += 1
-
- #print(self.FSM.owner.soundSlots[0].notes[0])
- # self.FSM.owner.soundSlots[0].notes[0] = [[1,16,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[1,16,0],[0,0,0],
- # [0,0,0],[0,0,0],[1,16,0],[0,0,0]]
- # self.FSM.owner.soundSlots[3].notes[0] = [[1,16,0],[0,0,0],[1,16,0],[1,16,0],
- # [1,16,0],[0,0,0],[1,16,0],[1,16,0],
- # [1,16,0],[1,16,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0]]
- # self.FSM.owner.soundSlots[2].notes[0] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0]]
-
- # self.FSM.owner.soundSlots[0].notes[1] = [[1,16,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[1,16,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0]]
- # self.FSM.owner.soundSlots[3].notes[1] = [[1,16,0],[0,0,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[1,16,0],[1,16,0],
- # [1,16,0],[0,0,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0]]
- # self.FSM.owner.soundSlots[2].notes[1] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0]]
-
- # self.FSM.owner.soundSlots[0].notes[2] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0]]
- # self.FSM.owner.soundSlots[3].notes[2] = [[1,16,0],[0,0,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[1,16,0],[1,16,0],
- # [1,16,0],[0,0,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[1,16,0],[0,0,0]]
- # self.FSM.owner.soundSlots[2].notes[2] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0]]
-
- # self.FSM.owner.soundSlots[0].notes[3] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [1,16,0],[0,0,0],[0,0,0],[0,0,0],
- # [1,16,0],[0,0,0],[1,16,0],[0,0,0]]
- # self.FSM.owner.soundSlots[3].notes[3] = [[1,16,0],[0,0,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[1,16,0],[1,16,0],
- # [1,16,0],[0,0,0],[1,16,0],[0,0,0],
- # [1,16,0],[0,0,0],[1,16,0],[0,0,0]]
- # self.FSM.owner.soundSlots[2].notes[3] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0],
- # [0,0,0],[0,0,0],[0,0,0],[0,0,0]]
-
- #for n in self.FSM.owner.soundSlots[0].notes:
- #print('sound ', self.id, ' ', n)
-
- super(LoadDefault, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- #self.FSM.owner.save_song()
- self.FSM.ToTransition('toMain')
- #self.FSM.ToTransition('toMain')
-
- def Exit(self):
- pass
-
- #====================================
-
- #====================================
-
- class Main(State):
- def __init__(self,FSM):
- super(Main, self).__init__(FSM)
-
- def Enter(self):
- print('hello main')
- self.FSM.owner.pub.register("beat", self)
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Main"
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Vol", str(o.sconf['volume']))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- #text_box3(o, "BPM", "90.0")
- o.disp.image(o.image, o.rotation)
-
- #o.start_playback()
-
- #should be pattner len 16
- print('this sound ', o.soundSlots[0].notes[0])
- o.soundSlots[2].volume = 2
- super(Main, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- # if o.keyState[16] > 0:
- # print('okey ', o.keyState[16])
-
- menu1_actions(self, o)
-
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Vol", str(o.volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- #text_box3(o, "BPM", "90.0")
- o.disp.image(o.image, o.rotation)
-
-
- if o.keyState[17] == 1:
- draw_menu2(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[17] == 4:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Vol", str(o.volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- #text_box3(o, "BPM", "90.0")
- o.disp.image(o.image, o.rotation)
-
-
-
- # if o.keyState[17] == 1:
- # o.draw.rectangle((20, 100, 40, 120), outline=0, fill=o.color_b)
- # o.disp.image(o.image, o.rotation)
- # elif o.keyState[17] == 4:
- # o.draw.rectangle((20, 100, 40, 120), outline=0, fill=o.dark_grey)
- # o.disp.image(o.image, o.rotation)
-
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- if k == 1:
- #_id2
- #o.eSound = _id
-
- #o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- #o.draw.text((0, 0), "SelSou", font=o.h1, fill=o.color_a)
- #o.draw.text((20, 60), str(o.eSound), font=o.h2, fill=o.color_b)
- note = _id + o.note_bank * 16
- if len(o.soundSlots) > note:
-
- self.FSM.owner.soundSlots[note].play(o.note_vol)
- o.eSound = note
- print('now editing sound ', o.eSound)
- #draw_header(o)
- #self.draw_square()
- text_box1(o, "Vol", str(o.volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- self.draw_square()
- o.disp.image(o.image, o.rotation)
- _id += 1
-
-
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- # for s in o.soundSlots:
- # print('--', s.notes[message[0]][message[1]])
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
-
- _id = 0
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
-
-
- def draw_square(self):
- o = self.FSM.owner
- size = 22
- og_x = (o.width / 2) - (size * 2)
- o_x = og_x
- o_y = 127
- _id = o.note_bank * 16
- #o.draw.rectangle((o_x + 4, o_y + 4, o_x + (size *4) + 4 , (o_y - (size * 4) + 4)), outline="#000000", fill="#000000", width=1)
- #for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- while _id < ((o.note_bank * 16) + 16):
- #print('n is ' ,n)
- if _id == o.eSound:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y -= size
- o_x = og_x
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
- #====================================
-
- class PadPlayer(State):
- def __init__(self,FSM):
- super(PadPlayer, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- print('entering pad player')
- super(PadPlayer, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
-
-
- _id = 0
- for k in self.FSM.owner.keyState:
- if _id < 16 and k == 1:
- self.FSM.owner.soundSlots[_id].play()
- _id += 1
- if self.FSM.owner.keys:
-
- print("Pressed: ", self.FSM.owner.keys)
- #self.FSM.ToTransition('toLand')
-
- def Exit(self):
- pass
-
- #====================================
-
- class SeqPlayer(State):
- def __init__(self,FSM):
- super(SeqPlayer, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- self.beat = 0
- self.FSM.owner.pub.register("beat", self)
- print('entering seq player')
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((20, 0), 'SeqPlayer', font=o.h1, fill="#FFFFFF")
- o.disp.image(o.image, o.rotation)
- super(SeqPlayer, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- o = self.FSM.owner
- # if o.playhead != self.beat:
- # #print('beat')
- # o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
- # o.draw.text((0, 0), str(o.playhead), font=o.font, fill="#FFFFFF")
- # #if (o.playhead % 8) == 0:
- # o.disp.image(o.image, o.rotation)
-
-
- # _id = 0
- # for s in o.soundSlots:
- # #if s.pattern[o.playhead] == 1:
- # if s.notes[o.curPattern][o.playhead] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
- if o.keyState[12] == 1:
- o.start_playback()
- if o.keyState[13] == 1:
- o.stop_playback()
- #self.beat = o.playhead
- #print('key0 ', o.keyState[16])
- if o.keyState[16] == 2:
- #print('key0 ', o.keyState[16])
- if o.keyState[0] == 1:
- print('to main')
- self.FSM.ToTransition('toMain')
-
- def ReceiveMessage(self, message):
- #print(self.name, 'got message', message)
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((20, 0), str(message[0]) + ' - ' + str(message[1]), font=o.h1, fill="#FFFFFF")
- o.disp.image(o.image, o.rotation)
- play_seq(o, message)
- # _id = 0
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
- #====================================
-
- class SelectSound(State):
- def __init__(self,FSM):
- super(SelectSound, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "SelSou"
- o.pub.register("beat", self)
- #o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
- #o.draw.text((0, 0), "SelSou", font=o.h1, fill="#FFFFFF")
- draw_header(o)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
- super(SelectSound, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- if o.keyState[16] == 2:
- if o.keyState[0] == 1:
- self.FSM.ToTransition('toMain')
- else:
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if k == 1:
- o.eSound = _id
-
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((0, 0), "SelSou", font=o.h1, fill=o.color_a)
- o.draw.text((20, 60), str(o.eSound), font=o.h2, fill=o.color_b)
-
- self.draw_square()
- o.disp.image(o.image, o.rotation)
- self.FSM.owner.soundSlots[_id].play()
-
- print('now editing sound ', _id)
-
-
-
-
- _id += 1
- #self.FSM.ToTransition('toLand')
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
- o.draw.text((0, 0), "SelSou", font=o.h1, fill="#FFFFFF")
- #o.disp.image(o.image, o.rotation)
-
- #o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
- o.draw.text((0, 20), str(o.eSound), font=o.h2, fill="#FFFFFF")
- o.disp.image(o.image, o.rotation)
- play_seq(o, message)
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
-
- def draw_square(self):
- o = self.FSM.owner
- size = 32
- og_x = 110
- o_x = og_x
- o_y = 0
- _id = 0
-
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- #print('n is ' ,n)
- if _id == o.eSound:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.color_b)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.dark_grey)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y += size
- o_x = og_x
-
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
- #====================================
-
- class SelectPattern(State):
- def __init__(self,FSM):
- super(SelectPattern, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Select Pattern"
- o.pub.register("beat", self)
-
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- super(SelectPattern, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- # if o.keyState[0] == 1:
- # self.FSM.ToTransition('toMain')
- else:
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if k == 1:
- o.ePattern = _id
-
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((0, 0), "SelPat", font=o.h1, fill=o.color_a)
- o.draw.text((20, 60), str(o.ePattern), font=o.h2, fill=o.color_b)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- print('now editing sound ', _id)
-
- _id += 1
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
-
- def draw_square(self):
- o = self.FSM.owner
- size = 22
- og_x = (o.width / 2) - (size * 2)
- o_x = og_x
- o_y = 127
- _id = 0
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- if _id == o.ePattern:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.olive, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y -= size
- o_x = og_x
-
- #////////////////////////////////////////////
-
- # for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- # #print('n is ' ,n)
- # if _id == o.ePattern:
- # o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.color_b)
- # else:
- # o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.dark_grey)
- # o_x = o_x + size
- # _id += 1
- # if _id % 4 == 0:
- # o_y += size
- # o_x = og_x
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class EditSoundSequence(State):
- def __init__(self,FSM):
- super(EditSoundSequence, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Note Edit"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
- super(EditSoundSequence, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- if o.keyState[16] == 2:
- pass
-
- else:
- _id = 0
- for k in self.FSM.owner.keyState:
- if _id < 16 and k == 1:
- if o.soundSlots[o.eSound].notes[o.ePattern][_id][0] == 1:
- print('turn note off')
- o.soundSlots[o.eSound].notes[o.ePattern][_id][0] = 0
- else:
- print('turn note on')
- o.soundSlots[o.eSound].notes[o.ePattern][_id][0] = 1
- #self.FSM.owner.soundSlots[_id].play()
-
- _id += 1
-
-
- def draw_square(self):
- o = self.FSM.owner
- size = 22
- og_x = (o.width / 2) - (size * 2)
- o_x = og_x
- o_y = 127
- _id = 0
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- if _id == o.playhead:
- if o.curPattern == o.ePattern:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.olive, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.pink, width=1)
- elif n[0] == 1:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y -= size
- o_x = og_x
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
-
- o.disp.image(o.image, o.rotation)
-
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class EditSong(State):
- def __init__(self,FSM):
- super(EditSong, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Edit Song"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
- o.draw.text((20, 50), str(o.song), font=o.h2, fill=o.light_grey)
- o.disp.image(o.image, o.rotation)
- self.new_song = []
- super(EditSong, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
-
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- if self.new_song == []:
- o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
- o.draw.text((20, 50), str(o.song), font=o.h2, fill=o.light_grey)
- else:
- o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
- o.draw.text((20, 50), str(self.new_song), font=o.h2, fill=o.pink)
- #self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- if o.keyState[16] > 0:
- pass
- else:
- _id = 0
- for k in self.FSM.owner.keyState:
- if k == 1 and _id < 16:
- self.new_song.append(_id)
- #o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- draw_header(o)
- #o.draw.text((0, 0), "SonEdt", font=o.h1, fill=o.light_grey)
- o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
- o.draw.text((20, 50), str(self.new_song), font=o.h2, fill=o.pink)
- o.disp.image(o.image, o.rotation)
- _id += 1
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
-
- def Exit(self):
- o = self.FSM.owner
- self.FSM.owner.pub.unregister("beat", self)
- if self.new_song != []:
- o.song = self.new_song
- o.songCycle = cycle(self.new_song)
- self.curPattern = next(o.songCycle)
- o.songStart = o.curPattern
-
- #====================================
-
- class File(State):
- def __init__(self,FSM):
- super(File, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "File"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- o.disp.image(o.image, o.rotation)
- super(File, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- #self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- #self.draw_square()
-
- o.disp.image(o.image, o.rotation)
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- # _id += 1
-
- def Exit(self):
- pass
-
- class Util(State):
- def __init__(self,FSM):
- super(Util, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Utilities"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- o.disp.image(o.image, o.rotation)
- super(Util, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- elif o.keyState[16] == 4:
- draw_header(o)
- #self.draw_square()
- o.disp.image(o.image, o.rotation)
-
- #self.FSM.ToTransition('toLand')
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- #self.draw_square()
-
- o.disp.image(o.image, o.rotation)
- #play_seq(o, message)
- # for s in o.soundSlots:
- # if s.notes[message[0]][message[1]][0] == 1:
- # o.soundSlots[_id].play()
- #id += 1
- def Exit(self):
- pass
-
-
-
- class Ball(State):
- def __init__(self,FSM):
- super(Ball, self).__init__(FSM)
-
- def Enter(self):
- self.ball_size = 10
- self.ballx = self.ball_size
- self.bally = self.ball_size
-
- self.ball_speed = 15
- self.ball_x_dir = 1
- self.ball_y_dir = 1
-
- self.ball2x = self.ball_size + 180
- self.ball2y = self.ball_size + 70
-
- self.ball2_x_dir = -1
- self.ball2_y_dir = -1
-
- o = self.FSM.owner
- o.header_text = "Utilities"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- o.disp.image(o.image, o.rotation)
- super(Ball, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- else:
- now = datetime.now()
- current_time = time.strftime("%-I:%M %p")
- #current_time = now.strftime("%H:%M:%S")
- #print("Current Time =", current_time)
-
-
- if self.ballx > (o.width - self.ball_size) or self.ballx < (0 + self.ball_size):
- self.ball_x_dir *= -1
- if (self.bally > o.height - self.ball_size) or (self.bally < 0 + self.ball_size):
- self.ball_y_dir *= -1
-
- self.ballx += self.ball_speed * self.ball_x_dir
- self.bally += self.ball_speed * self.ball_y_dir
-
-
- if self.ball2x > (o.width - self.ball_size) or self.ball2x < (0 + self.ball_size):
- self.ball2_x_dir *= -1
- if (self.ball2y > o.height - self.ball_size) or (self.ball2y < 0 + self.ball_size):
- self.ball2_y_dir *= -1
-
- self.ball2x += self.ball_speed * self.ball2_x_dir
- self.ball2y += self.ball_speed * self.ball2_y_dir
-
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
-
- o.draw.ellipse((self.ballx - self.ball_size, self.bally - self.ball_size, self.ballx + self.ball_size, self.bally + self.ball_size), fill = o.light_grey, outline =o.light_grey)
- o.draw.ellipse((self.ball2x - self.ball_size, self.ball2y - self.ball_size, self.ball2x + self.ball_size, self.ball2y + self.ball_size), fill = o.light_grey, outline =o.light_grey)
- o.center_block(current_time, o.h3, [0,0,o.width,o.height], o.pink)
- o.disp.image(o.image, o.rotation)
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- pass
-
- #====================================
-
-
- class Clock(State):
- def __init__(self,FSM):
- super(Clock, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- current_time = time.strftime("%-I:%M:%S")
- #current_time = time.strftime("%-I:%M:%S %p")
-
- #self.ball_sizex, self.ball_sizey = o.h3.getsize(current_time)
- self.ball_sizex, self.ball_sizey = o.h3.getsize("18:88:88")
- self.ball_sizex /= 2
- self.ball_sizey /= 2
- self.ballx = o.width / 2
- self.bally = o.height / 2
-
- self.ball_speed = 1
- self.ball_x_dir = 1
- self.ball_y_dir = 1
-
- o.header_text = "Utilities"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- pass
- #draw_header(o)
- #o.disp.image(o.image, o.rotation)
- super(Clock, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.disp.image(o.image, o.rotation)
- else:
- #now = datetime.now()
- current_time = time.strftime("%-I:%M:%S")
- #current_time = time.strftime("%-I:%M:%S %p")
- #current_time = now.strftime("%H:%M:%S")
- #print("Current Time =", current_time)
- #self.ball_sizex, self.ball_sizey = o.h3.getsize(current_time)
- #self.ball_sizex /= 2
- #self.ball_sizey /= 2
-
- if self.ballx > (o.width - self.ball_sizex) or self.ballx < (0 + self.ball_sizex):
- self.ball_x_dir *= -1
- if (self.bally > o.height - self.ball_sizey) or (self.bally < 0 + self.ball_sizey):
- self.ball_y_dir *= -1
-
- self.ballx += self.ball_speed * self.ball_x_dir
- self.bally += self.ball_speed * self.ball_y_dir
-
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.black)
-
- #o.draw.ellipse((self.ballx - self.ball_sizex, self.bally - self.ball_sizey, self.ballx + self.ball_sizex, self.bally + self.ball_sizey), fill = o.light_grey, outline =o.light_grey)
-
- o.draw.text((self.ballx - self.ball_sizex, self.bally - self.ball_sizey), current_time, align='center', font=o.h3, fill=o.olive)
- #o.center_block(current_time, o.h3, [0,0,o.width,o.height], o.pink)
- o.disp.image(o.image, o.rotation)
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- pass
-
-
- #====================================
- #main
- #select pattern
- #pattern
- #song
|