[pygame] Getting input from command line
I know this isn't directly related to PyGame but I figured there were worse places to ask a question like this. Does anybody know the best way to get input from the command line? Specifically space and escape. I have my program doing things in a thread and constantly reporting information. I'd like the main thread to be able to pause and unpause the other thread on space and to quit program cleanly with escape. I tried using Curses, but it didn't work out too well. I got the input great, but I came across problems when adding strings that went off screen (lol). Rather than try to fix this I finally decided that I didn't want to use Curses since it can't run on Windows. Am I getting into the realm of GUI software here simply by wanting input from space and escape? I just wanted something I could start in a terminal and forget about really. Does anyone have any ideas? Thanks, Fiona
Re: [pygame] Getting input from command line
Does anybody know the best way to get input from the command line? Specifically space and escape. I have my program doing things in a thread and constantly reporting information. I'd like the main thread to be able to pause and unpause the other thread on space and to quit program cleanly with escape. I tried using Curses, but it didn't work out too well. I got the input great, but I came across problems when adding strings that went off screen (lol). Rather than try to fix this I finally decided that I didn't want to use Curses since it can't run on Windows. Am I getting into the realm of GUI software here simply by wanting input from space and escape? I just wanted something I could start in a terminal and forget about really. Does anyone have any ideas? Thanks, Fiona I think I must be missing something. Why don't you just use pygame keys? http://www.pygame.org/docs/ref/key.html -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
Re: [pygame] Getting input from command line
Knapp wrote: I think I must be missing something. Why don't you just use pygame keys? http://www.pygame.org/docs/ref/key.html I was under the impression that I had to create a window before PyGame would get keys, or is this not the case? I wanted my program to be purely in the terminal.
Re: [pygame] Crazy Machine type game?
On Sun, 30 Nov 2008 22:57:19 -0200, claudio canepa [EMAIL PROTECTED] wrote: On Fri, Nov 28, 2008 at 2:44 PM, Joe Strout [EMAIL PROTECTED] wrote: Hi all, I'm new to pygame, and only recently returned to Python after nearly a decade in the REALbasic world. So I hope you'll speak slowly and use small words. :) I've got the bug to create a game similar to the classic games Incredible Machine and Crazy Machine. For those not familiar, it amounts to giving the player a palette of pieces that they can arrange in a 2D grid to make Rube Goldberg-style machine that accomplishes some goal. Pieces include weights, balls, balloons, electrical components, fans, candles, rockets, ropes, pulles, gears, monkeys on bicycles, and so on. It's a little like the Flash game Fantastic Contraption [1], but with far more (and more fun) parts. As an open-source networked game, it could be especially fun, as anyone could contribute their own challenges, and we could keep stats online regarding how many people have attempted or solved each one. Is there already anything like this started in Python? (I searched the pygame archives, but didn't see anything.) If not, have you any advice on how to approach it in the Pygame world? I was thinking of trying PyODE for the physics simulation (hopefully that will run cleanly on all platforms, and not just Windows, as that is a firm constraint for me). For the graphics, all I need is basically 2D sprites that can move, rotate, and change their image -- from the Pygame examples I've seen, that should be no problem. But what do y'all think? Thanks, - Joe [1] http://fantasticcontraption.com/ There is an old clone like in pygame site, look at http://www.pygame.org/projects/21/139/ You might also want to look at Assembly Line: http://www.pygame.org/project/735/
Re: [pygame] Getting input from command line
Perhaps overkill, and not portable, but you could use the curses module. --Mike Fiona Burrows wrote: I know this isn't directly related to PyGame but I figured there were worse places to ask a question like this. Does anybody know the best way to get input from the command line? Specifically space and escape. I have my program doing things in a thread and constantly reporting information. I'd like the main thread to be able to pause and unpause the other thread on space and to quit program cleanly with escape. I tried using Curses, but it didn't work out too well. I got the input great, but I came across problems when adding strings that went off screen (lol). Rather than try to fix this I finally decided that I didn't want to use Curses since it can't run on Windows. Am I getting into the realm of GUI software here simply by wanting input from space and escape? I just wanted something I could start in a terminal and forget about really. Does anyone have any ideas? Thanks, Fiona
Re: [pygame] Getting input from command line
Michael George wrote: Perhaps overkill, and not portable, but you could use the curses module. --Mike Fiona Burrows wrote: I tried using Curses, but it didn't work out too well. I got the input great, but I came across problems when adding strings that went off screen (lol). Rather than try to fix this I finally decided that I didn't want to use Curses since it can't run on Windows. Note to self: read whole message before replying :) --Mike
Re: [pygame] Crazy Machine type game?
On Dec 1, 2008, at 7:33 AM, Kris Schnee wrote: On Sun, 30 Nov 2008 22:57:19 -0200, claudio canepa [EMAIL PROTECTED] wrote: There is an old clone like in pygame site, look at http://www.pygame.org/projects/21/139/ You might also want to look at Assembly Line: http://www.pygame.org/project/735/ Boy, somebody ought to add the simulation tag to those games -- I utterly failed to find them when searching for such things last week! Thanks, - Joe
[pygame] Pygame-Fenix - Using generators as game objects
Hi all, years ago I used to use a tool to make games called DIV Games Studio, when it eventually died I started using it's successor called Fenix. The language that you used to make games was/is an odd mix of C and Pascal. However they had a novel way of creating and handling game objects. Basically everything in the game is a Process, processes are basically objects that run from start to finish, have screen coordinaties, z-depth, a size, an angle, and a graphic among other things. You could define a process like this: process guy(x, y) begin graph = load_png(test.png); loop frame; end end end Everytime your program calls a guy, like you would a function, a new object is created in world independent of everything else. The code for the guy starts at begin, and then gets destroyed when it hits the end. loop creates an infinite loop. The interesting part of how it all works is the frame; statement. When it hits frame, it jumps out of the loop and stops executing till the next frame. There's also routines for distance checking and collision detection between objects. In addition to the aformentioned settings that each process can have it was all very easy to do simple to moderately complex games. Basically DIV/Fenix made me retarded when it came to making games. In other languages it just seemed I had to do so much to achieve what Fenix gave me for free. When I started writing Python I found I loved it, and hated Fenix's syntax and it's constant bugs. So I decided to emulate Fenix in Python/Pygame. The result (thus far) is fenix-pygame: http://code.google.com/p/pygame-fenix/ I found that I can emulate the way the frame; statement works completely by using generators instead. The example code on the front page shows a program that displays an object which has a graphic assigned to it and moves around the screen with the arrow keys. When the code hits yield it jumps out of the function till the next frame. There are a few other simple examples showing process interaction in the repo. I'm not sure if anyone else has used generators for game objects, but it's always seemed so natural to me and I certainly can't stop thinking in processes when I write games. The library is certainly not perfect, there's next to no optimisation done especially in display routines so don't expect anything fast. But the concept is there. I'm going to continue improving it for my own endeavours and will be using it for Ludum Dare this weekend. Hope someone finds it interesting or useful. Thanks, Fiona -- *Sputnik Internet **¤ * Web Graphic Design, Marketing Illustration 30 King Street Manchester M2 6AZ Tel 0870 742 5959 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: http://www.sputnikinternet.com http://www.sputnikinternet.com/ **
[pygame] Python pygame in the web
Is it any way to put python and pygame in a web? I mean to create a game and put it on the web like flash games. Oscar
Re: [pygame] Pygame-Fenix - Using generators as game objects
This is something I've thought of as well, but slightly differently. It started with me working on a game framework where your guy would have an __init__ for loading the images, and a FrameAction that gets called by the game loop. The game loop of the framework would handle all of the callbacks. The purpose of the framework, largely, is to simplify things for people that want to be game scriptors but aren't comfortable enough with programming to make a whole game. So it occurred to me, one way to possibly make it easier is to use generators. One arrangement would be the loop that you described, but not necessarily have just one loop. A simple example is when a non-player object would have a looped sequence of events, each taking a certain amount of frames. The old way of doing it would be: def begin(self): state = 0 statecounter = 0 while True: if state == 0: #state 0 stuff if statecounter == 5: state = 1 statecounter = -1 elif state == 1: #state 1 stuff if statecounter == 3: state = 2 statecounter = -1 elif state == 2: #state 2 stuff if statecounter == 7: state = 0 statecounter = -1 statecounter += 1 yield The way I would do it is this: def begin(self): while True: for x in range(0,5): #state 0 stuff yield for x in range(0,3): #state 1 stuff yield for x in range(0,7): #state 2 stuff yield You could also have conditionals that take input that direct it in different control paths. The point here being, instead of worrying about using state variables, you could use your location in the loop as your state. It can make you think of it a lot more as one script, instead of having to think about it in terms of frames and states. Just thought I'd share that; it doesn't look like it would require any changes to Pygame-Fenix, just a new way of using it. Dan On Mon, Dec 1, 2008 at 9:54 AM, Fiona Burrows [EMAIL PROTECTED] wrote: Hi all, years ago I used to use a tool to make games called DIV Games Studio, when it eventually died I started using it's successor called Fenix. The language that you used to make games was/is an odd mix of C and Pascal. However they had a novel way of creating and handling game objects. Basically everything in the game is a Process, processes are basically objects that run from start to finish, have screen coordinaties, z-depth, a size, an angle, and a graphic among other things. You could define a process like this: process guy(x, y) begin graph = load_png(test.png); loop frame; end end end Everytime your program calls a guy, like you would a function, a new object is created in world independent of everything else. The code for the guy starts at begin, and then gets destroyed when it hits the end. loop creates an infinite loop. The interesting part of how it all works is the frame; statement. When it hits frame, it jumps out of the loop and stops executing till the next frame. There's also routines for distance checking and collision detection between objects. In addition to the aformentioned settings that each process can have it was all very easy to do simple to moderately complex games. Basically DIV/Fenix made me retarded when it came to making games. In other languages it just seemed I had to do so much to achieve what Fenix gave me for free. When I started writing Python I found I loved it, and hated Fenix's syntax and it's constant bugs. So I decided to emulate Fenix in Python/Pygame. The result (thus far) is fenix-pygame: http://code.google.com/p/pygame-fenix/ I found that I can emulate the way the frame; statement works completely by using generators instead. The example code on the front page shows a program that displays an object which has a graphic assigned to it and moves around the screen with the arrow keys. When the code hits yield it jumps out of the function till the next frame. There are a few other simple examples showing process interaction in the repo. I'm not sure if anyone else has used generators for game objects, but it's always seemed so natural to me and I certainly can't stop thinking in processes when I write games. The library is certainly not perfect, there's next to no optimisation done especially in display routines so don't expect anything fast. But the concept is there. I'm going to continue improving it for my own endeavours and will be using it for Ludum Dare this weekend. Hope someone finds it interesting or useful. Thanks, Fiona -- Sputnik Internet ¤ Web Graphic Design, Marketing Illustration 30 King Street Manchester M2 6AZ Tel 0870 742 5959 E-mail: [EMAIL PROTECTED] Web: http://www.sputnikinternet.com
Re: [pygame] Pygame-Fenix - Using generators as game objects
If you want to look up information about this, the general term is actor-based programming. Existing libraries (neither of which ever seemed that great) include PARLEY and Dramatis. Stackless tasklets are also a very nice way to handle this. --Noah On Dec 1, 2008, at 7:54 AM, Fiona Burrows wrote: Hi all, years ago I used to use a tool to make games called DIV Games Studio, when it eventually died I started using it's successor called Fenix. The language that you used to make games was/is an odd mix of C and Pascal. However they had a novel way of creating and handling game objects. Basically everything in the game is a Process, processes are basically objects that run from start to finish, have screen coordinaties, z-depth, a size, an angle, and a graphic among other things. You could define a process like this: process guy(x, y) begin graph = load_png(test.png); loop frame; end end end Everytime your program calls a guy, like you would a function, a new object is created in world independent of everything else. The code for the guy starts at begin, and then gets destroyed when it hits the end. loop creates an infinite loop. The interesting part of how it all works is the frame; statement. When it hits frame, it jumps out of the loop and stops executing till the next frame. There's also routines for distance checking and collision detection between objects. In addition to the aformentioned settings that each process can have it was all very easy to do simple to moderately complex games. Basically DIV/Fenix made me retarded when it came to making games. In other languages it just seemed I had to do so much to achieve what Fenix gave me for free. When I started writing Python I found I loved it, and hated Fenix's syntax and it's constant bugs. So I decided to emulate Fenix in Python/Pygame. The result (thus far) is fenix-pygame: http://code.google.com/p/pygame-fenix/ I found that I can emulate the way the frame; statement works completely by using generators instead. The example code on the front page shows a program that displays an object which has a graphic assigned to it and moves around the screen with the arrow keys. When the code hits yield it jumps out of the function till the next frame. There are a few other simple examples showing process interaction in the repo. I'm not sure if anyone else has used generators for game objects, but it's always seemed so natural to me and I certainly can't stop thinking in processes when I write games. The library is certainly not perfect, there's next to no optimisation done especially in display routines so don't expect anything fast. But the concept is there. I'm going to continue improving it for my own endeavours and will be using it for Ludum Dare this weekend. Hope someone finds it interesting or useful. Thanks, Fiona -- Sputnik Internet ¤ Web Graphic Design, Marketing Illustration 30 King Street Manchester M2 6AZ Tel 0870 742 5959 E-mail: [EMAIL PROTECTED] Web: http://www.sputnikinternet.com
Re: [pygame] Python pygame in the web
Short answer: No Long answer: Check the ML archives, this is discussed frequently. --Noah On Dec 1, 2008, at 8:07 AM, OsKaR wrote: Is it any way to put python and pygame in a web? I mean to create a game and put it on the web like flash games. Oscar
Re: [pygame] Python pygame in the web
What about web.py or Django? Make this tools possible to embeed a game in a web? 2008/12/1 Noah Kantrowitz [EMAIL PROTECTED] Short answer: No Long answer: Check the ML archives, this is discussed frequently. --Noah On Dec 1, 2008, at 8:07 AM, OsKaR wrote: Is it any way to put python and pygame in a web? I mean to create a game and put it on the web like flash games. Oscar
Re: [pygame] Python pygame in the web
I don't think you read my answer. Did you read my answer? --Noah On Dec 1, 2008, at 8:51 AM, OsKaR wrote: What about web.py or Django? Make this tools possible to embeed a game in a web? 2008/12/1 Noah Kantrowitz [EMAIL PROTECTED] Short answer: No Long answer: Check the ML archives, this is discussed frequently. --Noah On Dec 1, 2008, at 8:07 AM, OsKaR wrote: Is it any way to put python and pygame in a web? I mean to create a game and put it on the web like flash games. Oscar
Re: [pygame] Pygame-Fenix - Using generators as game objects
Noah Kantrowitz wrote: If you want to look up information about this, the general term is actor-based programming. Existing libraries (neither of which ever seemed that great) include PARLEY and Dramatis. Stackless tasklets are also a very nice way to handle this. Thank you! I knew there would be a term for it. :) Those libraries seem interesting - especially Dramatis. But neither of them seem as well suited for games as mine as I have lots of game-specific things like collision detection going on. -- *Sputnik Internet **¤ * Web Graphic Design, Marketing Illustration 30 King Street Manchester M2 6AZ Tel 0870 742 5959 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: http://www.sputnikinternet.com http://www.sputnikinternet.com/ **
Re: [pygame] Pygame-Fenix - Using generators as game objects
On Mon, Dec 1, 2008 at 6:05 PM, Fiona Burrows [EMAIL PROTECTED] wrote: Noah Kantrowitz wrote: If you want to look up information about this, the general term is actor-based programming. Existing libraries (neither of which ever seemed that great) include PARLEY and Dramatis. Stackless tasklets are also a very nice way to handle this. Panda3d is a lot like this also. This sample code is from their intro in the manual. They have 2 systems that work together. One is event driven and the other is task driven (tasks get called after each screen refresh or so). You then just make little defs that say what to do at each event or task slice and add them to the caller. Collisions can be set to trigger events or you can use a task to check the event que each turn. This code loads a 3d landscape and a panda bear actor and then makes the panda walk from side to side and turn around. Then the camera spins round and round also. import direct.directbase.DirectStart from pandac.PandaModules import * from direct.task import Task from direct.actor import Actor from direct.interval.IntervalGlobal import * import math #Load the first environment model environ = loader.loadModel(models/environment) environ.reparentTo(render) environ.setScale(0.25,0.25,0.25) environ.setPos(-8,42,0) #Task to move the camera def SpinCameraTask(task): angledegrees = task.time * 6.0 angleradians = angledegrees * (math.pi / 180.0) base.camera.setPos(20*math.sin(angleradians),-20.0*math.cos(angleradians),3) base.camera.setHpr(angledegrees, 0, 0) return Task.cont taskMgr.add(SpinCameraTask, SpinCameraTask) #Load the panda actor, and loop its animation pandaActor = Actor.Actor(models/panda-model,{walk:models/panda-walk4}) pandaActor.setScale(0.005,0.005,0.005) pandaActor.reparentTo(render) pandaActor.loop(walk) #Create the four lerp intervals needed to walk back and forth pandaPosInterval1= pandaActor.posInterval(13,Point3(0,-10,0), startPos=Point3(0,10,0)) pandaPosInterval2= pandaActor.posInterval(13,Point3(0,10,0), startPos=Point3(0,-10,0)) pandaHprInterval1= pandaActor.hprInterval(3,Point3(180,0,0), startHpr=Point3(0,0,0)) pandaHprInterval2= pandaActor.hprInterval(3,Point3(0,0,0), startHpr=Point3(180,0,0)) #Create and play the sequence that coordinates the intervals pandaPace = Sequence(pandaPosInterval1, pandaHprInterval1, pandaPosInterval2, pandaHprInterval2, name = pandaPace) pandaPace.loop() run() -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
Re: [pygame] [dev] making fastevents the default event module
fastevent calls SDL locking functions for thread safetly. I don't know how this is superior to CPython's Global Interpreter Lock (GIL) which automatically provides thread locking for extension module functions. The only difference I can see is that fastevent.post() can wait when the message queue is full, as it releases the GIL, while event.post() raises an exception. Lenard Chris Smith wrote: I'm not worried about events currently being 'slow'. But I would like to know what the extra overhead would be. If it's otherwise backwards compatible, I see no problem. Chris 2008/12/1 Lenard Lindstrom [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Hi René, I don't know enough about fastevent to make a suggestion. It is undocumented. I do see that fastevent has more overhead than event though. Lenard René Dudfield wrote: hi, I think we should change fastevents to be the default event module... making the other event module 'oldevent'. This is because fastevent is just nicer when using threads :) - event (will be the fastevents module) - fastevents (will be an alias to the new event module, which is the fastevents module) - oldevent (will be the current event module) Any objections? cheers, ps. note, I've started using [dev] subject for pygame development related threads. -- Lenard Lindstrom [EMAIL PROTECTED]
RE: [pygame] Pygame-Fenix - Using generators as game objects
Panda is more of a hybrid of an actor system and a lot of interlinked state machines (each actor has an FSM, and there are others that are global). I do actually like this model a lot, just not the Panda API. --Noah -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Knapp Sent: Monday, December 01, 2008 10:33 AM To: pygame-users@seul.org Subject: Re: [pygame] Pygame-Fenix - Using generators as game objects On Mon, Dec 1, 2008 at 6:05 PM, Fiona Burrows [EMAIL PROTECTED] wrote: Noah Kantrowitz wrote: If you want to look up information about this, the general term is actor-based programming. Existing libraries (neither of which ever seemed that great) include PARLEY and Dramatis. Stackless tasklets are also a very nice way to handle this. Panda3d is a lot like this also. This sample code is from their intro in the manual. They have 2 systems that work together. One is event driven and the other is task driven (tasks get called after each screen refresh or so). You then just make little defs that say what to do at each event or task slice and add them to the caller. Collisions can be set to trigger events or you can use a task to check the event que each turn. This code loads a 3d landscape and a panda bear actor and then makes the panda walk from side to side and turn around. Then the camera spins round and round also. import direct.directbase.DirectStart from pandac.PandaModules import * from direct.task import Task from direct.actor import Actor from direct.interval.IntervalGlobal import * import math #Load the first environment model environ = loader.loadModel(models/environment) environ.reparentTo(render) environ.setScale(0.25,0.25,0.25) environ.setPos(-8,42,0) #Task to move the camera def SpinCameraTask(task): angledegrees = task.time * 6.0 angleradians = angledegrees * (math.pi / 180.0) base.camera.setPos(20*math.sin(angleradians),- 20.0*math.cos(angleradians),3) base.camera.setHpr(angledegrees, 0, 0) return Task.cont taskMgr.add(SpinCameraTask, SpinCameraTask) #Load the panda actor, and loop its animation pandaActor = Actor.Actor(models/panda-model,{walk:models/panda- walk4}) pandaActor.setScale(0.005,0.005,0.005) pandaActor.reparentTo(render) pandaActor.loop(walk) #Create the four lerp intervals needed to walk back and forth pandaPosInterval1= pandaActor.posInterval(13,Point3(0,-10,0), startPos=Point3(0,10,0)) pandaPosInterval2= pandaActor.posInterval(13,Point3(0,10,0), startPos=Point3(0,-10,0)) pandaHprInterval1= pandaActor.hprInterval(3,Point3(180,0,0), startHpr=Point3(0,0,0)) pandaHprInterval2= pandaActor.hprInterval(3,Point3(0,0,0), startHpr=Point3(180,0,0)) #Create and play the sequence that coordinates the intervals pandaPace = Sequence(pandaPosInterval1, pandaHprInterval1, pandaPosInterval2, pandaHprInterval2, name = pandaPace) pandaPace.loop() run() -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
Re: [pygame] Pygame-Fenix - Using generators as game objects
On Mon, Dec 1, 2008 at 7:49 PM, Noah Kantrowitz [EMAIL PROTECTED] wrote: Panda is more of a hybrid of an actor system and a lot of interlinked state machines (each actor has an FSM, and there are others that are global). I do actually like this model a lot, just not the Panda API. --Noah What do you dislike about the API? I find it really easy to use. I sometimes wish pygame were more like it. What would you change? -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
RE: [pygame] Pygame-Fenix - Using generators as game objects
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Knapp Sent: Monday, December 01, 2008 10:54 AM To: pygame-users@seul.org Subject: Re: [pygame] Pygame-Fenix - Using generators as game objects On Mon, Dec 1, 2008 at 7:49 PM, Noah Kantrowitz [EMAIL PROTECTED] wrote: Panda is more of a hybrid of an actor system and a lot of interlinked state machines (each actor has an FSM, and there are others that are global). I do actually like this model a lot, just not the Panda API. --Noah What do you dislike about the API? I find it really easy to use. I sometimes wish pygame were more like it. What would you change? The Panda API has a lot of a C++isms that show through to the Python side. Example: Node vs. NodePath. It isn't bad per se, just not as clean as it could be. I think the same ideas could be made into a much more pythonic system that would be glorious. --Noah
Re: [pygame] Pygame-Fenix - Using generators as game objects
On Monday 01 December 2008 17:05:58 Fiona Burrows wrote: Thank you! I knew there would be a term for it. :) Those libraries seem interesting - especially Dramatis. But neither of them seem as well suited for games as mine as I have lots of game-specific things like collision detection going on. Also Kamaelia does these things btw. Kamaelia is actor-like, but not actor model. The difference is primarily that in Kamaelia when you send you send to an outbox, not to someone else's inbox. Something higher up then resolves outbox-inboxes for you. (This is made performance friendly by some internal optimisations, meaning that delivery to an outbox immediately delivers to the correct inbox). This leads to stuff like: Pipeline( MyGamesEventsComponent(up=p, down=l, left=a, right=s), BasicSprite(cat.png, name = cat, border=40), ).activate() Since you can join the output from one thing to the input from the other. (Other shapes other than pipeline are available) More detail on differences: http://yeoldeclue.com/cgi-bin/blog/blog.cgi?rm=viewpostnodeid=1226893221 http://lambda-the-ultimate.org/node/3108#comment-45328 Fundamentally though, kamaelia's model is more like hardware or unix pipes, the actor model is a bit like UDP. See also the first major example here: http://www.slideshare.net/kamaelian/practical-concurrent-systems-made-simple-using-kamaelia-presentation (Ok, there's a preamble - skip forward to about slide 55) Incidentally, Kamaelia defaults to using generators (though you can use threads and processes), and what you've written here: process guy(x, y) begin graph = load_png(test.png); loop frame; end end end Essentially matches what we do. For a comparison of the difference between a normal bit of pygame code and a pygame component, you can follow the sequence of changes here: http://code.google.com/p/kamaelia/source/browse/trunk/Sketches/MPS/WebCam.py Lines 18 - 48 are a normal usage of pygame / pygame camera module code. Lines 51 - 81 are the minimal transformation to a threaded based component (but one that doesn't play nicely with others) Lines 83 - 104 splits out just the capture to a component and Lines 109 - 127 is a surface displayer. This is a minimal change version really from 51-81 so it doesn't play nicely with others. That's then changed to something that does in lines 132-167. You'll note its main method looks like this: (couple of minor cleanups actually - that is scratch/sketch code :-) def main(self): yield Axon.Ipc.WaitComplete(self.getDisplay()) while 1: for snapshort in self.Inbox(inbox): self.display.blit(snapshot, (0,0)) self.pygame_display_flip() while not self.anyReady(): self.pause() yield 1 yield 1 Which aside form a few oddities probably doesn't look *too* strange really. There's more evolution further on through the file, but you should be able to see the logic really - get the thing working normally, then replace calls regarding getting a surface with something else, and replace the pygame display flip call with something else (if the surface is dirty). There's a bunch of pygame specific components, played with the (hopefully soon to be released since it's cool) pygame video support, and some stuff aimed at simple games for kids. Most of our pygame stuff has actually revolved around playing interfaces. (eg there's a physics model based topology visualiser for example :) ) For example, this is an example chat server with pygame based clients: http://yeoldeclue.com/cgi-bin/blog/blog.cgi?rm=viewpostnodeid=1226574014 Oh, the pygame components can also sit happily on Open GL surfaces in case that's of interest :) Michael. -- http://yeoldeclue.com/blog http://twitter.com/kamaelian http://www.kamaelia.org/GetKamaelia http://www.kamaelia.org/Cookbook
Re: [pygame] Getting input from command line
On Monday 01 December 2008 12:57:15 Fiona Burrows wrote: I know this isn't directly related to PyGame but I figured there were worse places to ask a question like this This page is your friend: http://openbookproject.net/py4fun/lode/lode.html#auto2 In fact the entire site is quite fun... http://openbookproject.net/py4fun/ ... but with a name like that it would be. Specifically this file shows you what you need to do: http://openbookproject.net//py4fun/lode/ttyLinux.py Specifically you have to change the console mode to spit out characters at a time, you can then play with them and when your program exits change it back again. Michael. -- http://yeoldeclue.com/blog http://twitter.com/kamaelian http://www.kamaelia.org/Home
Re: [pygame] Crazy Machine type game?
Joe Strout wrote: On Dec 1, 2008, at 7:33 AM, Kris Schnee wrote: On Sun, 30 Nov 2008 22:57:19 -0200, claudio canepa [EMAIL PROTECTED] wrote: There is an old clone like in pygame site, look at http://www.pygame.org/projects/21/139/ You might also want to look at Assembly Line: http://www.pygame.org/project/735/ Also my other simulationy game, 555-BOOM: http://www.pygame.org/project/498/ Boy, somebody ought to add the simulation tag to those games Good idea - I've just done that for mine. -- Greg