def make_cat(cat_location, screensize, border): # Get the cat again! files = list() for x in os.listdir("pictures"): if x not in ("README", "CVS", ".svn"): files.append(x) image_location = files[random.randint(0, len(files) - 1)] cat_surface = pygame.image.load("pictures/" + image_location) cat = cat_surface.convert() cat.set_colorkey((255, 255, 255), pygame.RLEACCEL) rotation_speed = randomFromRangeExcludingZero(-2, 2) scale_speed = float(randomFromRangeExcludingZero(-1, 1)) position = list((random.randint(border, screensize[0] - border), random.randint(border, screensize[1] - border))) newCat = BasicSprite(image=cat) X = Graphline(newCat=newCat, rotator=loopingCounter(rotation_speed), translation=cartesianPingPong(position, screensize[0], screensize[1], border), scaler=bouncingFloat(scale_speed), imaging=continuousIdentity(cat), shutdown_fanout=Fanout([ "rotator", "translation", "scaler", "imaging", "self_shutdown" ]), linkages={ ("rotator", "outbox"): ("newCat", "rotator"), ("translation", "outbox"): ("newCat", "translation"), ("scaler", "outbox"): ("newCat", "scaler"), ("imaging", "outbox"): ("newCat", "imaging"), ("newCat", "signal"): ("shutdown_fanout", "inbox"), ("shutdown_fanout", "rotator"): ("rotator", "control"), ("shutdown_fanout", "translation"): ("translation", "control"), ("shutdown_fanout", "scaler"): ("scaler", "control"), ("shutdown_fanout", "imaging"): ("imaging", "control"), ("shutdown_fanout", "self_shutdown"): ("shutdown_fanout", "control"), }).activate() return newCat
def make_cat(cat_location, screensize, border): # Get the cat again! files = list() for x in os.listdir("pictures"): if x not in ("README", "CVS", ".svn"): files.append(x) image_location = files[random.randint(0, len(files) - 1)] cat_surface = pygame.image.load("pictures/" + image_location) cat = cat_surface.convert() cat.set_colorkey((255, 255, 255), pygame.RLEACCEL) rotation_speed = randomFromRangeExcludingZero(-2, 2) scale_speed = float(randomFromRangeExcludingZero(-1, 1)) position = list((random.randint(border, screensize[0] - border), random.randint(border, screensize[1] - border))) newCat = CatSprite(image=cat) newCat.activate() # to register it with the sprite scheduler, this is a hack. X = Graphline( newCat=newCat, rotator=loopingCounter(rotation_speed), translation=cartesianPingPong(position, screensize[0], screensize[1], border), scaler=bouncingFloat(scale_speed), imaging=continuousIdentity(cat), shutdown_fanout=Fanout(["rotator", "translation", "scaler", "imaging", "self_shutdown"]), linkages={ ("self", "inbox"): ("newCat", "inbox"), ("rotator", "outbox"): ("newCat", "rotator"), ("translation", "outbox"): ("newCat", "translation"), ("scaler", "outbox"): ("newCat", "scaler"), ("imaging", "outbox"): ("newCat", "imaging"), ("newCat", "signal"): ("shutdown_fanout", "inbox"), ("shutdown_fanout", "rotator"): ("rotator", "control"), ("shutdown_fanout", "translation"): ("translation", "control"), ("shutdown_fanout", "scaler"): ("scaler", "control"), ("shutdown_fanout", "imaging"): ("imaging", "control"), ("shutdown_fanout", "self_shutdown"): ("shutdown_fanout", "control"), }, ) return X
# # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this notice. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------------- from Kamaelia.Automata.Behaviours import bouncingFloat from Kamaelia.Chassis.Graphline import Graphline from Kamaelia.UI.OpenGL.ProgressBar import ProgressBar Graphline(BOUNCE=bouncingFloat(0.5), PROGRESS=ProgressBar(size=(3, 0.5, 0.2), position=(0, 0, -10), progress=0.5), linkages={ ("BOUNCE", "outbox"): ("PROGRESS", "progress"), }).run() # Licensed to the BBC under a Contributor Agreement: THF
# # (1) Kamaelia Contributors are listed in the AUTHORS file and at # http://www.kamaelia.org/AUTHORS - please extend this file, # not this notice. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------------- from Kamaelia.Automata.Behaviours import bouncingFloat from Kamaelia.Chassis.Graphline import Graphline from Kamaelia.UI.OpenGL.ProgressBar import ProgressBar Graphline( BOUNCE = bouncingFloat(0.5), PROGRESS = ProgressBar(size = (3, 0.5, 0.2), position=(0,0,-10), progress=0.5), linkages = { ("BOUNCE", "outbox"):("PROGRESS", "progress"), } ).run() # Licensed to the BBC under a Contributor Agreement: THF
glDepthMask(GL_TRUE) glDisable(GL_BLEND) def frame(self): self.handleProgress() def handleProgress(self): while self.dataReady("progress"): self.progress = self.recv("progress") if self.progress < 0.0: self.progress = 0.0 if self.progress > 1.0: self.progress = 1.0 self.redraw() __kamaelia_components__ = (ProgressBar,) if __name__=='__main__': from Kamaelia.Automata.Behaviours import bouncingFloat from Kamaelia.Chassis.Graphline import Graphline Graphline( BOUNCE = bouncingFloat(0.5), PROGRESS = ProgressBar(size = (3, 0.5, 0.2), position=(0,0,-10), progress=0.5), linkages = { ("BOUNCE", "outbox"):("PROGRESS", "progress"), } ).run() # Licensed to the BBC under a Contributor Agreement: THF