aboutsummaryrefslogtreecommitdiff
path: root/behaviors/RunningBehavior.py
blob: 4f51898f9758c9c004cc3d72dcbd0c0cf64c3b58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from operationscore.Behavior import *
import util.ComponentRegistry as compReg
import pdb
import Util
class RunningBehavior(Behavior):
    def processResponse(self, sensorInputs, recursiveInputs):
        newResponses = sensorInputs 
        ret = []
        ret += newResponses
        for recurInput in recursiveInputs:
            outDict = dict(recurInput)
            if not 'Dir' in outDict:
                outDict['Dir'] = 1 #to the right
            if not 'StepSize' in outDict:
                outDict['StepSize'] = self['StepSize']
            outDict['Location']= Util.addLocations(outDict['Location'],
            (outDict['StepSize']*outDict['Dir'],0))
            if not Util.pointWithinBoundingBox(outDict['Location'], \
                compReg.getComponent('Screen').getSize()):
                    outDict['Dir'] *= -1
            ret.append(outDict)
        ret += newResponses
        return (ret, ret)