[pygame] Crackle and static with pygame.mixer.music
I am attempting to play .ogg files with pygame, but my playback is static-filled. Sample script follows: --- import pygame.mixer pygame.mixer.init() pygame.mixer.music.load('sample.ogg') pygame.mixer.music.play() import time while 1: time.sleep(1) --- I have tested this with the Ubuntu 8.04 distribution of pygame 1.7.1, version 1.8.0 from the home page, and the latest 1.8.1 release on the CVS. All versions produce identical results. All tested .ogg files work perfectly in other media players.
Re: [pygame] Another sprite issue.
Oh. I see. Thank you very much. I knew it had to be something simple. On Mon, Jul 28, 2008 at 5:40 PM, Brian Fisher <[EMAIL PROTECTED]>wrote: > They are all using the same rect object, and you are positioning that 1 > single rect to the location of the wall. So collision is working for all, > but all of them are positioned in the same place. > > Instead of calling get_rect once and reusing the result, you should pass > the image to each sprite and have them each call get_rect themselves to get > their own unique rect. > > > > On Mon, Jul 28, 2008 at 8:36 PM, <[EMAIL PROTECTED]> wrote: > >> I want to display sprites with the same graphic across several areas >> of my game. So I load the image into one variable, and then create all >> my sprites from that same image. >> >> All the sprites appear properly, but collision detection only works on >> the last sprite drawn using the variable with the image. Why is this? >> Do I have to reload the image everytime? >> >> This is my code to load the image: >> >> def load_image(name, transparent=0, colorkey=None): #from the line-by- >> line chimp tutorial >>fullname = os.path.join('img', name) >>try: >>if transparent == 0: >>image = pygame.image.load(fullname).convert() >>else: >>image = pygame.image.load(fullname).convert_alpha() >>except pygame.error, message: >>print 'Cannot load image:', name >>raise SystemExit, message >>if colorkey is not None: >>if colorkey is -1: >>colorkey = image.get_at((0,0)) >>image.set_colorkey(colorkey, RLEACCEL) >>return image, image.get_rect() >> >> To setup the sprite: >> >> class Units(pygame.sprite.Sprite): >> >>def __init__(self, img, loc1 = 250, loc2 = 250): >>pygame.sprite.Sprite.__init__(self) #start up sprites >> >>#locs >>self.loc1 = loc1 >>self.loc2 = loc2 >> >>#create sprite >>self.image, self.rect = img >>self.rect.center = [self.loc1, self.loc2] >> >> and actually making the sprites: >> >> wallGfx = load_image('wall.png', 1) >> self.wall1 = Units(wallGfx2, 400, 325) >> self.screen.blit(self.wall1.image, self.wall1.rect) >> >> self.wall2 = Units(wallGfx, 400, 400) >> self.screen.blit(self.wall2.image, self.wall2.rect) >> self.egroup = pygame.sprite.RenderUpdates(self.wall1, self.wall2) >> >> pygame.display.update() >> >> Now, doing this, only the sprite at 400,400 (self.wall2) will have >> proper collision detection. They're both displayed, but only the last >> one added to the group has it. If I remove self.wall2, self.wall1 will >> detect it properly. >> >> Any ideas? >> >> Thanks in advance. >> > >
Re: [pygame] Another sprite issue.
They are all using the same rect object, and you are positioning that 1 single rect to the location of the wall. So collision is working for all, but all of them are positioned in the same place. Instead of calling get_rect once and reusing the result, you should pass the image to each sprite and have them each call get_rect themselves to get their own unique rect. On Mon, Jul 28, 2008 at 8:36 PM, <[EMAIL PROTECTED]> wrote: > I want to display sprites with the same graphic across several areas > of my game. So I load the image into one variable, and then create all > my sprites from that same image. > > All the sprites appear properly, but collision detection only works on > the last sprite drawn using the variable with the image. Why is this? > Do I have to reload the image everytime? > > This is my code to load the image: > > def load_image(name, transparent=0, colorkey=None): #from the line-by- > line chimp tutorial >fullname = os.path.join('img', name) >try: >if transparent == 0: >image = pygame.image.load(fullname).convert() >else: >image = pygame.image.load(fullname).convert_alpha() >except pygame.error, message: >print 'Cannot load image:', name >raise SystemExit, message >if colorkey is not None: >if colorkey is -1: >colorkey = image.get_at((0,0)) >image.set_colorkey(colorkey, RLEACCEL) >return image, image.get_rect() > > To setup the sprite: > > class Units(pygame.sprite.Sprite): > >def __init__(self, img, loc1 = 250, loc2 = 250): >pygame.sprite.Sprite.__init__(self) #start up sprites > >#locs >self.loc1 = loc1 >self.loc2 = loc2 > >#create sprite >self.image, self.rect = img >self.rect.center = [self.loc1, self.loc2] > > and actually making the sprites: > > wallGfx = load_image('wall.png', 1) > self.wall1 = Units(wallGfx2, 400, 325) > self.screen.blit(self.wall1.image, self.wall1.rect) > > self.wall2 = Units(wallGfx, 400, 400) > self.screen.blit(self.wall2.image, self.wall2.rect) > self.egroup = pygame.sprite.RenderUpdates(self.wall1, self.wall2) > > pygame.display.update() > > Now, doing this, only the sprite at 400,400 (self.wall2) will have > proper collision detection. They're both displayed, but only the last > one added to the group has it. If I remove self.wall2, self.wall1 will > detect it properly. > > Any ideas? > > Thanks in advance. >
[pygame] Re: Another sprite issue.
Er, there is an error in the code I pasted there. It says wallGfx2, but that's not why this is happening, thats just something left over. It doesn't work even when it's the proper variable. On Jul 28, 5:36 pm, [EMAIL PROTECTED] wrote: > I want to display sprites with the same graphic across several areas > of my game. So I load the image into one variable, and then create all > my sprites from that same image. > > All the sprites appear properly, but collision detection only works on > the last sprite drawn using the variable with the image. Why is this? > Do I have to reload the image everytime? > > This is my code to load the image: > > def load_image(name, transparent=0, colorkey=None): #from the line-by- > line chimp tutorial > fullname = os.path.join('img', name) > try: > if transparent == 0: > image = pygame.image.load(fullname).convert() > else: > image = pygame.image.load(fullname).convert_alpha() > except pygame.error, message: > print 'Cannot load image:', name > raise SystemExit, message > if colorkey is not None: > if colorkey is -1: > colorkey = image.get_at((0,0)) > image.set_colorkey(colorkey, RLEACCEL) > return image, image.get_rect() > > To setup the sprite: > > class Units(pygame.sprite.Sprite): > > def __init__(self, img, loc1 = 250, loc2 = 250): > pygame.sprite.Sprite.__init__(self) #start up sprites > > #locs > self.loc1 = loc1 > self.loc2 = loc2 > > #create sprite > self.image, self.rect = img > self.rect.center = [self.loc1, self.loc2] > > and actually making the sprites: > > wallGfx = load_image('wall.png', 1) > self.wall1 = Units(wallGfx2, 400, 325) > self.screen.blit(self.wall1.image, self.wall1.rect) > > self.wall2 = Units(wallGfx, 400, 400) > self.screen.blit(self.wall2.image, self.wall2.rect) > self.egroup = pygame.sprite.RenderUpdates(self.wall1, self.wall2) > > pygame.display.update() > > Now, doing this, only the sprite at 400,400 (self.wall2) will have > proper collision detection. They're both displayed, but only the last > one added to the group has it. If I remove self.wall2, self.wall1 will > detect it properly. > > Any ideas? > > Thanks in advance.
Re: [pygame] pygame and bulletml
Python can read xml. I don't know of a bulletml specific python lib. -- Jake
[pygame] Another sprite issue.
I want to display sprites with the same graphic across several areas of my game. So I load the image into one variable, and then create all my sprites from that same image. All the sprites appear properly, but collision detection only works on the last sprite drawn using the variable with the image. Why is this? Do I have to reload the image everytime? This is my code to load the image: def load_image(name, transparent=0, colorkey=None): #from the line-by- line chimp tutorial fullname = os.path.join('img', name) try: if transparent == 0: image = pygame.image.load(fullname).convert() else: image = pygame.image.load(fullname).convert_alpha() except pygame.error, message: print 'Cannot load image:', name raise SystemExit, message if colorkey is not None: if colorkey is -1: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, RLEACCEL) return image, image.get_rect() To setup the sprite: class Units(pygame.sprite.Sprite): def __init__(self, img, loc1 = 250, loc2 = 250): pygame.sprite.Sprite.__init__(self) #start up sprites #locs self.loc1 = loc1 self.loc2 = loc2 #create sprite self.image, self.rect = img self.rect.center = [self.loc1, self.loc2] and actually making the sprites: wallGfx = load_image('wall.png', 1) self.wall1 = Units(wallGfx2, 400, 325) self.screen.blit(self.wall1.image, self.wall1.rect) self.wall2 = Units(wallGfx, 400, 400) self.screen.blit(self.wall2.image, self.wall2.rect) self.egroup = pygame.sprite.RenderUpdates(self.wall1, self.wall2) pygame.display.update() Now, doing this, only the sprite at 400,400 (self.wall2) will have proper collision detection. They're both displayed, but only the last one added to the group has it. If I remove self.wall2, self.wall1 will detect it properly. Any ideas? Thanks in advance.
Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
Hi, here's some more stuff to consider... http://wiki.secondlife.com/wiki/Eventlet http://pypi.python.org/pypi/greenlet There is a python wrapper for enet too (in the version control, part of enet). libevent api: http://www.monkey.org/~provos/libevent/ http://code.google.com/p/pyevent/ cheers, On Tue, Jul 29, 2008 at 11:06 AM, René Dudfield <[EMAIL PROTECTED]> wrote: > hello, > > below are a collection of notes for game networking... > > For the pygame 1.9+ release we would really like to get networking > library routines in :) Something that's simple, and has been used > successfully in at least 2 games( 1 by the author, and 1 by someone > else) would be nice. Getting your library ready for ludumdare.com > (august 8-10), and pyweek.org (sept 31st) would allow other people to > try it out by making games. > > > > > Channels in UDP are cool. They allow you to separate data which cares > about order or sequence. Here's a description from a game UDP > networking library... note enet is used by the cube engine. > http://enet.bespin.org/Features.html > > For udp please consider being tcp friendly... > http://www.psc.edu/networking/projects/tcpfriendly/ > > > Seeing network events in the pygame event queue would simplify things > for people. So networking then becomes like any other event. > > #pygame.network.send(data, channel, lossy) > pygame.network.send("hello network.", CHANNEL_CHAT, 0) > > for e in pygame.event.get(): > if e.type == NETWORK: > if e.what == NETWORK_DATA_IN: > print e.channel > print e.data > print e.sequenceid > print e.peer > if e.channel == CHANNEL_CHAT: > # we write the incomming text to our chat window. > chatwindow.write_text(e.peer, e.data) > > > > > OSC is an important consideration too. OSC is the new midi. It's a > pretty good UDP based protocol for real time use. It's widely used in > the music world as a networked replacement for midi, and a little bit > in the game world. > > http://en.wikipedia.org/wiki/OpenSound_Control > > It does things quite well for real time use. Things like bundling > messages together. So if you send a bunch of messages they can be > played back in time. This is obviously very useful for music, but also > for games... where timing is important for many games. > > This idea from OSC(bundling timed events) can be used to replay events > with the same time that they appeared in one machine on another > machine. However OSC can be implemented separately if needed(and has > already been made > http://www.ixi-audio.net/content/body_backyard_python.html ). > > > Another thing to consider is sending video data. Video data can be > quite large :) Especially when you get into the 10gbit area. > > > Here's a discussion on quake 3 networking... > http://trac.bookofhook.com/bookofhook/trac.cgi/wiki/Quake3Networking > > Noah code: > https://coderanger.net/svn/school/2007/fall/egd/magnoball/pygamenet.py > > Simon Wittabers twisted implementation of simple networking. > http://code.google.com/p/pygnet/ > > Notes from 2006 pre-gsoc about simple networking for pygame. > http://wiki.python.org/moin/SummerOfCode/PythonLibraries/SimpleNetworkingForPygame > > Concurrent programming using an actor component based model. (note > the website is ancient... but there is actually an active community > there with 5 or gsoc students) > http://kamaelia.sourceforge.net/Home > http://yeoldeclue.com/cgi-bin/blog/blog.cgi (this blog by the author > has more current info on it) > > sjbrowns networking tutorial using twisted: > http://sjbrown.ezide.com/games/writing-games.html > > raknet is one of the top game networking libraries... written in C++ > Good to look at for features, and ways they do things. > http://www.jenkinssoftware.com/ > > http://www.pygame.org/tags/network > http://www.pygame.org/tags/multiplayer > > > Tunneling over http, and using serial ports is something else to > consider :) As is communication via camera(in) and video(out) screen > ;) > > > > anyway... just some notes for reading. > > > cu, > > > > On Tue, Jul 29, 2008 at 9:55 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: >>> -Original Message- >>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >>> On Behalf Of Casey Duncan >>> Sent: Monday, July 28, 2008 4:46 PM >>> To: pygame-users@seul.org >>> Cc: 'Games for the OLPC' >>> Subject: Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad >>> >>> On Jul 28, 2008, at 4:49 PM, Noah Kantrowitz wrote: >>> >>> [..] >>> >> https://coderanger.net/svn/school/2007/fall/egd/magnoball/ >>> >> pygamenet.py >>> >>> . Also a WiP. >>> >> PyQNet is split over 8 modules, but the actual number of code-lines >>> >> in >>> >> the library (excluding the tests) is pretty small (640 incl. >>> comments >>> >> and docstrings), pygamenet is around 591 when you take out the >>> >> comments. Though PyQNet is likely to grow substantially once I get >>> >> all >>> >> the fea
Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
hello, below are a collection of notes for game networking... For the pygame 1.9+ release we would really like to get networking library routines in :) Something that's simple, and has been used successfully in at least 2 games( 1 by the author, and 1 by someone else) would be nice. Getting your library ready for ludumdare.com (august 8-10), and pyweek.org (sept 31st) would allow other people to try it out by making games. Channels in UDP are cool. They allow you to separate data which cares about order or sequence. Here's a description from a game UDP networking library... note enet is used by the cube engine. http://enet.bespin.org/Features.html For udp please consider being tcp friendly... http://www.psc.edu/networking/projects/tcpfriendly/ Seeing network events in the pygame event queue would simplify things for people. So networking then becomes like any other event. #pygame.network.send(data, channel, lossy) pygame.network.send("hello network.", CHANNEL_CHAT, 0) for e in pygame.event.get(): if e.type == NETWORK: if e.what == NETWORK_DATA_IN: print e.channel print e.data print e.sequenceid print e.peer if e.channel == CHANNEL_CHAT: # we write the incomming text to our chat window. chatwindow.write_text(e.peer, e.data) OSC is an important consideration too. OSC is the new midi. It's a pretty good UDP based protocol for real time use. It's widely used in the music world as a networked replacement for midi, and a little bit in the game world. http://en.wikipedia.org/wiki/OpenSound_Control It does things quite well for real time use. Things like bundling messages together. So if you send a bunch of messages they can be played back in time. This is obviously very useful for music, but also for games... where timing is important for many games. This idea from OSC(bundling timed events) can be used to replay events with the same time that they appeared in one machine on another machine. However OSC can be implemented separately if needed(and has already been made http://www.ixi-audio.net/content/body_backyard_python.html ). Another thing to consider is sending video data. Video data can be quite large :) Especially when you get into the 10gbit area. Here's a discussion on quake 3 networking... http://trac.bookofhook.com/bookofhook/trac.cgi/wiki/Quake3Networking Noah code: https://coderanger.net/svn/school/2007/fall/egd/magnoball/pygamenet.py Simon Wittabers twisted implementation of simple networking. http://code.google.com/p/pygnet/ Notes from 2006 pre-gsoc about simple networking for pygame. http://wiki.python.org/moin/SummerOfCode/PythonLibraries/SimpleNetworkingForPygame Concurrent programming using an actor component based model. (note the website is ancient... but there is actually an active community there with 5 or gsoc students) http://kamaelia.sourceforge.net/Home http://yeoldeclue.com/cgi-bin/blog/blog.cgi (this blog by the author has more current info on it) sjbrowns networking tutorial using twisted: http://sjbrown.ezide.com/games/writing-games.html raknet is one of the top game networking libraries... written in C++ Good to look at for features, and ways they do things. http://www.jenkinssoftware.com/ http://www.pygame.org/tags/network http://www.pygame.org/tags/multiplayer Tunneling over http, and using serial ports is something else to consider :) As is communication via camera(in) and video(out) screen ;) anyway... just some notes for reading. cu, On Tue, Jul 29, 2008 at 9:55 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> On Behalf Of Casey Duncan >> Sent: Monday, July 28, 2008 4:46 PM >> To: pygame-users@seul.org >> Cc: 'Games for the OLPC' >> Subject: Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad >> >> On Jul 28, 2008, at 4:49 PM, Noah Kantrowitz wrote: >> >>> [..] >> >> https://coderanger.net/svn/school/2007/fall/egd/magnoball/ >> >> pygamenet.py >> >>> . Also a WiP. >> >> PyQNet is split over 8 modules, but the actual number of code-lines >> >> in >> >> the library (excluding the tests) is pretty small (640 incl. >> comments >> >> and docstrings), pygamenet is around 591 when you take out the >> >> comments. Though PyQNet is likely to grow substantially once I get >> >> all >> >> the features I want implemented. >> >> >> >> The difference in size currently is likely because PyQNet is >> >> implemented >> >> as UDP with ordering and retry controlled by the Python code >> >> instead of >> >> using TCP-level operations. The UDP operations should allow us to >> >> code >> >> adaptations into the library to optimize for low-latency game-y >> >> operation. >> > >> > This is a common misconception. The reason to use UDP is not for low- >> > latency >> > (just set TCP_NODELAY), but to accommodate lossy links. Generally >> > this means >> > dealing with e
RE: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Casey Duncan > Sent: Monday, July 28, 2008 5:13 PM > To: pygame-users@seul.org > Subject: Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad > > On Jul 28, 2008, at 5:55 PM, Noah Kantrowitz wrote: > > >> TCP has many semantics that can be undesirable for some games, in > >> particular "guaranteed delivery" regardless of effective time of > >> transmission. In many real-time applications (FPS games come to > >> mind), > >> state data becomes out of date very quickly, thus if the > transmission > >> cannot be completed in a particular time window, it is better not to > >> receive the data at all. In these games the state updates can become > >> roughly like a stream. > > > > In any game network protocol I have ever seen, this is simply not > > true. For > > example, position is generally not sent as an absolute, but as > > difference. > > Aside from periodic resyncs, the moment-to-moment updates generally > > all do > > need to be received. > > Quake 3 famously issues updates solely via udp as a delta between the > last known state of the receiver and the sender bi-directionally. This > has been widely copied in games of that genre in the following years > and was considered at the time to be a huge advance over the mixture > of reliable and unreliable transmission modes used before. Yes, this is an excellent use of UDP for game networking. My point is just that designing your game to allow this cleanly is very difficult, and slapping retransmission on top of UDP actually gets you worse off than simply using TCP. I get antsy seeing UDP mentioned around games because I think 1) people discard TCP as unusable far too fast and 2) people don't understand how hard _good_ networking is. --Noah
Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
On Jul 28, 2008, at 5:55 PM, Noah Kantrowitz wrote: TCP has many semantics that can be undesirable for some games, in particular "guaranteed delivery" regardless of effective time of transmission. In many real-time applications (FPS games come to mind), state data becomes out of date very quickly, thus if the transmission cannot be completed in a particular time window, it is better not to receive the data at all. In these games the state updates can become roughly like a stream. In any game network protocol I have ever seen, this is simply not true. For example, position is generally not sent as an absolute, but as difference. Aside from periodic resyncs, the moment-to-moment updates generally all do need to be received. Quake 3 famously issues updates solely via udp as a delta between the last known state of the receiver and the sender bi-directionally. This has been widely copied in games of that genre in the following years and was considered at the time to be a huge advance over the mixture of reliable and unreliable transmission modes used before. UDP has a lower overhead than TCP, making it advantageous for sending streaming data where intermittent loss is preferable to indeterminate data lag. The overheard will be lower than implementing a similar system yourself in UDP. Also dynamic window sizing means that the overhead is generally too small to speak of. The lower overhead is more of a bonus, not the main benefit. The main benefit is direct control over the delivery and retransmission semantics. At the expense, of course, of having to implement these things yourself. I'm not trying to argue that UDP is better, but it certainly has its advantages for specific applications. -Casey
Re: [pygame] pygame and anaglyph games
yes, anaglyph games - since they were quite rare, even from all game history - would be interesting on develop this kind of game using lines would be the easier solution (maybe), but working directly on colour channels could provide better results - that's why i asked how possible could be directly working on each colour channel, for this kind of game as example... On Mon, Jul 28, 2008 at 9:26 PM, Paul Pigg <[EMAIL PROTECTED]> wrote: > Yeah, it looked much like that to me, too. I believe it should be possible > in pygame, but if that is in fact what he wants to do, then I know that > vpython has stereo vision capabilities builtin, enabled by a simple flag. > Not that I am saying vpython will meet all your needs (it can be quite > limiting at times), but, you know, FYI. > > --Paul > > On Mon, Jul 28, 2008 at 1:11 PM, Knapp <[EMAIL PROTECTED]> wrote: >> >> On Mon, Jul 28, 2008 at 8:44 PM, Brian Fisher <[EMAIL PROTECTED]> >> wrote: >> > So what exactly about this anaglyph game thing is it you want to do in >> > pygame? >> > >> > If it's just drawing rects, yeah you can do that (pygame.draw.rect) >> > >> > If it's drawing lines of different colors on different lines, then you >> > can >> > do that too (pygame.draw.line) >> > >> > There are possible issues with each of those and other possible >> > approaches >> > to do stuff, but it's easier to talk about such things when one knows >> > what >> > it is you want to achieve. The more specific you can be the better. >> > >> > >> > On Mon, Jul 28, 2008 at 6:01 AM, Paulo Silva <[EMAIL PROTECTED]> >> > wrote: >> >> >> >> how fine were being Pygame on anaglyph games like this? >> >> http://youtube.com/watch?v=C00TlFHld0o >> >> >> >> Is the only way doing like this, using the red channel in the odd >> >> lines and green/blue in even (stuff not very hard to do, btw...), or >> >> can we really work on separated colour channels? >> >> If someone know snippets, working games, etc., please let me know... >> >> >> >> thanks! :-) >> >> Just a guess but, I think he wants to do 3d games with 3d red/blue >> glasses. >> >> -- >> Douglas E Knapp >> >> http://sf-journey-creations.wikispot.org/Front_Page > >
RE: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Casey Duncan > Sent: Monday, July 28, 2008 4:46 PM > To: pygame-users@seul.org > Cc: 'Games for the OLPC' > Subject: Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad > > On Jul 28, 2008, at 4:49 PM, Noah Kantrowitz wrote: > >>> [..] > >> https://coderanger.net/svn/school/2007/fall/egd/magnoball/ > >> pygamenet.py > >>> . Also a WiP. > >> PyQNet is split over 8 modules, but the actual number of code-lines > >> in > >> the library (excluding the tests) is pretty small (640 incl. > comments > >> and docstrings), pygamenet is around 591 when you take out the > >> comments. Though PyQNet is likely to grow substantially once I get > >> all > >> the features I want implemented. > >> > >> The difference in size currently is likely because PyQNet is > >> implemented > >> as UDP with ordering and retry controlled by the Python code > >> instead of > >> using TCP-level operations. The UDP operations should allow us to > >> code > >> adaptations into the library to optimize for low-latency game-y > >> operation. > > > > This is a common misconception. The reason to use UDP is not for low- > > latency > > (just set TCP_NODELAY), but to accommodate lossy links. Generally > > this means > > dealing with either bad connections or high congestion. And when I > > say "deal > > with" I mean "detect and die", not just reimplementing > > retransmission on top > > of UDP. As it stands there is no real reason to use UDP for games > > anymore > > unless you really think the vast majority of your users will be on > bad > > connections. I don't think this is the case, even for OLPC (sat > > links are > > slow, but generally not lossy). > > TCP has many semantics that can be undesirable for some games, in > particular "guaranteed delivery" regardless of effective time of > transmission. In many real-time applications (FPS games come to mind), > state data becomes out of date very quickly, thus if the transmission > cannot be completed in a particular time window, it is better not to > receive the data at all. In these games the state updates can become > roughly like a stream. In any game network protocol I have ever seen, this is simply not true. For example, position is generally not sent as an absolute, but as difference. Aside from periodic resyncs, the moment-to-moment updates generally all do need to be received. > UDP has a lower overhead than TCP, making it advantageous for sending > streaming data where intermittent loss is preferable to indeterminate > data lag. The overheard will be lower than implementing a similar system yourself in UDP. Also dynamic window sizing means that the overhead is generally too small to speak of. --Noah
Re: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
On Jul 28, 2008, at 4:49 PM, Noah Kantrowitz wrote: [..] https://coderanger.net/svn/school/2007/fall/egd/magnoball/ pygamenet.py . Also a WiP. PyQNet is split over 8 modules, but the actual number of code-lines in the library (excluding the tests) is pretty small (640 incl. comments and docstrings), pygamenet is around 591 when you take out the comments. Though PyQNet is likely to grow substantially once I get all the features I want implemented. The difference in size currently is likely because PyQNet is implemented as UDP with ordering and retry controlled by the Python code instead of using TCP-level operations. The UDP operations should allow us to code adaptations into the library to optimize for low-latency game-y operation. This is a common misconception. The reason to use UDP is not for low- latency (just set TCP_NODELAY), but to accommodate lossy links. Generally this means dealing with either bad connections or high congestion. And when I say "deal with" I mean "detect and die", not just reimplementing retransmission on top of UDP. As it stands there is no real reason to use UDP for games anymore unless you really think the vast majority of your users will be on bad connections. I don't think this is the case, even for OLPC (sat links are slow, but generally not lossy). TCP has many semantics that can be undesirable for some games, in particular "guaranteed delivery" regardless of effective time of transmission. In many real-time applications (FPS games come to mind), state data becomes out of date very quickly, thus if the transmission cannot be completed in a particular time window, it is better not to receive the data at all. In these games the state updates can become roughly like a stream. UDP has a lower overhead than TCP, making it advantageous for sending streaming data where intermittent loss is preferable to indeterminate data lag. That said, using TCP is more user-friendly and "intuitive" as it has a higher level of abstraction as a protocol. But the trade-off -- as is always the case with abstraction -- is less direct control. -Casey
RE: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Mike C. Fletcher > Sent: Monday, July 28, 2008 3:44 PM > To: pygame-users@seul.org; Games for the OLPC > Subject: [pygame] Re: [OLPC-Games] PyQNet project on Launchpad > > Noah Kantrowitz wrote: > > Mike C. Fletcher wrote: > >> Hi all, > >> > >> Those of you who were at PyCon in Chicago for the OLPC sprint may > >> remember Phil Hassey's impromptu lecture on how to build a > networking > >> API [1]. I've been hacking together a preliminary implementation of > >> something like that API and have just moved the project to > >> Launchpad[2] so that other people can play with the code. It's > >> definitely not finished yet, so if you want to work on something > >> low-level and network-y, feel free to play. > > > > A similarly designed (and much smaller) library is also up at > > > https://coderanger.net/svn/school/2007/fall/egd/magnoball/pygamenet.py > > . Also a WiP. > PyQNet is split over 8 modules, but the actual number of code-lines in > the library (excluding the tests) is pretty small (640 incl. comments > and docstrings), pygamenet is around 591 when you take out the > comments. Though PyQNet is likely to grow substantially once I get all > the features I want implemented. > > The difference in size currently is likely because PyQNet is > implemented > as UDP with ordering and retry controlled by the Python code instead of > using TCP-level operations. The UDP operations should allow us to code > adaptations into the library to optimize for low-latency game-y > operation. This is a common misconception. The reason to use UDP is not for low-latency (just set TCP_NODELAY), but to accommodate lossy links. Generally this means dealing with either bad connections or high congestion. And when I say "deal with" I mean "detect and die", not just reimplementing retransmission on top of UDP. As it stands there is no real reason to use UDP for games anymore unless you really think the vast majority of your users will be on bad connections. I don't think this is the case, even for OLPC (sat links are slow, but generally not lossy). --Noah
[pygame] Re: [OLPC-Games] PyQNet project on Launchpad
Noah Kantrowitz wrote: Mike C. Fletcher wrote: Hi all, Those of you who were at PyCon in Chicago for the OLPC sprint may remember Phil Hassey's impromptu lecture on how to build a networking API [1]. I've been hacking together a preliminary implementation of something like that API and have just moved the project to Launchpad[2] so that other people can play with the code. It's definitely not finished yet, so if you want to work on something low-level and network-y, feel free to play. A similarly designed (and much smaller) library is also up at https://coderanger.net/svn/school/2007/fall/egd/magnoball/pygamenet.py . Also a WiP. PyQNet is split over 8 modules, but the actual number of code-lines in the library (excluding the tests) is pretty small (640 incl. comments and docstrings), pygamenet is around 591 when you take out the comments. Though PyQNet is likely to grow substantially once I get all the features I want implemented. The difference in size currently is likely because PyQNet is implemented as UDP with ordering and retry controlled by the Python code instead of using TCP-level operations. The UDP operations should allow us to code adaptations into the library to optimize for low-latency game-y operation. pygamenet.py seems nice, but it's not really the direction I was looking to explore. I don't see a problem with having both libraries under development. Have fun, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com
Re: [pygame] pygame and anaglyph games
Yeah, it looked much like that to me, too. I believe it should be possible in pygame, but if that is in fact what he wants to do, then I know that vpython has stereo vision capabilities builtin, enabled by a simple flag. Not that I am saying vpython will meet all your needs (it can be quite limiting at times), but, you know, FYI. --Paul On Mon, Jul 28, 2008 at 1:11 PM, Knapp <[EMAIL PROTECTED]> wrote: > On Mon, Jul 28, 2008 at 8:44 PM, Brian Fisher <[EMAIL PROTECTED]> > wrote: > > So what exactly about this anaglyph game thing is it you want to do in > > pygame? > > > > If it's just drawing rects, yeah you can do that (pygame.draw.rect) > > > > If it's drawing lines of different colors on different lines, then you > can > > do that too (pygame.draw.line) > > > > There are possible issues with each of those and other possible > approaches > > to do stuff, but it's easier to talk about such things when one knows > what > > it is you want to achieve. The more specific you can be the better. > > > > > > On Mon, Jul 28, 2008 at 6:01 AM, Paulo Silva <[EMAIL PROTECTED]> > wrote: > >> > >> how fine were being Pygame on anaglyph games like this? > >> http://youtube.com/watch?v=C00TlFHld0o > >> > >> Is the only way doing like this, using the red channel in the odd > >> lines and green/blue in even (stuff not very hard to do, btw...), or > >> can we really work on separated colour channels? > >> If someone know snippets, working games, etc., please let me know... > >> > >> thanks! :-) > > Just a guess but, I think he wants to do 3d games with 3d red/blue glasses. > > -- > Douglas E Knapp > > http://sf-journey-creations.wikispot.org/Front_Page >
Re: [pygame] pygame and anaglyph games
On Mon, Jul 28, 2008 at 8:44 PM, Brian Fisher <[EMAIL PROTECTED]> wrote: > So what exactly about this anaglyph game thing is it you want to do in > pygame? > > If it's just drawing rects, yeah you can do that (pygame.draw.rect) > > If it's drawing lines of different colors on different lines, then you can > do that too (pygame.draw.line) > > There are possible issues with each of those and other possible approaches > to do stuff, but it's easier to talk about such things when one knows what > it is you want to achieve. The more specific you can be the better. > > > On Mon, Jul 28, 2008 at 6:01 AM, Paulo Silva <[EMAIL PROTECTED]> wrote: >> >> how fine were being Pygame on anaglyph games like this? >> http://youtube.com/watch?v=C00TlFHld0o >> >> Is the only way doing like this, using the red channel in the odd >> lines and green/blue in even (stuff not very hard to do, btw...), or >> can we really work on separated colour channels? >> If someone know snippets, working games, etc., please let me know... >> >> thanks! :-) Just a guess but, I think he wants to do 3d games with 3d red/blue glasses. -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
Re: [pygame] pygame and anaglyph games
So what exactly about this anaglyph game thing is it you want to do in pygame? If it's just drawing rects, yeah you can do that (pygame.draw.rect) If it's drawing lines of different colors on different lines, then you can do that too (pygame.draw.line) There are possible issues with each of those and other possible approaches to do stuff, but it's easier to talk about such things when one knows what it is you want to achieve. The more specific you can be the better. On Mon, Jul 28, 2008 at 6:01 AM, Paulo Silva <[EMAIL PROTECTED]> wrote: > how fine were being Pygame on anaglyph games like this? > http://youtube.com/watch?v=C00TlFHld0o > > Is the only way doing like this, using the red channel in the odd > lines and green/blue in even (stuff not very hard to do, btw...), or > can we really work on separated colour channels? > If someone know snippets, working games, etc., please let me know... > > thanks! :-) >
Re: [pygame] pygame and anaglyph games
i think don't - alpha works with opacities from all channels, not 100% of one or another specificly i think you can't get, for example, with alpha channels, over a #FF background, having a #FF and #00 sprites overlapped, a #00 colour, which would be the needed result... but maybe Pygame or SDL have different ways (modes) to work with alpha channels, which i don't know any of them at all? - On Mon, Jul 28, 2008 at 6:29 PM, Knapp <[EMAIL PROTECTED]> wrote: > On Mon, Jul 28, 2008 at 3:01 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: >> how fine were being Pygame on anaglyph games like this? >> http://youtube.com/watch?v=C00TlFHld0o >> >> Is the only way doing like this, using the red channel in the odd >> lines and green/blue in even (stuff not very hard to do, btw...), or >> can we really work on separated colour channels? >> If someone know snippets, working games, etc., please let me know... >> >> thanks! :-) >> > > Could you not do it with alpha channels? > > -- > Douglas E Knapp > > http://sf-journey-creations.wikispot.org/Front_Page >
Re: [pygame] how hexcolour arrays works?
thanks! :-) On Mon, Jul 28, 2008 at 6:36 PM, Knapp <[EMAIL PROTECTED]> wrote: > Numpy or numeric (old) might give you arrays that are more to your > liking. These are python libs btw. > -- > Douglas E Knapp > > http://sf-journey-creations.wikispot.org/Front_Page >
Re: [pygame] how hexcolour arrays works?
Numpy or numeric (old) might give you arrays that are more to your liking. These are python libs btw. -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
Re: [pygame] pygame and anaglyph games
On Mon, Jul 28, 2008 at 3:01 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: > how fine were being Pygame on anaglyph games like this? > http://youtube.com/watch?v=C00TlFHld0o > > Is the only way doing like this, using the red channel in the odd > lines and green/blue in even (stuff not very hard to do, btw...), or > can we really work on separated colour channels? > If someone know snippets, working games, etc., please let me know... > > thanks! :-) > Could you not do it with alpha channels? -- Douglas E Knapp http://sf-journey-creations.wikispot.org/Front_Page
Re: [pygame] Moving sprites.
It sounds like you've developed past this now, but I do have an old tutorial I wrote for people stuck with the same problems you had. The question comes up a lot. Half the tutorial doesn't even touch Pygame. It shows how to do things with straight Surface and blit calls. Help! How Do I Move An Image? http://pygame.org/docs/tut/MoveIt.html [EMAIL PROTECTED] wrote: So I've read piman's tutorial and checked out a few others. I'm still confused. I don't really understand the process of moving a sprite around. I would like to use RenderUpdates and such, but I'm lost.
Re: [pygame] BUG cd audio
On Sun, Jul 27, 2008 at 8:04 PM, René Dudfield <[EMAIL PROTECTED]> wrote: > Have you considered cdrtools?http://cdrecord.berlios.de/ It > works on win/linux/mac > > This is a ubuntu, and SDL bug really... I'll have to look at filing bug > reports. > No, I haven't considered cdrtools. Thanks for the link. I'd encountered them in the past, but no more than that. For now, though, I've outsourced my ripping needs to abcde. http://lly.org/~rcw/abcde/page/ It understands CDDB files and with the appropriate command-line parameters, does everything I need it to. It would be most helpful in the future, though, if this bug could be fixed. Thanks for being willing to look into it.
Re: [pygame] how hexcolour arrays works?
Me as well, i started using Python identation on ansi-basic, for an easier recoding between both :-) Who knows in a future i will be using pep8 on sdlBasic and wxBasic as well? i think maybe it's only a habit issue... Well, btw my first scare/concern about pep8 is the code may look too huge, like some java helloworld-like examples i saw (except some proce55ing.org examples, maybe...) - On Mon, Jul 28, 2008 at 4:10 PM, James Paige <[EMAIL PROTECTED]> wrote: > On Mon, Jul 28, 2008 at 04:03:09PM +0100, Paulo Silva wrote: >> >> James: thanks the encouragement, even when more than 20 years i were >> (in a hobbystic level, of course) coding in ansi-Basic language (8bit, >> Amos, sdlbasic/wxbasic ) my way of coding were nothing looking like >> pep8 - btw, would be a very interesting exercise... >> > > I also got my start with languages in the basic family, and I had the > same difficulty when I went to learn other languages. I wanted to make > other languages look like basic. It took me a while to learn the value > of adapting to the style of each different language. > > Of course, now when I go and write basic programs, I am constantly > trying to make them look more like python :) > > --- > James Paige >
Re: [pygame] how hexcolour arrays works?
On Mon, Jul 28, 2008 at 04:03:09PM +0100, Paulo Silva wrote: > > James: thanks the encouragement, even when more than 20 years i were > (in a hobbystic level, of course) coding in ansi-Basic language (8bit, > Amos, sdlbasic/wxbasic ) my way of coding were nothing looking like > pep8 - btw, would be a very interesting exercise... > I also got my start with languages in the basic family, and I had the same difficulty when I went to learn other languages. I wanted to make other languages look like basic. It took me a while to learn the value of adapting to the style of each different language. Of course, now when I go and write basic programs, I am constantly trying to make them look more like python :) --- James Paige
Re: [pygame] how hexcolour arrays works?
Devon: graphic designer as well? what a small world! :-) - an interesting link about Python and Graphic Design is this one: http://ospublish.constantvzw.org/index.php?s=python (constantvzw.org were at last Libre Graphics Meeting...) James: thanks the encouragement, even when more than 20 years i were (in a hobbystic level, of course) coding in ansi-Basic language (8bit, Amos, sdlbasic/wxbasic ) my way of coding were nothing looking like pep8 - btw, would be a very interesting exercise... -- On Mon, Jul 28, 2008 at 3:36 PM, James Paige <[EMAIL PROTECTED]> wrote: > Don't give up on python, just understand that readability is *REALLY* > important. > > If it helps, you should try to remember that the true prupose of a > programming language is NOT to describe to a computer what you want it > to do. The true purpose of a programming language is for you to describe > to yourself and other programmers what you want the computer to do. > > --- > James Paige > > On Mon, Jul 28, 2008 at 12:39:27PM +0100, Paulo Silva wrote: >> Stop right now? oh please, just now when i were getting so happy on >> trying to learn it? what a stimulation from the open-source world... >> :-(( >> >> (i really wanted only to focus in the solutions of doubts like mine one...) >> >> - >> >> >> >> > Stop using Python right now. The whole idea of the language revolves >> > around readability. >> >> --- >> >> On Mon, Jul 28, 2008 at 12:30 PM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: >> > Paulo Silva wrote: >> >> >> >> thanks Noah! >> >> >> >> ::> There, isn't that easier to read? >> >> >> >> it's easier to read on small codes like this, but when the code gets >> >> larger, surelly you need to use the scrollbar like working out in a >> >> gym... >> >> >> >> for me is very important being able to see around 5 'def' contents on >> >> the screen without having to scroll (well, i must confess i have an >> >> awful memory, maybe i'm getting too old...), but if the problem is >> >> politeness from me, of course i can clean the code before posting... >> > >> > Stop using Python right now. The whole idea of the language revolves around >> > readability. >> > >> > --Noah >> > >> > >> >> >
Re: [pygame] how hexcolour arrays works?
Don't give up on python, just understand that readability is *REALLY* important. If it helps, you should try to remember that the true prupose of a programming language is NOT to describe to a computer what you want it to do. The true purpose of a programming language is for you to describe to yourself and other programmers what you want the computer to do. --- James Paige On Mon, Jul 28, 2008 at 12:39:27PM +0100, Paulo Silva wrote: > Stop right now? oh please, just now when i were getting so happy on > trying to learn it? what a stimulation from the open-source world... > :-(( > > (i really wanted only to focus in the solutions of doubts like mine one...) > > - > > > > > Stop using Python right now. The whole idea of the language revolves around > > readability. > > --- > > On Mon, Jul 28, 2008 at 12:30 PM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: > > Paulo Silva wrote: > >> > >> thanks Noah! > >> > >> ::> There, isn't that easier to read? > >> > >> it's easier to read on small codes like this, but when the code gets > >> larger, surelly you need to use the scrollbar like working out in a > >> gym... > >> > >> for me is very important being able to see around 5 'def' contents on > >> the screen without having to scroll (well, i must confess i have an > >> awful memory, maybe i'm getting too old...), but if the problem is > >> politeness from me, of course i can clean the code before posting... > > > > Stop using Python right now. The whole idea of the language revolves around > > readability. > > > > --Noah > > > > > >
Re: [pygame] how hexcolour arrays works?
yay graphic designers here, here, hey, hey! Devon --- On Mon, 7/28/08, Paulo Silva <[EMAIL PROTECTED]> wrote: > From: Paulo Silva <[EMAIL PROTECTED]> > Subject: Re: [pygame] how hexcolour arrays works? > To: pygame-users@seul.org > Date: Monday, July 28, 2008, 6:59 AM > Noah, i also agree completelly each person works > differently, of > course! :-) (maybe that's why i got concerned about > politeness on > pasting code here, which i didn't know how far is it > needed or not...) > - you may be from the academic world, and i'm hobbyst, > academically > from graphic design area (and still with some bad habits > from the > ansi-basic 80's coding...) > > When compaired with Perl, Ruby and Java, Python for me is > maybe the > very best language i found - it's clean, and also works > fine as script > language on Gimp, Inkscape, Blender, Scribus, etc., what is > truly > awesome for me... - and as well, Python came installed on > all Linux > and MacOS-X, what is awesome as well... > > what made me becoming so surprised with Python is i could > code there > in the same way i used to code on sdlBasic and wxBasic, and > these > codes worked fine! :-) - you know, a mere graphic designer > with a > hobbyst taste about coding, being able to code scripts for > Gimp and so > on (the python version of the .ai importer from Inkscape is > mine, as > well the Gnome menu converter for Fluxbox, for example... > :-p ), even > some small converters... why i shoutd stop coding on > Python, you > know... ? > > thanks! :-) > > > > On Mon, Jul 28, 2008 at 12:38 PM, Noah Kantrowitz > <[EMAIL PROTECTED]> wrote: > > Paulo Silva wrote: > >> > >> Stop right now? oh please, just now when i were > getting so happy on > >> trying to learn it? what a stimulation from the > open-source world... > >> :-(( > >> > >> (i really wanted only to focus in the solutions of > doubts like mine > >> one...) > > > > If Python doesn't match the way you work, I doubt > you will enjoy it. Not > > every tool is right for every job, and each person > works differently. Thats > > all. > > > > --Noah > > > >
[pygame] pygame and anaglyph games
how fine were being Pygame on anaglyph games like this? http://youtube.com/watch?v=C00TlFHld0o Is the only way doing like this, using the red channel in the odd lines and green/blue in even (stuff not very hard to do, btw...), or can we really work on separated colour channels? If someone know snippets, working games, etc., please let me know... thanks! :-)
[pygame] looking for pep8 fixing tools! :-)
I found this one which seems to check if our code is 100% PEP8 compatible, it seems to be useful! http://svn.browsershots.org/trunk/devtools/pep8/pep8.py But of course, a PEP8 fixer would be awesome as well (specially for people like me! :-) ) All information alike you may know, please let me (us) know! :-)
Re: [pygame] how hexcolour arrays works?
thanks for all as well, Dr0id! :-) - On Mon, Jul 28, 2008 at 12:59 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: > Noah, i also agree completelly each person works differently, of > course! :-) (maybe that's why i got concerned about politeness on > pasting code here, which i didn't know how far is it needed or not...) > - you may be from the academic world, and i'm hobbyst, academically > from graphic design area (and still with some bad habits from the > ansi-basic 80's coding...) > > When compaired with Perl, Ruby and Java, Python for me is maybe the > very best language i found - it's clean, and also works fine as script > language on Gimp, Inkscape, Blender, Scribus, etc., what is truly > awesome for me... - and as well, Python came installed on all Linux > and MacOS-X, what is awesome as well... > > what made me becoming so surprised with Python is i could code there > in the same way i used to code on sdlBasic and wxBasic, and these > codes worked fine! :-) - you know, a mere graphic designer with a > hobbyst taste about coding, being able to code scripts for Gimp and so > on (the python version of the .ai importer from Inkscape is mine, as > well the Gnome menu converter for Fluxbox, for example... :-p ), even > some small converters... why i shoutd stop coding on Python, you > know... ? > > thanks! :-) > > > > On Mon, Jul 28, 2008 at 12:38 PM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: >> Paulo Silva wrote: >>> >>> Stop right now? oh please, just now when i were getting so happy on >>> trying to learn it? what a stimulation from the open-source world... >>> :-(( >>> >>> (i really wanted only to focus in the solutions of doubts like mine >>> one...) >> >> If Python doesn't match the way you work, I doubt you will enjoy it. Not >> every tool is right for every job, and each person works differently. Thats >> all. >> >> --Noah >> >> >
Re: [pygame] how hexcolour arrays works?
Noah, i also agree completelly each person works differently, of course! :-) (maybe that's why i got concerned about politeness on pasting code here, which i didn't know how far is it needed or not...) - you may be from the academic world, and i'm hobbyst, academically from graphic design area (and still with some bad habits from the ansi-basic 80's coding...) When compaired with Perl, Ruby and Java, Python for me is maybe the very best language i found - it's clean, and also works fine as script language on Gimp, Inkscape, Blender, Scribus, etc., what is truly awesome for me... - and as well, Python came installed on all Linux and MacOS-X, what is awesome as well... what made me becoming so surprised with Python is i could code there in the same way i used to code on sdlBasic and wxBasic, and these codes worked fine! :-) - you know, a mere graphic designer with a hobbyst taste about coding, being able to code scripts for Gimp and so on (the python version of the .ai importer from Inkscape is mine, as well the Gnome menu converter for Fluxbox, for example... :-p ), even some small converters... why i shoutd stop coding on Python, you know... ? thanks! :-) On Mon, Jul 28, 2008 at 12:38 PM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: > Paulo Silva wrote: >> >> Stop right now? oh please, just now when i were getting so happy on >> trying to learn it? what a stimulation from the open-source world... >> :-(( >> >> (i really wanted only to focus in the solutions of doubts like mine >> one...) > > If Python doesn't match the way you work, I doubt you will enjoy it. Not > every tool is right for every job, and each person works differently. Thats > all. > > --Noah > >
Re: [pygame] how hexcolour arrays works?
hi again Paulo Silva schrieb: Dr0id, thanks! your code resulted as i wanted, but... ::> This 'a = []*8 ' does not what you expect. See documentation. which documentation? where? ::> a = [0x883746, 0xA88721, 0xBDE87A, 0xEE875F, 0xFE98A1, 0x334836, 0x374838, 0xAAB398] Is it the only way for defining numeral (float and integer) arrays in python? What i wanted is: . define the size of the array before using it - just like 'dim a[8]' works on sdlBasic, and 'a_st=[""]*8' works so fine with strings on Python . being able to put values inside the array when and where i want, just like a[5]=0x403304 # you cannot say how many entries the list will have at creation, just create a empty list and add the values li = [] # if the values are know in the beginning: li = [vlaue1, value2, ...] # some code li.append( value1) # some code li.insert(pos, value2) # pos is the possition in the list What type vlaue1 and value2 are is not important, so value1 could be an int, value2 could be a string or a float or whatever and yes, python is alot about readbility, so please dont use ';' here the guidelines: http://www.python.org/dev/peps/pep-0008/ (it will you take some effort and time to master all guidelines, but I think it is worth it ) scrolling doesnt hurt, if you dont see enough use an editor with splitted windows. ~DR0ID
Re: [pygame] how hexcolour arrays works?
Paulo Silva wrote: Stop right now? oh please, just now when i were getting so happy on trying to learn it? what a stimulation from the open-source world... :-(( (i really wanted only to focus in the solutions of doubts like mine one...) If Python doesn't match the way you work, I doubt you will enjoy it. Not every tool is right for every job, and each person works differently. Thats all. --Noah signature.asc Description: OpenPGP digital signature
Re: [pygame] how hexcolour arrays works?
Stop right now? oh please, just now when i were getting so happy on trying to learn it? what a stimulation from the open-source world... :-(( (i really wanted only to focus in the solutions of doubts like mine one...) - > Stop using Python right now. The whole idea of the language revolves around > readability. --- On Mon, Jul 28, 2008 at 12:30 PM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: > Paulo Silva wrote: >> >> thanks Noah! >> >> ::> There, isn't that easier to read? >> >> it's easier to read on small codes like this, but when the code gets >> larger, surelly you need to use the scrollbar like working out in a >> gym... >> >> for me is very important being able to see around 5 'def' contents on >> the screen without having to scroll (well, i must confess i have an >> awful memory, maybe i'm getting too old...), but if the problem is >> politeness from me, of course i can clean the code before posting... > > Stop using Python right now. The whole idea of the language revolves around > readability. > > --Noah > >
Re: [pygame] how hexcolour arrays works?
Paulo Silva wrote: thanks Noah! ::> There, isn't that easier to read? it's easier to read on small codes like this, but when the code gets larger, surelly you need to use the scrollbar like working out in a gym... for me is very important being able to see around 5 'def' contents on the screen without having to scroll (well, i must confess i have an awful memory, maybe i'm getting too old...), but if the problem is politeness from me, of course i can clean the code before posting... Stop using Python right now. The whole idea of the language revolves around readability. --Noah signature.asc Description: OpenPGP digital signature
Re: [pygame] how hexcolour arrays works?
Paulo Silva wrote: Dr0id, thanks! your code resulted as i wanted, but... ::> This 'a = []*8 ' does not what you expect. See documentation. which documentation? where? ::> a = [0x883746, 0xA88721, 0xBDE87A, 0xEE875F, 0xFE98A1, 0x334836, 0x374838, 0xAAB398] Is it the only way for defining numeral (float and integer) arrays in python? What i wanted is: . define the size of the array before using it - just like 'dim a[8]' works on sdlBasic, and 'a_st=[""]*8' works so fine with strings on Python . being able to put values inside the array when and where i want, just like a[5]=0x403304 Don't do that. It is hard to edit and error prone. ::> http://www.diveintopython.org/native_data_types/lists.html It's exactly what i want to avoid... this example is only about strings (and i'm looking for numerals like integer and float examples), and are mostly about array concatenation, what i'm really avoiding now... Lists don't care what values you put in them, its all the same. --Noah signature.asc Description: OpenPGP digital signature
Re: [pygame] how hexcolour arrays works?
thanks Noah! ::> There, isn't that easier to read? it's easier to read on small codes like this, but when the code gets larger, surelly you need to use the scrollbar like working out in a gym... for me is very important being able to see around 5 'def' contents on the screen without having to scroll (well, i must confess i have an awful memory, maybe i'm getting too old...), but if the problem is politeness from me, of course i can clean the code before posting... thanks and sorry about everything! :-) - On Mon, Jul 28, 2008 at 12:25 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: > Dr0id, thanks! your code resulted as i wanted, but... > > ::> This 'a = []*8 ' does not what you expect. See documentation. > > which documentation? where? > > > > ::> a = [0x883746, 0xA88721, 0xBDE87A, 0xEE875F, 0xFE98A1, 0x334836, > 0x374838, 0xAAB398] > > Is it the only way for defining numeral (float and integer) arrays in python? > What i wanted is: > . define the size of the array before using it - just like 'dim a[8]' > works on sdlBasic, and 'a_st=[""]*8' works so fine with strings on > Python > . being able to put values inside the array when and where i want, > just like a[5]=0x403304 > > > > ::> http://www.diveintopython.org/native_data_types/lists.html > > It's exactly what i want to avoid... this example is only about > strings (and i'm looking for numerals like integer and float > examples), and are mostly about array concatenation, what i'm really > avoiding now... > > thanks again! :-) > > --- > > > On Mon, Jul 28, 2008 at 12:12 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: >> running python as direct mode also provides me the same error? >> >> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) >> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. > a=[]*8 > a[0]=0xFF >> Traceback (most recent call last): >> File "", line 1, in >> IndexError: list assignment index out of range > >> >> >> >> >> >> On Mon, Jul 28, 2008 at 12:03 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: >>> thanks, but i found nothing there... :-( >>> >>> >>> >>> On Mon, Jul 28, 2008 at 11:56 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: Paulo Silva wrote: > > Hi, i'm having problems on defining a hexcolour array - weird is i > never have this kind of problem when defining a string array in the > same way... > This may look as a very naive mistake, but i got really stuck, since > even from google searches i can't get any help... > Thanks a lot in advance... :-) http://diveintopython.org/native_data_types/lists.html --Noah >>> >> >
Re: [pygame] how hexcolour arrays works?
Dr0id, thanks! your code resulted as i wanted, but... ::> This 'a = []*8 ' does not what you expect. See documentation. which documentation? where? ::> a = [0x883746, 0xA88721, 0xBDE87A, 0xEE875F, 0xFE98A1, 0x334836, 0x374838, 0xAAB398] Is it the only way for defining numeral (float and integer) arrays in python? What i wanted is: . define the size of the array before using it - just like 'dim a[8]' works on sdlBasic, and 'a_st=[""]*8' works so fine with strings on Python . being able to put values inside the array when and where i want, just like a[5]=0x403304 ::> http://www.diveintopython.org/native_data_types/lists.html It's exactly what i want to avoid... this example is only about strings (and i'm looking for numerals like integer and float examples), and are mostly about array concatenation, what i'm really avoiding now... thanks again! :-) --- On Mon, Jul 28, 2008 at 12:12 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: > running python as direct mode also provides me the same error? > > Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. a=[]*8 a[0]=0xFF > Traceback (most recent call last): > File "", line 1, in > IndexError: list assignment index out of range > > > > > > On Mon, Jul 28, 2008 at 12:03 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: >> thanks, but i found nothing there... :-( >> >> >> >> On Mon, Jul 28, 2008 at 11:56 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: >>> Paulo Silva wrote: Hi, i'm having problems on defining a hexcolour array - weird is i never have this kind of problem when defining a string array in the same way... This may look as a very naive mistake, but i got really stuck, since even from google searches i can't get any help... Thanks a lot in advance... :-) >>> >>> http://diveintopython.org/native_data_types/lists.html >>> >>> --Noah >>> >>> >> >
Re: [pygame] how hexcolour arrays works?
running python as direct mode also provides me the same error? Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a=[]*8 >>> a[0]=0xFF Traceback (most recent call last): File "", line 1, in IndexError: list assignment index out of range >>> On Mon, Jul 28, 2008 at 12:03 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: > thanks, but i found nothing there... :-( > > > > On Mon, Jul 28, 2008 at 11:56 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: >> Paulo Silva wrote: >>> >>> Hi, i'm having problems on defining a hexcolour array - weird is i >>> never have this kind of problem when defining a string array in the >>> same way... >>> This may look as a very naive mistake, but i got really stuck, since >>> even from google searches i can't get any help... >>> Thanks a lot in advance... :-) >> >> http://diveintopython.org/native_data_types/lists.html >> >> --Noah >> >> >
Re: [pygame] how hexcolour arrays works?
Paulo Silva wrote: thanks, but i found nothing there... :-( Annotated and style cleaned up. General note: Never put multiple statements on one line. Just pretend that ; doesn't exist. import random import pygame pygame.init() # a=[]*8 #- same as 'dim a[8]' from sdlBasic? # No, this will just repeat an empty list 8 times, giving you another # empty list a = [None] * 8 # This is valid, but the following version is better a = [ 0x883746, 0xA88721, 0xBDE87A, 0xFE98A1, 0x334836, 0x374838, 0xAAB398, ] screen = pygame.display.set_mode((320,240)) pygame.display.set_caption("move a box") background = pygame.Surface(screen.get_size()).convert() background.fill(random.choice(a)) box = pygame.Surface((25,25)).convert() box.fill(random.choice(a)) box_x=0 box_y=100 clock = pygame.time.Clock() kpg = True while kpg: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT: kpg=False box_x+=5 if box_x > screen.get_width(): box_x=0 screen.blit(bkgd, (0,0)) screen.blit(box, (box_x,box_y)) pygame.display.flip() There, isn't that easier to read? --Noah signature.asc Description: OpenPGP digital signature
Re: [pygame] how hexcolour arrays works?
hi here: http://www.diveintopython.org/native_data_types/lists.html in Section: Example 3.14. List Operators read carefully ;-) ~DR0ID Paulo Silva schrieb: thanks, but i found nothing there... :-( On Mon, Jul 28, 2008 at 11:56 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: Paulo Silva wrote: Hi, i'm having problems on defining a hexcolour array - weird is i never have this kind of problem when defining a string array in the same way... This may look as a very naive mistake, but i got really stuck, since even from google searches i can't get any help... Thanks a lot in advance... :-) http://diveintopython.org/native_data_types/lists.html --Noah
Re: [pygame] how hexcolour arrays works?
Hi First of all, why do you write that many instruction on one line?? This looks much nicer (ok, it gets a bit longer, but clearer to read): import pygame,random pygame.init() a=[]*8 #- same as 'dim a[8]' from sdlBasic? a[0]=0x883746 a[1]=0xA88721 a[2]=0xBDE87A a[3]=0xEE875F #- list assignment index out of range? a[4]=0xFE98A1 a[5]=0x334836 a[6]=0x374838 a[7]=0xAAB398 screen=pygame.display.set_mode((320,240)) bkgd=pygame.Surface(screen.get_size()) bkgd=bkgd.convert() bkgd.fill(a[random.random()*7]) pygame.display.set_caption("move a box") box=pygame.Surface((25,25)) box=box.convert() box.fill(a[random.random()*7]) box_x=0 box_y=100 clock=pygame.time.Clock() kpg=True while kpg: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT:kpg=False box_x+=5 if box_x>screen.get_width():box_x=0 screen.blit(bkgd,(0,0)) screen.blit(box,(box_x,box_y)) pygame.display.flip() #-- This 'a = []*8 ' does not what you expect. See documentation. import pygame,random pygame.init() # nice thing about python, just init the list with the values a = [0x883746, 0xA88721, 0xBDE87A, 0xEE875F, 0xFE98A1, 0x334836, 0x374838, 0xAAB398] screen = pygame.display.set_mode((320,240)) bkgd = pygame.Surface(screen.get_size()) bkgd = bkgd.convert() # might be better to use randint(lower, upper) bkgd.fill(a[random.randint(0,7)]) pygame.display.set_caption("move a box") box = pygame.Surface((25,25)) box = box.convert() # same here, use randint box.fill(a[random.randint(0,7)]) box_x = 0 box_y = 100 clock = pygame.time.Clock() kpg = True while kpg: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT: kpg = False box_x += 5 if box_x>screen.get_width(): box_x = 0 screen.blit(bkgd,(0,0)) screen.blit(box,(box_x, box_y)) pygame.display.flip() Maybe your interested in some more tutorials: http://dr0id.homepage.bluewin.ch/pygame_tutorials.html ~DR0ID Paulo Silva schrieb: Hi, i'm having problems on defining a hexcolour array - weird is i never have this kind of problem when defining a string array in the same way... This may look as a very naive mistake, but i got really stuck, since even from google searches i can't get any help... Thanks a lot in advance... :-) import pygame,random pygame.init() a=[]*8 #- same as 'dim a[8]' from sdlBasic? a[0]=0x883746;a[1]=0xA88721;a[2]=0xBDE87A;a[3]=0xEE875F #- list assignment index out of range? a[4]=0xFE98A1;a[5]=0x334836;a[6]=0x374838;a[7]=0xAAB398 screen=pygame.display.set_mode((320,240));bkgd=pygame.Surface(screen.get_size());bkgd=bkgd.convert();bkgd.fill(a[random.random()*7]) pygame.display.set_caption("move a box") box=pygame.Surface((25,25));box=box.convert();box.fill(a[random.random()*7]) box_x=0;box_y=100;clock=pygame.time.Clock();kpg=True while kpg: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT:kpg=False box_x+=5 if box_x>screen.get_width():box_x=0 screen.blit(bkgd,(0,0));screen.blit(box,(box_x,box_y));pygame.display.flip()
Re: [pygame] how hexcolour arrays works?
thanks, but i found nothing there... :-( On Mon, Jul 28, 2008 at 11:56 AM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote: > Paulo Silva wrote: >> >> Hi, i'm having problems on defining a hexcolour array - weird is i >> never have this kind of problem when defining a string array in the >> same way... >> This may look as a very naive mistake, but i got really stuck, since >> even from google searches i can't get any help... >> Thanks a lot in advance... :-) > > http://diveintopython.org/native_data_types/lists.html > > --Noah > >
Re: [pygame] how hexcolour arrays works?
Paulo Silva wrote: Hi, i'm having problems on defining a hexcolour array - weird is i never have this kind of problem when defining a string array in the same way... This may look as a very naive mistake, but i got really stuck, since even from google searches i can't get any help... Thanks a lot in advance... :-) http://diveintopython.org/native_data_types/lists.html --Noah signature.asc Description: OpenPGP digital signature
[pygame] how hexcolour arrays works?
Hi, i'm having problems on defining a hexcolour array - weird is i never have this kind of problem when defining a string array in the same way... This may look as a very naive mistake, but i got really stuck, since even from google searches i can't get any help... Thanks a lot in advance... :-) import pygame,random pygame.init() a=[]*8 #- same as 'dim a[8]' from sdlBasic? a[0]=0x883746;a[1]=0xA88721;a[2]=0xBDE87A;a[3]=0xEE875F #- list assignment index out of range? a[4]=0xFE98A1;a[5]=0x334836;a[6]=0x374838;a[7]=0xAAB398 screen=pygame.display.set_mode((320,240));bkgd=pygame.Surface(screen.get_size());bkgd=bkgd.convert();bkgd.fill(a[random.random()*7]) pygame.display.set_caption("move a box") box=pygame.Surface((25,25));box=box.convert();box.fill(a[random.random()*7]) box_x=0;box_y=100;clock=pygame.time.Clock();kpg=True while kpg: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT:kpg=False box_x+=5 if box_x>screen.get_width():box_x=0 screen.blit(bkgd,(0,0));screen.blit(box,(box_x,box_y));pygame.display.flip()
Re: [pygame] very easy snippets to start: where from i can get?
thanks! On Mon, Jul 28, 2008 at 4:16 AM, Knapp <[EMAIL PROTECTED]> wrote: > On Mon, Jul 28, 2008 at 1:08 AM, Paulo Silva <[EMAIL PROTECTED]> wrote: > >> about oop, i'm really curious about learning it, but i have to see >> examples (smaller than 1kb, please...) explaining clearly where and >> how the code gets so improved instead as coding them as procedural >> (all of my trying experiences on oop coding were completely >> frustrating up to now...) >> > > In many ways it is just a matter of the subroutines having private > data. And then, taking those routines and using them as a basis for > extended data and routines based of the first ones. > > And this idea too but I don't use it much. > http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming > > -- > Douglas E Knapp > > http://sf-journey-creations.wikispot.org/Front_Page >
[pygame] Re: [OLPC-Games] PyQNet project on Launchpad
Mike C. Fletcher wrote: Hi all, Those of you who were at PyCon in Chicago for the OLPC sprint may remember Phil Hassey's impromptu lecture on how to build a networking API [1]. I've been hacking together a preliminary implementation of something like that API and have just moved the project to Launchpad[2] so that other people can play with the code. It's definitely not finished yet, so if you want to work on something low-level and network-y, feel free to play. A similarly designed (and much smaller) library is also up at https://coderanger.net/svn/school/2007/fall/egd/magnoball/pygamenet.py . Also a WiP. --Noah signature.asc Description: OpenPGP digital signature