Re: [pygame] phpbb forum missing at pygame.org website
On Fri, Jul 25, 2008 at 11:51 AM, James Paige <[EMAIL PROTECTED]> wrote: > The blog-like interface does allow posting. The newsgroup-thread > interface does not. I like the idea of switching from a mailing list to phpBB. There are many great features of bulletin boards: * user icons * getting email notifications for some threads and not others * sticky topics and announcements * easy to moderate if necessary * syntax highlighting for code snippets * uniform interface for html links in messages * ability to upload screenshots and include in messages Apart from the features, I think nowadays people are more comfortable joining a forum than subscribing to a mailing list. -- Nathan Whitehead
Re: [pygame] No pygame.mixer.Sound.get_current()?
On Wed, Jul 30, 2008 at 8:17 PM, Tyler Distad <[EMAIL PROTECTED]> wrote: > ... > Now I guess my original question has changed. I can now find my > position within a track, using your suggestion of > mixer.music.get_pos() (Though the value returned is relative only to > the current seek position, not the start of the file.) Now I'm missing > a get_length() function for mixer.music(). Is this something that can > be added? You might want to check out my latest package, SWMixer. http://pypi.python.org/pypi/SWMixer/ README is at: http://code.google.com/p/pygalaxy/wiki/SWMixer This is an alternative for pygame's sound functions. It has some nice features, such as getting the current position of sounds, resampling audio, etc.. It is also written in 100% Python, so if you want to add your own features it should be simpler than trying to hack SDL and pygame. It doesn't have a streaming music capability at the moment, still working on that. For my own music games I convert everything to WAV files and load them entirely before playing, it works fine. -- Nathan Whitehead
Re: [pygame] Pygame, cwiid and ode - movement
On Thu, Aug 7, 2008 at 2:39 AM, flx <[EMAIL PROTECTED]> wrote: > I'm trying to make a foosball [1] game wth pygame, using the wiimote > to control the bars. > > I've managed to control the rotation using the accelerometers, but i > can't get the sliding part right. I've been asked to use the ir > sensors for the sliding movement, but I just can't get it right. I think you have two separate questions here: * how to get IR working on the wiimote and get IR data * once IR is working, how to interpret the data to make the paddle slide around correctly For the first part: which Wiimote library are you using? Does it support IR? Is it buggy with your particular Wiimote/bluetooth combination? What operating system are you using? For the second part: I recommend making a simple program that just displays squares at the reported IR positions, setting the screen to 1024x768. Then try moving the Wiimote around and take notes about where the squares go. Where do they go when you slide left? What about when you point downwards? Rotate clockwise? Then use those notes to write code to control the paddle directly. You might need some calculations here (argh, math!). Once you've got this down you will have control of the paddle but it will be jerky and flickery. Also when you move too far to the edge of the screen the paddle will stop moving (one IR dot goes off screen). To fix the jerkiness, a first step is averaging several values over time. A better but harder approach is a Kalman filter. To fix the flickery problem: if there are 0 dots reported, use the most recent positions. That stops the input from disappearing for a frame. If there are too many dots (3 or more), then you want to pick the 2 dots closest to the last reported IR positions. To fix the edge-of-the-screen problem, a good approach I've used is to guess where the missing IR dot should be. I assume that the dot off the edge of the screen moves just like the one that remains on the screen. This won't be strictly true if the wiimote is rotating or changing distance to the sensor bar, but it will keep the paddle responding to input rather than stopping abruptly at the edge of the screen. FYI: I'm working on a pygame library that supports the wiimote on all platforms, it will be done Real Soon Now. -- Nathan Whitehead
[pygame] SoundAnalyse
I would like to announce the release of SoundAnalyse, a small python library for analysing sound chunks. In particular it calculates the loudness of a sound chunk and does realtime pitch detection. The pitch detection guts are coded in a C function so it should be pretty fast even on slower computers. Now you can make the singing game you've always dreamed of! (Opera Hero?) Get it at PyPI: http://pypi.python.org/pypi/SoundAnalyse The distribution is a source distribution using distutils, so you need a working C compiler. If someone has a Windows box and sends me a precompiled version for Windows I will add that to the distribution. View the README at: http://code.google.com/p/pygalaxy/wiki/SoundAnalyse Some notes: pygame doesn't support audio input, so you need to use something like pyaudio for microphone input. But you can use pygame for graphics and events along with pyaudio for sound, it works fine. If you want sound playback along with microphone input, try my SWMixer module: http://code.google.com/p/pygalaxy/wiki/SWMixer Give it a try and let me know what you think. -- Nathan Whitehead
Re: [pygame] SoundAnalyse
On Tue, Sep 9, 2008 at 3:31 PM, Ron Dippold <[EMAIL PROTECTED]> wrote: > Neat, I don't currently have an actual use for this right now but will > certainly keep it in mind and I think stuff like this is just > useful/fun/neat on its own existence. Something similar I've always wanted > for pygame is a beat detector, which seems closely related. I'll definitely > take a look. Ooo, a beat detector, I should totally add that. I'll have to look up the algorithms for that. Thanks for the suggestion. -- Nathan Whitehead
Re: [pygame] Display Update Trouble After Focus Loss
On Thu, Sep 11, 2008 at 8:45 AM, Mark S <[EMAIL PROTECTED]> wrote: > I'm having some trouble with the pygame display. While my program is > running it will spend a chunk of time continually animating in a tight loop. > If during this time the window losses focus (I click on another window, for > example) the display will stop updating. The program continues running and > when it reaches the end of the animation loop it will wait for the user to > hit a key, at which point the display with begin updating again. I would try adding pygame.event.pump() calls within the tight animation loop (once per frame maybe). That will allow pygame to process windowing events during the animation. -- Nathan Whitehead
[pygame] AppState-0.1 released
I am proud to announce the release of AppState, a python package for implementing a persistent shared application state. This module allows your Python programs to easily have a persistent global shared state. This state can be used to store things like number of users, game high scores, message of the day from the author, etc. The state has an interface like a dictionary with some additional synchronization functionality and some restrictions. This module connects to a server on the Google App Engine to store and manage data. It uses a simple security model based on Google accounts. Why would you want to use this module? * Quickly add multiplayer features to your Pygame game * Take advantage of Google's efficient and reliable infrastructure (for free!) * Super easy to get started and use * Includes security features Download from PyPI: http://pypi.python.org/pypi/AppState README with more info: http://code.google.com/p/pygalaxy/wiki/AppState Suggestions are welcome. -- Nathan Whitehead
Re: [pygame] AppState-0.1 released
On Thu, Sep 25, 2008 at 12:03 PM, Horst JENS <[EMAIL PROTECTED]> wrote: > sounds interesting. > Do i understand this right: > all players need to have an valid google account to "join" ? > Only the creator of the game will be asked to write his google account > passwort inside python code ? > > > I think about doing a global highscore list for a pygame game with your > code. The creator of the app needs a Google account to register the app with the server. Depending on which security options you select, you can require users to have accounts or not. For example, you might choose to let anyone read high scores, but only people logged in can change the high scores. If that is the security model then your application might start, let the player play the game, and show the existing high scores. If the player gets a new high score, then the app could ask for their google username and password and use that to log in and update the high score table. Alternatively you could turn off the account requirement entirely. That way users would not have to have accounts. The only issue there is that if someone "hacks" your application you can't do anything to stop them. If you require accounts then if someone causes trouble you can ban their account. I should also say that you don't have to hard-code account emails and passwords into the application. They can be stored in a file, or typed every time the program is run, etc. -- Nathan
Re: [pygame] AppState-0.1 released
On Sat, Sep 27, 2008 at 9:04 AM, Horst JENS <[EMAIL PROTECTED]> wrote: > Somehow i would feel uncomfortable if i had to type in my gmail account > password just to upload an highscore - even if it's a open-source app. You don't have to use your gmail account, you can create a new Google Account just for gaming. Just use something like "[EMAIL PROTECTED]" for your email. Then go to mailinator.com to verify the email. Works fine. -- Nathan
[pygame] Game Maker but with Python?
I just saw "100 Game Maker Games", a cool 10 minute video that shows the wide variety of cool games you can make with Game Maker. http://playthisthing.com/100-game-maker-games There should be something like this but with Python and pygame! My friends at UCSC have taught intro programming using Game Maker, and it went well but they were ultimately unhappy with GML (the Game Maker scripting language) as a first programming language. When I taught game programming I went straight for pygame and Python (of course). It worked out pretty well, but the students had to spend quite a bit of time figuring out programming concepts before they could even get a square moving around on the screen. Would you use a graphical tool like Game Maker to make your games if it used pygame and was extensible using Python? Why or why not? What would such a tool have to do to be useful? -- Nathan
Re: [pygame] Game Maker but with Python?
On Wed, Oct 1, 2008 at 5:09 PM, Ron Dippold <[EMAIL PROTECTED]> wrote: ... > It would be nice having a python scriptable Game Maker, but that would be a > huge undertaking - it's 100x more work to write a game maker that requires > no coding than it is to write a single game. But you might take a look at > Game Wizard ( http://www.pygame.org/project/601/ ) I agree, it would be a huge undertaking. As much as I'm tempted to start coding it up, I realize that it would almost certainly never get finished and be a waste of effort. But it's fun to think about! And I really am tempted to code on it. -- Nathan
Re: [pygame] recommendation for a good n00b IDE
On Fri, Oct 3, 2008 at 5:00 PM, Sean Wolfe <[EMAIL PROTECTED]> wrote: > So. . . . any recommendations for a good n00b IDE? I really like IDLE's > stripped down no-frills approach. Also, I need to be able to set a > white-on-black color scheme. . . much easier on the eyes. Emacs is what I use. Works on every platform, customizable to heck. But it's not noob friendly. Still I think it is worth learning. On Mac OS X I liked TextMate (free trial). It worked with pygame and had a nice feel. Very noob friendly. -- Nathan
Re: [pygame] recommendation for a good n00b IDE
On Fri, Oct 3, 2008 at 5:35 PM, pymike <[EMAIL PROTECTED]> wrote: > Geany is similar to SCiTE, but preferences are more easily edited. Geany is > by far the best IDE for Ubuntu (and I've tried a TON) Just tried this, Geany rules! Thanks for mentioning it. Geany also handles pygame hangups nicely, you get a console window that launches your app that you can close cleanly even if your app hangs and takes pygame and python down with it. I like. Next time I teach Python I'm using Geany. -- Nathan
Re: [pygame] Indie Game Host
On Sat, Oct 18, 2008 at 2:56 PM, Matt Kremer <[EMAIL PROTECTED]> wrote: > There were two responses, I'm going to respond to both in this message. > > For one, games are not played in-browser. They are temporarily loaded via > JAVA and then run on the players computer. > > Also, I am not just someone who saw "game" in the list name, and my site > supports any kind of game. JAVA is only used to temporarily store the game > and run it. For instance, someone uploads a .exe in a .zip file (files must > be zipped to upload). JAVA loads this zip, unzips it, and runs the exe. > Nothing on the site is JAVA, they are all exe files. Is there some sort of sandbox for the .exe files? Why won't this be incredibly dangerous? There should be more description on the website. To demonstrate that this is something that might be of interest to pygame programmers, could you upload a python game to show that it works? An example game (not mine), including python source and a Windows .exe file: http://www.pyweek.org/e/midnightsun/ -- Nathan Whitehead
Re: [pygame] Indie Game Host
On Wed, Oct 22, 2008 at 1:15 PM, Matt Kremer <[EMAIL PROTECTED]> wrote: > Okay, it seems that PyGame games do work with http://gmarcade.com, I have > uploaded someone's pong game: > And it works just fine with Play Game Online. It must have just been an > issue with Kite Story. Thank you for trying this and verifying that it works, at least for some python games. Some comments: you should put a progress bar for the download that shows how much has been downloaded and how much remains. In general, I am a bit unclear what the advantage of using the jnlp is. For me at least I still had to click "yes" or "run" or whatever a couple times, just like I do with exe files. I'm not a windows user normally, though, so my system may be horribly out of date and not representative of most users. -- Nathan Whitehead
Re: [pygame] Recording sound
On Wed, Oct 29, 2008 at 10:13 AM, Knapp <[EMAIL PROTECTED]> wrote: > Does anyone know a good way to record sound with python or pygame in > Linux? Something that could work with the mic like skype does? You can use SWMixer, my little sound library for Python based on pyAudio. It can do recording and playback simultaneously if your soundcard supports it (but it is relatively untested). I'm using it for a singing game. The download has a little example that does recording and then playback of the sound recorded, while playing a sound in the background. http://code.google.com/p/pygalaxy/wiki/SWMixer -- Nathan Whitehead
Re: [pygame] Recording sound
On Wed, Oct 29, 2008 at 11:42 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Cool, Nathan. I was thinking about writing a singing game - well > maybe not a game so much as a tool. It plays scales and gives you > your statistical accuracy as far as hitting the correct note (just > based on pitch - also would do intervals etc.) Ah, then you want my SoundAnalyse module. It is C code with a python wrapper for realtime pitch and volume detection. http://code.google.com/p/pygalaxy/wiki/SoundAnalyse I separated it out from SWMixer just because compiling C code as part of the install is harder than installing a pure python package. > I was thinking about also adding support for music... To play notes from python, I use FluidSynth. It uses SF2 soundfont files, then you send it NOTEON events and such to play music. I have a preliminary binding for it, pyFluidSynth. http://code.google.com/p/pygalaxy/wiki/pyFluidSynth > Is your API stable at this point? All the packages and APIs should be relatively stable, but they have not been tested on all architectures by lots of people. Bug reports are encouraged. -- Nathan Whitehead
Re: [pygame] Geany
On Sat, Nov 8, 2008 at 7:37 AM, pymike <[EMAIL PROTECTED]> wrote: > If you've got lots of tabs and 4 spaces mixed together you can either The version of geany I have (0.13) has a menu option "Document"-"Replace Tabs by Spaces" that does this. -- Nathan Whitehead
Re: [pygame] Better Python music playback?
Yeah, the synchronization problem is annoying. That's the main motivation why I wrote swmixer. Take a look at the documentation page, under the section EXPLICIT TICK INTERFACE. http://code.google.com/p/pygalaxy/wiki/SWMixer That section shows how you can calculate chunks of sound and synchronize exactly with the game video framerate. That method works much better for rhythm games where loss of synchronization screws up the whole game. If you try out swmixer and have problems, let me know. -- Nathan On Sun, May 24, 2009 at 10:42 PM, Zack Schilling wrote: > I suppose you're both right. Using just the mixer, I only lose two > abilities: Starting the music from specific points and precise timing > information. > > I can emulate the timing feedback using pygame.time.get_ticks and an offset > when the song starts, but I'll need to work around not being able to start > playing the song at an arbitrary number of milliseconds. I'm making a > rhythm/combat/platformer, so the music and gameplay are closely tied. The > biggest problem with losing the ability to start the music any place is that > there is going to be desynchronization if the player happens to repeatedly > pause the game. > > Each time the player pauses, a few milliseconds will slip by between > pausing/resuming the music and recalculating the tick offset, regardless of > what order I perform the two in. Eventually the music will desynchronize > from the game. Can anyone think of a way to keep the music in sync through > multiple pauses without either: 1.) allowing the music to play while paused > or 2.) restarting the music on unpause. The music has to stop and resume > exactly where it left off or else just the act of pausing affects gameplay. > If the number of milliseconds that I think the song has been playing don't > match the actual number, then the gameplay falls apart. > > Thanks, > > -Zack
Re: [pygame] I'm loving wills book :)
On Thu, Apr 3, 2008 at 12:16 AM, Lamonte(Scheols/Demonic) <[EMAIL PROTECTED]> wrote: > The only pygame book availible to man? > http://www.apress.com/book/view/9781590598726 Hi, might as well introduce myself. I'm Nathan Whitehead, just got my computer science phd. My main research is in security models and certified software, but I also love love love messing about with computer games and python. Currently I'm working on a book on python game programming tentatively titled: **Adventures in Game Programming : Using Python and Pygame to create innovative games quickly** It's based on a class I taught last summer where bright high school kids (many with no programming experience) used macbook pros, pygame, and various controllers including gamepads and wiimotes to create small games. It was an absolute blast, so this summer I'm writing up what we did and expanding it so other people can have the same fun we did. Right now I'm working on adding wiimote support to pygame, in collaboration with Luke Paireepinart, Michael Laforest, and Gary Bishop. The goal is a nice addition to pygame that fits the existing interfaces, is stable and as bug-free as possible, and works on all major platforms with the least amount of hassle. If you know anyone else that I should talk to, or if you are interested in working on this as well, please let me know (email [EMAIL PROTECTED]). The book is designed for people with some programming experience but who are perhaps not python masters. So there's not a review of "what is a loop", but there is a short section on defining classes and inheritance (needed for sprites). A sampling of chapter titles: * Sprites (static image sprites, animations, timing and speed issues, player sprites, keeping track of sprites) * Case Study: Zefferia (the story, Zefflonian invasion, bosses) * Rhythm: Feel the Beat (rhythm game mechanics, recording timing tracks, processing player input, scoring combos) * Case Study: Dance or Die! * Wave the Wiimote (connecting to wiimote, interpreting buttons, accelerometers and gravity, angles) * Track the Wiimote (using the Wiimote IR sensors, target practice, rotation and distance to the screen) * Artificial Intelligence (triggered behavior, finite state machines, pathfinding) If you are interested in helping out with testing code, proofreading chapters, or just giving me advice, please email me at [EMAIL PROTECTED] It will be a while until the finished book is out, but the code should be done in the next couple months and will be freely available under an open source license. Cheers, -- Nathan Whitehead
Re: [pygame] Python and Speed
On Thu, Apr 17, 2008 at 1:47 PM, Devon Scott-Tunkin <[EMAIL PROTECTED]> wrote: > Just out of curiousity as a complete newbie > programmer, would you set out 2d partitioning the > screen in pygame by making say 4 invisible sprites > with rects like say: The way I do binning is to keep track of the bin for each sprite. I have a little function like: def binnum(x, y): return ((x % BINSIZE) * 1000 + (y % BINSIZE)) When each sprite moves, the binnum for the sprite gets updated. To detect whether two sprites are colliding, first check the binnums. If they are in the same bin, start calculating distances. Otherwise just return NO. This isn't 100% accurate since sprites might straddle a bin division line, but that's the general idea. To get full 100% accuracy I do some stuff with keeping lists of bins that need to be checked for each sprite. So the function binnum returns a list instead of just a number. That gives you answers like "did sprite x collide with sprite y?", but the full power of binning is answering questions like "which sprites are colliding with which other sprites?" To answer that question quickly you also need to keep track of which sprites are in which bins from the bin perspective, i.e. given any particular bin you get a list of sprites in that bin. I make "bins" a dictionary with the key being the bin number and the value being the list of sprites that are in the bin. When sprites move, they first remove themselves from their existing bin, update positions, then add themselves to the new bin. I also removed the key in the dictionary for empty bins. To determine which sprites are colliding, you iterate over all the nonempty bins. For each bin, you do the obvious collision test for all possible sprites in the bin. Put all the collisions together for each bin and you get all the collisions. Why is this a speedup? Every time a sprite moves the program now does a little more work, but not much. With the naive algorithm, checking collisions for 100 sprites takes 100*99=9900 collision tests. With binning where you have 9 bins (3x3 grid on screen), you might only have about 11 sprites per bin. That is 11*10 tests per bin, or 9*11*10=990 tests total, a good speedup over 9900 tests! If all 100 sprites huddle together in one spot, the binning won't help and you'll still have 9900 tests plus a small overhead for keeping track of the bins. Binning will be in Chapter 20: "Optimization Techniques" of my forthcoming book "Adventures in Game Programming: Creating innovative games quickly using Python and Pygame". -- Nathan Whitehead
Re: Re: [pygame] Python and Speed
On Fri, Apr 18, 2008 at 9:23 AM, Ian Mallett <[EMAIL PROTECTED]> wrote: > OK, my point here is that if C languages can do it, Python should be able to > too. I think all of this answers my question about why it isn't... You don't have to use C to get fast programs. OCaml is very fast (between C and C++), especially when you start doing interesting things. It comes with an interpreter, a bytecompiler, and an optimizing compiler. Also, there is OCamlSDL, which is the pygame of the OCaml world. http://ocamlsdl.sourceforge.net/ It takes a little bit of brainbending to wrap your mind around the OCaml language, but once you figure it out you can write real programs quickly, and have them be very optimized. I prefer hacking around with pygame and python because you get so much flexibility. You don't have to declare variables, you just use them. You don't have to muck around with makefiles. You can mix different types of data in dictionaries. It is just easier, but the price you pay is performance. In a typed language like OCaml, the compiler might know that every entry in a dictionary is an integer so it can optimize every access. In python, the interpreter has no idea what will come out when you request a key, it could be an integer, a sprite object, None, ... The programming languages community is working feverishly to combine the benefits of typed languages with the ease of use of dynamic languages, but it is an ongoing effort. -- Nathan Whitehead
[pygame] starting sound playback at offset
Is it possible to start sound playback at an offset from the beginning of the sound? I'm working on a simple system for game music that changes with the intensity of the game. The idea is to fade out one track while fading in the new one, matching the beats, as the game intensity changes. To get the beats to match up I need to start the new track at an offset. -- Nathan Whitehead
Re: [pygame] starting sound playback at offset
On Thu, May 8, 2008 at 11:54 PM, Patrick Mullen <[EMAIL PROTECTED]> wrote: > ... A more high tech > solution may be to use a sndarray, but I am completely unfamiliar with how > these array objects can be used exactly. but it may be that you can make an > array, and then slive it from where you want to start, and it will modify > the sound such as to start from where you want. ... > If you do figure out how to "seek" using a sndarray let me know, I'd be > interested in such a thing as well. Thanks for the suggestion to use sndarray, works great. Here's my function: def play_offset(snd, offset): """play a sound starting at a sample offset returns channel new offset sound is playing on """ samps = pygame.sndarray.samples(snd)[offset:] newsnd = pygame.sndarray.make_sound(samps) return newsnd.play() Also, the offset is measured in samples after resampling. If the mixer frequency is 44100, then 44100 samples is one second offset. -- Nathan Whitehead
[pygame] pygame documentation license
I would like to include a quick reference to pygame functions in an appendix of my book. Would it be permissible to use the documentation of pygame for this (reformatted and possibly reorganized)? It appears the documentation is LGPL. The source code of the appendix would appear on the book's website (LaTeX source). The entire book would not be LGPL. Some chapters will appear for free on the website, others will not. I think this would be OK, but I'm not a license expert. Any thoughts? Apart from legalities, would that be appropriate? -- Nathan Whitehead deadpixelpress.com
Re: [pygame] pygame documentation license
On Wed, May 21, 2008 at 5:45 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Not sure how you'd satisfy the requirement to allow > users to upgrade to a new version, though, if it's > something like an index that points to other things > in the book. That's a good point. I wasn't thinking of having references to the main text in the appendix, more just a quick reference to thumb through while you're programming. I guess to update the appendix users could download a new version, print it out, then stuff it in the book ;) More seriously, it would be handy to have a printable version of the pygame documentation, that is useful independent of any book about pygame. Thanks everyone for your replies. My conclusion so far is that the plan for the appendix isn't crazy and I'll go ahead with it until I hear a good argument for why it's not allowed or that it is unreasonable. I'll pass the question along to my lawyer friend and see if he has any new angles on it. -- Nathan Whitehead deadpixelpress.com
Re: [pygame] pygame documentation license
On Wed, May 21, 2008 at 9:33 PM, Brian Fisher <[EMAIL PROTECTED]> wrote: > So what makes you think the documentation is licensed under LGPL? The documentation is included in the pygame release in the directory "docs/". All the information about licensing I have found for pygame is that it is LGPL. The LGPL file itself is in the directory "docs/". I imagine that everyone that checks in changes for pygame understands that their contribution is going to be LGPL, and this includes the documentation files. -- Nathan
[pygame] SWMixer released
I would like to announce the release of SWMixer, an advanced software mixer for sound playback and recording. It is written entirely in python. It uses NumPy array operations for fast performance and PyAudio for audio playback and recording. At the moment it is fairly untested. It works well on my computer using a couple test WAV files I have created. Please test it out to see if it works for you with acceptable performance. PyAudio is cross-platform, so SWMixer should theoretically run on all major platforms. Grab SWMixer at: http://pypi.python.org/pypi/SWMixer The README file explains how it works a bit more and shows some examples of how to use it, including using swmixer with pygame. Look at the README file here: http://code.google.com/p/pygalaxy/wiki/SWMixer Let me know how it goes and what you think. -- Nathan Whitehead