Ejemplo n.º 1
0
from Axon.likefile import LikeFile, schedulerThread
import time, Axon
from Sprites.BasicSprite import BasicSprite
from Sprites.SpriteScheduler import SpriteScheduler
from Simplegame import *


class catMaker(Axon.Component.component):
    """discards input, makes one cat per item on inbox."""
    def main(self):
        self.spritescheduler = SpriteScheduler(cat_args, cat_sprites, background, screen_surface, MyGamesEvents).activate()
        yield 1 # to make sure spritescheduler's main gets called once - there's code outside the loop there that needs to run.
        while True:
            while self.dataReady("inbox"):
                discardedfornow = self.recv("inbox")
                cat_appear_wav.play()
                self.spritescheduler.allsprites.add(make_cat(*self.spritescheduler.cat_args))
            self.pause()
            yield 1

bg = schedulerThread(slowmo=0.01).start()
catmaker = LikeFile(catMaker())
catmaker.activate()

max_cats = 10
for i in xrange(0, max_cats):
    time.sleep(0.5)
    catmaker.put(i)
print "cats over!"
time.sleep(5)
Ejemplo n.º 2
0
catlist = []
while True:
    input = raw_input(">>> ").lower()
    try:
        command, args = input.split(" ", 1)
    except ValueError:
        command, args = input, ""

    if command == "status":
        print "there are %s threads active and %s components" % (
            threading.activeCount(),
            len(Axon.Scheduler.scheduler.run.threads),
        )
    elif command == "add":
        count = 1
        if args and int(args) > 1:
            count = int(args)
        for i in xrange(0, count):
            newcat = LikeFile(make_cat(*cat_args))
            newcat.activate()
            catlist.append(newcat)
        print "added %s cats." % count
    elif command == "pause":
        for cat in catlist:
            cat.put("pause", "inbox")
        print "paused %s cats" % len(catlist)
    elif command == "toggle":
        for cat in catlist:
            cat.put("toggle", "inbox")
        print "toggled %s cats" % len(catlist)
Ejemplo n.º 3
0
from Sprites.SpriteScheduler import SpriteScheduler
from Simplegame import *


class catMaker(Axon.Component.component):
    """discards input, makes one cat per item on inbox."""
    def main(self):
        self.spritescheduler = SpriteScheduler(cat_args, cat_sprites,
                                               background, screen_surface,
                                               MyGamesEvents).activate()
        yield 1  # to make sure spritescheduler's main gets called once - there's code outside the loop there that needs to run.
        while True:
            while self.dataReady("inbox"):
                discardedfornow = self.recv("inbox")
                cat_appear_wav.play()
                self.spritescheduler.allsprites.add(
                    make_cat(*self.spritescheduler.cat_args))
            self.pause()
            yield 1


bg = schedulerThread(slowmo=0.01).start()
catmaker = LikeFile(catMaker())
catmaker.activate()

max_cats = 10
for i in xrange(0, max_cats):
    time.sleep(0.5)
    catmaker.put(i)
print "cats over!"
time.sleep(5)
Ejemplo n.º 4
0
       }
    )
    return X

cat_args = (cat_location, screensize, border)
spritescheduler = SpriteScheduler(cat_args, [], background, screen_surface, MyGamesEvents).activate()

catlist = []
while True:
    input = raw_input(">>> ").lower()
    try: command, args = input.split(' ', 1)
    except ValueError: command, args = input, ''

    if command == "status":
        print "there are %s threads active and %s components" % (threading.activeCount(), len(Axon.Scheduler.scheduler.run.threads))
    elif command == "add":
        count = 1
        if args and int(args) > 1: count = int(args)
        for i in xrange(0, count):
            newcat = LikeFile(make_cat(*cat_args))
            newcat.activate()
            catlist.append(newcat)
        print "added %s cats." % count
    elif command == "pause":
        for cat in catlist:
            cat.put("pause", "inbox")
        print "paused %s cats" % len(catlist)
    elif command == "toggle":
       for cat in catlist:
           cat.put("toggle", "inbox")
       print "toggled %s cats" % len(catlist)
Ejemplo n.º 5
0
# 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 Axon.likefile import LikeFile, schedulerThread
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Internet.TCPClient import TCPClient
import ao
schedulerThread(slowmo=0.001).start()

filename = "./snail.ogg"

playStream = LikeFile(Pipeline(VorbisDecode(), AOAudioPlaybackAdaptor()))
playStream.activate()
# set of components for playing the stream back.

host = "bbc.kamaelia.org"
port = 1500

client = LikeFile(TCPClient(host = host, port = port))
# component to grab a stream from the internet

filedump = open("streamdump.ogg", "w+b")

# Play the ogg data in the background
while True:
    data = client.get()
    filedump.write(data)
    # log the stream to disk