Commit d5bb76ce authored by Dave Pena PhD's avatar Dave Pena PhD

initial commit

parents
This diff is collapsed.
#!/usr/bin/env python
from decorator import decorator
import time
from array import array
import pygame as pg
from pygame.mixer import Sound, get_init
import pygame.gfxdraw as gfx
@decorator
def on_start(func,*args, **kwargs):
if kwargs !={}:
try:
if kwargs['Start']:
if 'Verbose' in kwargs['Settings']:
if kwargs['Settings']['Verbose']:
print(func)
pass
response= func(*args,**kwargs)
return response
else:
kwargs['Start'] = False
print(func,"DID NOT START")
return(kwargs)
except Exception as e:
print('NODE ERROR OCCURED TRYING TO START NODE FUNCTION:')
print('===========================================')
print(func,e)
print('===========================================')
print('LAST STATE SET TO:')
print('===========================================')
print('ekwargs')
print('===========================================')
print('LAST NODE FUNCTION SET TO:')
print('===========================================')
print('efunc')
print('===========================================')
global ekwargs
global efunc
ekwargs = kwargs
efunc = func
print('HALTING')
raise
else:
print('Empty kwargs')
return ()
def start():
return {'Start':True,'Settings':{'Verbose':False},'Status':{},'Threads':[]}
@on_start
def stremePyGame_node_36(*args, **kwargs):
pg.mixer.pre_init(44100, -16, 1)
pg.init()
pluriPalette = {
"pluri":(135,138,238),
"pluriDark":(89,45,84),
"pop1":(252,22,139),
"alert":(222,83,96),
"muted":(212,212,212),
"pop2":(85,216,203),
"white":(255,255,255),
"black":(0,0,0)
}
screen = pg.display.set_mode([800,800])
screen.fill(pluriPalette['pluri'])
pg.display.set_caption("Experiment")
font = pg.font.Font(pg.font.match_font('lato'), 72)
text = font.render('SomeText', True, pluriPalette['white'])
kwargs['Data'] = True # nodes will see anything placed in kwargs
########### Keeps an error from occuring when nodes are not connected #######
event1 = ""
event2 = ""
event3 = ""
event4 = ""
##############################################################################
while kwargs['Data']:
screen.blit(text, (10,10))
###################### BACK PIN EVENTS #######################################
kwargs = keydown_node_47(**kwargs)
###############################################################################
{event2}
{event3}
{event4}
if kwargs['Data']:
for i in pg.event.get():
if i.type == pg.QUIT:
kwargs['Data'] = False
pg.quit()
pg.display.flip()
return kwargs
class Note(Sound):
def __init__(self, frequency, volume=.1):
self.frequency = frequency
Sound.__init__(self, self.build_samples())
self.set_volume(volume)
def build_samples(self):
period = int(round(get_init()[0] / self.frequency))
samples = array("h", [0] * period)
amplitude = 2 ** (abs(get_init()[1]) - 1) - 1
for time in range(period):
if time < period / 2:
samples[time] = amplitude
else:
samples[time] = -amplitude
return samples
@on_start
def keydown_node_47(*args,**kwargs):
pressed = pg.key.get_pressed()
if pressed[pg.K_w]:
print("w is pressed")
if pressed[pg.K_s]:
print("s is pressed")
if pressed[pg.K_ESCAPE]:
kwargs['Data'] = False
if pressed[pg.K_SPACE]:
print("Spacebar Pressed")
Note(440).play(100)
return kwargs
class StremeNode:
def __init__(self):
pass
def run(self,*args,**kwargs):
self.kwargs=stremePyGame_node_36(**kwargs)
return (self.kwargs)
class liveprocess:
def __init__(self):
pass
def run(self,expname="Local"):
self.response=stremePyGame_node_36(**start())
return(self.response)
if __name__ == '__main__':
process = liveprocess()
process.run()
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment