diff options
author | Dan <dan@rcoh-ubuntu-small.(none)> | 2011-01-28 10:11:22 -0500 |
---|---|---|
committer | Dan <dan@rcoh-ubuntu-small.(none)> | 2011-01-28 10:11:22 -0500 |
commit | a028c880c8325419a238667e71a7e919b72a4798 (patch) | |
tree | 5a07f674fcead141165a5b4fec0143c3e6c60e05 /behaviors/MoveBehavior.py | |
parent | b8bb5e82a2e8802b9adb1258463d4198f974dbd1 (diff) | |
parent | 3319a58ecc391f9aac092ade45f9f50dc2af5aa6 (diff) |
Merge branch 'fridaydemo' of github.com:rcoh/SmootLight into osc
Diffstat (limited to 'behaviors/MoveBehavior.py')
-rw-r--r-- | behaviors/MoveBehavior.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/behaviors/MoveBehavior.py b/behaviors/MoveBehavior.py new file mode 100644 index 0000000..e504ca9 --- /dev/null +++ b/behaviors/MoveBehavior.py @@ -0,0 +1,34 @@ +from operationscore.Behavior import * +#import util.ComponentRegistry as compReg +#import util.Geo as Geo +#import util.Strings as Strings + +class MoveBehavior(Behavior): + """Moves current location by the x and y components of sensorInput. Uses recurrences to track + current input. @Author: Euguene""" + + def processResponse(self, sensorInputs, recursiveInputs): + if recursiveInputs: + currRecLocs = recursiveInputs + else: + currRecLocs = [{'Location' : (5, 5), 'Color' : [255, 255, 255]}] + + if sensorInputs: # if input exists, change location + ret = [] + for currRecLoc in currRecLocs: + currDict = dict(currRecLoc) + for sensorInput in sensorInputs: + if 'type' in sensorInput and sensorInput['type'] == 1: + currDict['Location'] = (currDict['Location'][0] - sensorInput['x'] * self['XStep'], \ + currDict['Location'][1] + sensorInput['y'] * self['YStep']) + currDict['Color'] = [sensorInput['r'], sensorInput['g'], sensorInput['b']] + #elif sensorInput['type'] == 2: + # currDict['Shake'] = 1 + # currDict['Force'] = sensorInput['force'] + ret.append(currDict) + #print ret + return (ret, ret) + + else: # if not, return current recursive location. + #print currRecLocs + return (currRecLocs, currRecLocs) |