Re: [pygame] Sound not playing at startup

2013-08-30 Thread James Paige
On Fri, Aug 30, 2013 at 7:16 AM, Arthur Sugden arthur.sug...@gmail.comwrote:

 Howdy,

 I'm using pygame.mixer on an embedded project (a Beaglebone Black which is
 similar to a Raspberry Pi). My program works perfectly when run from the
 command line, even from / (i.e. I've correctly put in the links to sound
 files), but when I add the program to rc.local, no sound comes out when I
 start up the board. Can someone help? Do I have to run it as sudo from some
 user space startup file? If so, can you tell me which?

 Thanks much,
 Arthur


I am just taking a wild guess here, but I suspect that ALSA will not yet
have finished initting when rc.local is run.

When I did an embedded project, I started my program using rungetty from
/etc/inittab instead of using rc.local

Install rungetty, and then edit your /etc/inittab so that rungetty will log
in a user automatically on one of the virtual consoles, for example, log
the embedded user in to tty2:

2:2345:respawn:/sbin/rungetty --autologin embedded tty2

Then you can edit /home/embedded/.profile to run your program.

---
James Paige


Re: [pygame] playing sound on Windows

2013-06-27 Thread James Paige
On Thu, Jun 27, 2013 at 08:11:39AM -0700, sarah wrote:
 Hi all,
 I've just subscribed to this list hoping someone can hplease elp me with the
 following problem: I wrote the class bellow (I also attached it) that simply 
 plays a sound
 file when its method play_file() is called. It works on Linux perfectly, but
 on Windows, no sound is played and I do need to find the reason of it.
 Configurations are:
 Windows 7 (32 bits), Python 2.6 and Pygame 1.9.1 (win32). Thank very
 much for any help!
 Sarah Barreto Marques
 
 www.audiogames.com.br
 @sarahbmarques
 
 
 
 
 import sys, pygame
 import time
 
 class Sound:
 pygame.mixer.pre_init(frequency=22050, size=-16, channels=2, buffer=1024)
 
 def play_file(self, name):
 #pygame.mixer.pre_init(frequency=44100, size=-16, channels=2, 
 buffer=1024)
 #pygame.mixer.get_init()
 sound=pygame.mixer.Sound(name)
 
 print 'playing'
 sound.play()
 
 print 'done'
 time.sleep(2)
 return sound
 
 if __name__=='__main__':
 pygame.init()
 sound=Sound()
 som.play_file('0.wav')


did you mean:

  sound.play_file('0.wav')

in the last line? som does not seem to be defined anywhere.

---
James Paige


Re: [pygame] playing sound on Windows

2013-06-27 Thread James Paige
I don't know why this problem is happening, but I can reproduce it.

I tested your script (with my own 0.wav file) and it worked fine on 
Linux, but on Windows 7 (64 bit) with both python 2.6 + pygame 1.9.1 and 
python 2.7 and pygame 1.9.2 there is no sound.

Although this does not solve your problem, I think you should remove the 
pygame.mixer.pre_init() because inside the class but not inside a 
function is definitely the wrong place for it, and even if you move it, 
all it does is change the defaults for pygame.mixer.init() to the same 
values those defaults have already.

You can also add

   print pygame.mixer.get_init()

and it will display the settings with which the mixer was initialized, 
or if mixer init failed entirely it will return None.

When I tested, .get_init() returned (22050, -16, 2) indicating that the 
init succeeded with the default settings.

Before I tested your script on my windows box, I tested my 0.wav file in 
audacity and it sounded fine.

After I tested your script, and the sound failed to play, I tried it 
again in audacity, and then it would not play.

Even though I could not get the .wav file to play anymore either in 
python or in audacity, the windows volume mixer test sound still worked 
find.

Very strange.

On Thu, Jun 27, 2013 at 01:04:12PM -0300, sarah marques wrote:
 Yes, I meant that. Sorry, I translated my code from Portuguese to send
 it to the list, and this word 'som' slipped.
 
 Sarah Barreto Marques
 
 2013/6/27, James Paige b...@hamsterrepublic.com:
  On Thu, Jun 27, 2013 at 08:11:39AM -0700, sarah wrote:
  Hi all,
  I've just subscribed to this list hoping someone can hplease elp me with
  the
  following problem: I wrote the class bellow (I also attached it) that
  simply plays a sound
  file when its method play_file() is called. It works on Linux perfectly,
  but
  on Windows, no sound is played and I do need to find the reason of it.
  Configurations are:
  Windows 7 (32 bits), Python 2.6 and Pygame 1.9.1 (win32). Thank very
  much for any help!
  Sarah Barreto Marques
 
  www.audiogames.com.br
  @sarahbmarques
 
 
 
 
  import sys, pygame
  import time
 
  class Sound:
  pygame.mixer.pre_init(frequency=22050, size=-16, channels=2,
  buffer=1024)
 
  def play_file(self, name):
  #pygame.mixer.pre_init(frequency=44100, size=-16, channels=2,
  buffer=1024)
  #pygame.mixer.get_init()
  sound=pygame.mixer.Sound(name)
 
  print 'playing'
  sound.play()
 
  print 'done'
  time.sleep(2)
  return sound
 
  if __name__=='__main__':
  pygame.init()
  sound=Sound()
  som.play_file('0.wav')
 
 
  did you mean:
 
sound.play_file('0.wav')
 
  in the last line? som does not seem to be defined anywhere.
 
  ---
  James Paige
 
 


Re: [pygame] Using Pygame to capture key presses for CLI prgram?

2013-05-29 Thread James Paige
A couple years ago I was trying to do something very similar. It wasn't 
a raspbery pi, but it was a very small fanless linux box running debian. 
In production, it had no monitor and never ran X. All the output was to 
a serial LCD and all the input was from a barcode scanner that sent 
keypresses as a keyboard.

I tried to use pygame for reading the input, but I finally gave up. 
Without a window, pygame is just the wrong tool for the job.

I finally ended up using python's termios module. Here is a small 
wrapper that I used http://pastebin.com/q9xMVUSb

I also found the timeout module handy in combination with reading raw 
stdin, but whether or not it will be useful for your program I don't know.

---
James Paige

On Wed, May 29, 2013 at 05:05:59PM -0700, winkleink wrote:
 Hi,
 
 I'm running pygame in a raspberry pi.
 The program I am writing has no graphical interface and I am connecting
 using SSH (Putty from a Windows XP computer)
 
 I want to capture a key press (with no graphical interface) and take action.
 Below is my code.  From what I can tell it should work.
 
 Any advice greatly appreciated.
 
 
 
 
 
 --
 View this message in context: 
 http://pygame-users.25799.x6.nabble.com/Using-Pygame-to-capture-key-presses-for-CLI-prgram-tp719.html
 Sent from the pygame-users mailing list archive at Nabble.com.
 


Re: [pygame] spam on cookbook?

2013-05-14 Thread James Paige
That is definitely spam. Many of the wiki pages on pygame.org are still 
plagued with it :(

On Tue, May 14, 2013 at 04:04:39PM -0500, Jake b wrote:
I found strange links on the bottom of the cookbook. It just says
 
http://spam link redacted
--
Jake



Re: [pygame] Ongoing Development

2013-04-16 Thread James Paige
This answer is a matter of opinion, and I am sure other people can offer 
different viewpoints, but for myself, I would suggest focusing on 
pygame1 for any projects you are starting *today* It has a long history 
of being stable, people have made tons of games with it, and by the time 
pygame2 is finished, it is very likely to have a backcompat interface so 
pygame2 will be able to run pygame1 games with a minimum of 
modification.

Maybe later, when pygame2 is a little more mature, it will make sense to 
start with it, but your experience with pygame1 will certainly not be 
wasted when that time comes.

Other opinions welcome :)

---
James Paige

On Tue, Apr 16, 2013 at 08:56:32AM +0100, Andrew Barlow wrote:
Yeah, it'd be great to know the differences between PyGame 1 and 2,
advantages, disadvantages, etc.
 
My big question (besides all the others I've posted ;-) ) is which should
I be using if i'm starting a project, right now?

My Python is pretty sound, just not sure which version of PyGame I should
be learning.
 
On 16 April 2013 00:39, Sean Felipe Wolfe ether@gmail.com wrote:
 
  On Apr 15, 2013 12:55 PM, VinAcius Naves Castanheira
  vncastanhe...@gmail.com wrote:
  
   What's the advantages of this pygame 2?
  
   2013/4/15, m...@sysfault.org m...@sysfault.org:
Paul Vincent Craven p...@cravenfamily.com:
   
I think Pygame 2 is dependent on SDL 2 mostly. It is just a thin
  CTYPE
shell over the SDL 2.0 library. Pygame 2 was last updated in Nov,
  but you
can get an updated SDL DLL from the website for newer code.
   
Yes, Pygame 2 (which really should get another name, since it not
related to Pygame at all anymore)
depends on SDL 2. I'm currently trimming down the SDL 2 wrapper, now
that the SDL 2 API is mostly stable
and hope to have finished it within the next two weeks or so (nag me
regularly ;-).
   
Cheers
Marcus
  
 
  I hope we can bring some of this info onto the website. Maybe I'll make
  some wiki pages ...


Re: [pygame] How to control the physical size of displayed objects?

2013-02-28 Thread James Paige
On Thu, Feb 28, 2013 at 01:28:01PM +0100, Mathieu Dubois wrote:


 Le 27/02/2013 22:33, Julian a écrit :
 On 02/27/2013 04:23 PM, Mathieu Dubois wrote:
 Just a last question: do you think the horizontal and vertical factors
 has to be the same? Because list_modes() tells me that my monitor can
 display: 1280x800 (ratio: 1.6), 1024x768 (ratio: 1.33), 800x600
 (ratio: 1.33), 640x480 (ratio: 1.33).

 You mean dealing with wrong aspect ratios? That's a tough one because
 different drivers handle it differently; some distort the picture, some
 zoom it while maintaining the aspect ratio, some don't zoom it at all. I
 would say that it's best to either assume there is no distortion of
 aspect ratio (i.e. a square is a square), or allow a horizontal
 adjustment that normally syncs with the vertical adjustment.

 I'm not sure to understand the difference between the 2 solutions you  
 suggest but it seems reasonnable to assume that the horizontal and  
 vertical ratios are the same (a square image of say 256x256 pixels will  
 be displayed as a square).

 I will try to code a simple application in order to test.

 Mathieu


Unfortunately, no you cannot assume a square aspect ratio. A widescreen 
monitor could be using a non-widescreen resolution, or vice-versa. There 
is no reliable way to know.

I discovered that The Gimp uses on-screen rulers to calibrate DPI, you 
might want to look at how it is done there. (Edit-Preferences-Display 
and then click the calibrate button)

---
James Paige


Re: [pygame] How to control the physical size of displayed objects?

2013-02-27 Thread James Paige
On Wed, Feb 27, 2013 at 04:08:08PM +0100, Mathieu Dubois wrote:
 Hello,

 I'm working on a program (written by someone else) to use PyGame to  
 display some images for use in a psychological experiment. I am new to  
 PyGame.

 For the experiment we need to display circles of a given physical size  
 (let's that the diameter must be 30mm). Currently the program seems to  
 do the conversion with a hardcoded value.

 I wanted to know if it possible to compute this value automatically.

 If I understand correctly, I need to know the physical size of the  
 screen and the resolution. Knowing the resolution is simple with PyGame  
 but how can I access the screen size?

 The program should be multi-platform.

 Any advice?

 Thanks in advance,
 Mathieu

Sadly, I believe this is nearly impossible to do in a reliable an 
automated way. This is not just for pygame, but any program.

If you need to support monitors that connect with a VGA cable, then I 
believe it is completely impossible. (if someone knows otherwise, please 
correct me!)

If the monitor is identified by the operating system, you can get the 
DPI, but this information can't be trusted. DPI settings are seldom 
guaranteed to be accurate. They might be correct, they might be 
incorrect, they might be intentionally misconfigured to manipulate font 
sizes, or other such ridiculous things.

If you want something simple and cross-platform, I would suggest 
displaying a calibration screen where you can hold a physical ruler up 
to the screen while spinning the mouse wheel until the on-screen ruler 
matches the physical ruler, and then save that constant in a config 
file, or something like that.

(Again, if anybody knows any tricks to do this automatically, please 
speak up and correct me, but I will be shocked if there is a 
single cross-platform way)

---
James


Re: [pygame] How to control the physical size of displayed objects?

2013-02-27 Thread James Paige
On Wed, Feb 27, 2013 at 07:51:57AM -0800, James Paige wrote:
 On Wed, Feb 27, 2013 at 04:08:08PM +0100, Mathieu Dubois wrote:
  Hello,
 
  I'm working on a program (written by someone else) to use PyGame to  
  display some images for use in a psychological experiment. I am new to  
  PyGame.
 
  For the experiment we need to display circles of a given physical size  
  (let's that the diameter must be 30mm). Currently the program seems to  
  do the conversion with a hardcoded value.
 
  I wanted to know if it possible to compute this value automatically.
 
  If I understand correctly, I need to know the physical size of the  
  screen and the resolution. Knowing the resolution is simple with PyGame  
  but how can I access the screen size?
 
  The program should be multi-platform.
 
  Any advice?
 
  Thanks in advance,
  Mathieu
 
 Sadly, I believe this is nearly impossible to do in a reliable an 
 automated way. This is not just for pygame, but any program.
 
 If you need to support monitors that connect with a VGA cable, then I 
 believe it is completely impossible. (if someone knows otherwise, please 
 correct me!)
 
 If the monitor is identified by the operating system, you can get the 
 DPI, but this information can't be trusted. DPI settings are seldom 
 guaranteed to be accurate. They might be correct, they might be 
 incorrect, they might be intentionally misconfigured to manipulate font 
 sizes, or other such ridiculous things.
 
 If you want something simple and cross-platform, I would suggest 
 displaying a calibration screen where you can hold a physical ruler up 
 to the screen while spinning the mouse wheel until the on-screen ruler 
 matches the physical ruler, and then save that constant in a config 
 file, or something like that.
 
 (Again, if anybody knows any tricks to do this automatically, please 
 speak up and correct me, but I will be shocked if there is a 
 single cross-platform way)
 

Oh, one more thought! This question got me curious, and after some 
googling, I saw a nifty suggestion on stackoverflow. In addition to 
displaying a ruler, your calibration screen could also display photos of 
some common coins, since whoever is doing the calibration might have an 
easier time locating a coin than locating a ruler.

---
James


Re: [pygame] Professional games made with Pygame?

2013-02-16 Thread James Paige
I thought that Nelly's Rooftop Garden felt rather polished and 
professional. I think that was a pyweek game.

---
James Paige


On Sat, Feb 16, 2013 at 02:35:24PM -0800, Al Sweigart wrote:
Hi everyone, I'm compiling a list of professional-quality games made using
Pygame. These don't necessarily have to be commercial games, but games
that have a professional level of quality.
 
So far, I have:
 
* Dangerous High School Girls in Trouble
* Frets on Fire
* Metin2
* Galcon
* PyDance
* SolarWolf
* Division Especial de Detectives
Are there any others? Or have I added some games to this list erroneously?
 
-Al


Re: [pygame] Does PyGame 1.9.1 work with Python 3.3.0 on Mac OSX 10.6.8?

2013-02-15 Thread James Paige
On Fri, Feb 15, 2013 at 10:04:16AM -0500, Julian wrote:
 On 02/15/2013 02:18 AM, Mt.Rose$TheFerns wrote:
 Yeah I am quite sure.

 I have 2.7.3 on my comp and it gives me no error at all.

 I don't know anything about Mac OS X, but I don't think you can use the  
 same Pygame installation for two different versions of Python. At least,  
 that's the case for Windows and GNU/Linux.


Yes, that is absolutely correct.
You can have multiple different versions of python installed, and pygame 
must be installed separately for each of them. pygame must be compiled 
to match the version of python you are using, and if the version does 
not match, then python will not be able to import pygame.

That is exactly why the pygame downloads page has so many instalation 
packages for each operating system. Unfortunately it is badly out of 
date, and does not have any packages for python 3.

If you search the mailing list archives you will find links to unoffical 
builds of  pygame for python 3, but I don't remember if anybody has 
linked specifically to python for pygame 3.3 sX


Re: [pygame] Does PyGame 1.9.1 work with Python 3.3.0 on Mac OSX 10.6.8?

2013-02-15 Thread James Paige

On Fri, Feb 15, 2013 at 09:38:42AM -0800, Mt.Rose$TheFerns wrote:
 Gotcha! Now I have to look for unofficial versions Dx.
 
 Wait, but on my office computer (Windows) I got PyGame 1.9.1 to work on
 3.3.0 o.O Unless I did download the 3.3.0 PyGame version. 

Remember that pygame version numbers are different than the version 
number of python that pygame was compiled for.

So what you used on your office windows computer was pygame 1.9.1 
compiled for python 3.3.0

---
James Paige


Re: [pygame] Pygame 1.9.2 source?

2012-10-09 Thread James Paige
On Tue, Oct 09, 2012 at 08:19:48AM -0700, James Paige wrote:
 On Tue, Oct 09, 2012 at 11:17:02AM -0400, Ryan Hope wrote:
  Where does the source for the pygame 1.9.2 builds come from? All I can
  find is 1.9.1 source which is over 3 years old.
 
 Wow. I was going to confidently point out where to find the link to it, 
 but the main pygame.org has a link on the left labelled Mercurial 
 which leads to a page named cvs which talks about Subversion :)
 
 It is in version control *somewhere* :)

I fixed that wiki page. The instructions are here: 
https://bitbucket.org/pygame/pygame/wiki/VersionControl

but the short version is that you run:

   hg clone https://bitbucket.org/pygame/pygame




Re: [pygame] Importing Graphics

2012-10-07 Thread James Paige
On Sat, Oct 06, 2012 at 03:13:01AM -0700, shane wrote:
 Hi 
 
 thanks for all the imput, kinda browsed through the beginnings and its
 reasonably straight forward if you creating simple games such as hangman etc
 - just need to get to grips with the different meanings - and do a lot of
 practice
 
 but i see the graphics are very basic so how does one do decent graphics -
 im not talking quake quality but something a bit more believable - like lets
 say Simcity - and can graphics  from shareware etc be imported

If you want to learn to draw your own graphics, I suggest googling for 
game art tutorials or pixel art tutorials. There are an abundance of 
good tutorials out there, and lots of gree graphics-making tools.

As for importing graphics from other games, don't unless the game 
explicitly says the graphics are free to use. A much safer bet is to 
start at http://opengameart.org/ where virtually everything is designed 
to allow re-use.

---
James Paige


Re: [pygame] newbie who is lost asking for rescue party

2012-10-05 Thread James Paige
But for a beginner, just learning python, it really doesn't matter 
very much which version you use.

The really important part is that your python version has to match your 
pygame version.

I am pretty sure that the vast majority of tutorials will work exactly 
the same in 2.7 and 3.x

---
James Paige

On Thu, Oct 04, 2012 at 11:04:52AM -0700, SHANE VAN STRAATEN wrote:
Hi
 
thanks for the advice but i was told to stay away from version python
3.2.3
as python-2.7.3 exe as this version is more supported and has more
libraries to use but as i am newbie i dont know and not looking to make
hot game just to learn
with easy tasks first so as you wne t through what i ahve to still learn
what would you do
 
Shane
 
From: Al Sweigart a...@inventwithpython.com
To: pygame-users@seul.org
Sent: Thursday, October 4, 2012 1:20 AM
Subject: Re: [pygame] newbie who is lost asking for rescue party
I'm assuming you have Windows. If you have a 64-bit machine, download this
file: http://www.python.org/ftp/python/3.2.3/python-3.2.3.amd64.msi
 
If you have a 32-bit machine, download this file:
http://www.python.org/ftp/python/3.2.3/python-3.2.3.msi
 
If you don't know, go to Start  Control Panel  System, look at System
type and it will say 64-bit or 32-bit.
 
Run this .msi file and jut click Next a whole bunch until it finishes.
(All the defaults are fine.)
 
Then download this file for Pygame:
http://pygame.org/ftp/pygame-1.9.2a0.win32-py3.2.msi
 
Run this .msi file, all the default options are fine.
 
This should install Python and Pygame.
 
-Al
 
On Wed, Oct 3, 2012 at 4:08 PM, Owen Rexian outrex...@gmail.com wrote:
 
  Not 100% sure what the problem is...
  So you have downloaded the binary, opened it up, and then what?
 
  On 4 October 2012 00:05, shane shanevansh...@yahoo.com wrote:
 
Hi
 
totaly a newbie in every sense
 
was told to download 2.7 version but even when i go to instruction
page i
get lost again please some help
 
i downloaded python-2.7.3 exe (15.5mb) what else do i need and where
di i
get it because there is a heck of a lot of files that i dont know what
they
mean or their purpose and it also talks of no scource code?
 
 *Windows Binary Installer*
This is probably the most popular method of installation. If you are
running
on windows, it is highly recommended you use this form of installing.
The
installers come with with nearly everything you need, and have an easy
point
and click installers.
The first thing you will need is an installation of Python. Python
binary
installers make it easy to get this done. Pygame binaries usually come
for
the latest 2 releases of Python, so you'll want to be fairly up to
date.
Once that is in place, you want to download the appropriate windows
binary.
From the pygame downloads page you can find the .EXE file you need.
This
will automatically install all of pygame and all the SDL dependencies.
The
windows binaries have filenames like this;
http://www3.telus.net/len_l/pygame-1.8.0release.win32-py2.5.msi;.
This
would be the installer for pygame version 1.8.0, for Python version
2.5. You
shouldn't have trouble finding the correct binary from the Windows
section
of the download page. http://www.pygame.org/download.shtml.
You will also probably want to install the windows documentation and
installation package. This will add easy links to the different
documentation and games that come with pygame. The installer for this
is
found next to the other windows binary downloads. The filename looks
like
this; pygame-docs-1.8.0.exe. And this would install the
documentation and
examples for pygame-1.8.0
One other thing the windows binaries are missing is the Numeric or
numpy
Python packages. You can easily install this separately and it will
allow
you to use the pygame surfarray module. This module is optional, so
there
is no need to do this. There are binary installers from the Numeric
download
page. http://sourceforge.net/project/showfiles.php?group_id=1369. A
Numeric
for Windows python 2.5 can be found on the download page:
http://www.pygame.org/download.shtml.
Numpy is newer than Numeric, so you should probably use that...
however both
are not entirely compatible. Instead of numpy you can also use
PixelArray,
which is built into pygame
 
--
View this message in context:

 http://pygame-users.25799.n6.nabble.com/newbie-who

Re: [pygame] Problems with reading joystick axis values

2012-08-14 Thread James Paige
I am pretty sure you need to pump the event queue.

http://www.pygame.org/docs/ref/event.html#pygame.event.pump

---
James Paige

On Tue, Aug 14, 2012 at 01:41:13PM -0700, Franky wrote:
 Hello!
 
 I have been playing around with joysticks in pygame a little bit.
 This is my most recent testing code:
 
 code
 /import pygame
 import time
 
 pygame.init()
 pygame.joystick.init()
 
 joystick=pygame.joystick.Joystick(0)
 joystick.init()
 
 print(joystick.get_name() + found)
 
 axis_old=2
 
 while 1:
 axis=joystick.get_axis(0)
 if axis != axis_old:
 print(axis)
 axis_old=axis
 time.sleep(1)/
 /code
 
 It should print the name of the joystick, read the values of axis 0 (i have
 tried all other axes too) and print it every second.
 
 It prints out this:
 Logitech Logitech Attack 3 found
 SDL_JoystickGetAxis value:0:
 0.0
 SDL_JoystickGetAxis value:0:
 SDL_JoystickGetAxis value:0:
 SDL_JoystickGetAxis value:0:
 SDL_JoystickGetAxis value:0:
 
 so it finds the correct stick (I also tried it with another one, no
 problem), but it always reads 0, no matter how I move the axes. It also
 prints SDL_JoystickGetAxis value:0: every time it reads from the joystick,
 but as far as i know that's a known bug and already fixed in the newest dev
 releases. But why does it always read 0?
 
 The joysticks I have tested this with are both in working condition. I'm
 using Ubuntu 12.04.
 
 Thanks for your help in advance!
 Daniel
 
 
 
 
 --
 View this message in context: 
 http://pygame-users.25799.n6.nabble.com/Problems-with-reading-joystick-axis-values-tp127.html
 Sent from the pygame-users mailing list archive at Nabble.com.
 


Re: [pygame] Monospaced fonts are meant to be mono-spaced, right?

2012-05-14 Thread James Paige
 I've given up on using SysFont because the results are
 too unpredictable cross-platform. I always bundle my
 own fonts with my games and use Font to load them
 explicitly.

YES! This, this, a thousand times THIS!

---
James paige


Re: [pygame] How to close audio file?

2012-03-23 Thread James Paige
Maybe my memory is fuzzy from so much time spent on Linux, but I thought 
Windows only locked files that you have open for writing. Shouldn't it 
not be locking a file that is only open for read?

Is it possible that mixer.music.load() is opening the music file in the 
wrong mode?

---
James Paige

On Fri, Mar 23, 2012 at 03:27:38PM +, Russell Jones wrote:
Not tested, but try getting a file object and using that instead, e.g.
f=open('myfile.wav')
pygame.mixer.music.load(f)
...
pygame.mixer.music.stop()
f.close()
 
Russell
 
On 21 March 2012 01:13, kfank kurtbutfr...@gmail.com wrote:
 
  I'm using pygame to play a wav file using the mixer.music module, but
  after completion the file remains locked.A  For example,
 
  import pygame
  pygame.mixer.init(44100, -16, 2, 1024)
  clock = pygame.time.Clock()
  pygame.mixer.music.load('myfile.wav')
  pygame.mixer.music.play(1)
  ...
  # wait until completion
  ...
  pygame.mixer.music.stop()
 
  At this point the file is still locked by the process. How do you close
  the file handle which was opened by the load command?


Re: [pygame] Making Games with Python Pygame free book

2012-03-19 Thread James Paige
Red-Green-Blue is for additive color (light)

Red-Blue-Yellow and Cyan-Magenta-Yellow are for subtractive color 
(paint, ink, etc)

On Mon, Mar 19, 2012 at 06:15:15PM +0100, Nick Arnoeyts wrote:
You're probably talking about something else, but isn't it supposed to be
Red-Green-Blue and not Red-Blue-Yellow?
 
Op 19 maart 2012 17:10 schreef Ian Mallett geometr...@gmail.com het
volgende:
 
  On Mon, Mar 19, 2012 at 9:49 AM, Russell Jones russell.jo...@gmail.com
  wrote:
 
Great news :) I liked IYOCGwP and have mentioned it here before now.
BTW, on page 34 of the new book you write (Red, blue, and yellow are
the primary colors for paints and pigments, but the computer monitor
uses light, not paint.)
The primary colours for pigment and paint are cyan, yellow and
magenta, no?
Russell
 
  There is a color space that defines all possible colors.  Primary
  colors are the colors we choose as basis vectors.  Both red-blue-yellow
  and cyan-magenta-yellow are valid basis vectors; the former more often
  used in painting, the latter more often used in printing.
  Ian 


Re: [pygame] Re: pygame sdl_image png/jpeg support

2012-02-14 Thread James Paige
He did already :)

 ORIGLIBDIRS=/lib:/lib/`uname -i`-linux-gnu:/lib64:/X11R6/lib \
     python setup.py build

the first line puts the lib location for your system into the 
ORIGLIBDIRS environment variable. Then when you run setup.py in the 
second line, setup.py knows to automatically search the locations listed 
in ORIGLIBDIRS

---
James

On Tue, Feb 14, 2012 at 08:51:30AM -0800, AntCox wrote:
 Hi Chris,
 Thanks a lot for your response. I think I understand what you're
 saying, that the png (or jpeg in your case) libs were installed
 somewhere the setup script is not looking for them. However I am not
 sure how to determine if this is my problem, and then how to fix it.
 Are you able to give me and pointers on that front?
 Ant
 
 On Feb 14, 5:28 pm, Christopher Arndt ch...@chrisarndt.de wrote:
  On 14.02.2012 17:05, AntCox wrote:
 
   I am trying to build pygame and during the dependency check it is only
   missing PNG and JPEG support [...]
   SDL_image is installed with both png and jpg support libpng and libjpg
   and respective -dev libraries are also installed. [...]
   I am running this on ubuntu 11.04
 
  I had the same pronlem a few weeks ago. Search the mailing list for the
  thread titled Compiling pygame on Ubuntu 11.10 oneiric JPGE [sic!] not
  found
 
  Here's my solution form the last post in the thread:
 
  For the record: here's a command line to compile pygame from a pristine
  hg checkout that works on Linux systems, which use this new scheme to
  install libraries:
 
  ORIGLIBDIRS=/lib:/lib/`uname -i`-linux-gnu:/lib64:/X11R6/lib \
      python setup.py build
 
  
 
  Chris
 


Re: [pygame] Re: pygame sdl_image png/jpeg support

2012-02-14 Thread James Paige
I haven't tested this myself, but I am pretty sure that 

ORIGLIBDIRS=/lib:/lib/`uname -i`-linux-gnu:/lib64:/X11R6/lib

will be correct for your system. Have you tried it yet? I don't think 
you will need to manually hunt down the locations of the libs.

---
James

On Tue, Feb 14, 2012 at 09:12:37AM -0800, AntCox wrote:
 Thank you James. When I work out where the correct libs have been
 installed should those locations be appended to the string assigned to
 ORIGLIBDIRS or just replace what Chris has in there?
 
 On Feb 14, 6:01 pm, James Paige b...@hamsterrepublic.com wrote:
  He did already :)
 
   ORIGLIBDIRS=/lib:/lib/`uname -i`-linux-gnu:/lib64:/X11R6/lib \
   python setup.py build
 
  the first line puts the lib location for your system into the
  ORIGLIBDIRS environment variable. Then when you run setup.py in the
  second line, setup.py knows to automatically search the locations listed
  in ORIGLIBDIRS
 
  ---
  James
 
 
 
 
 
 
 
  On Tue, Feb 14, 2012 at 08:51:30AM -0800, AntCox wrote:
   Hi Chris,
   Thanks a lot for your response. I think I understand what you're
   saying, that the png (or jpeg in your case) libs were installed
   somewhere the setup script is not looking for them. However I am not
   sure how to determine if this is my problem, and then how to fix it.
   Are you able to give me and pointers on that front?
   Ant
 
   On Feb 14, 5:28 pm, Christopher Arndt ch...@chrisarndt.de wrote:
On 14.02.2012 17:05, AntCox wrote:
 
 I am trying to build pygame and during the dependency check it is only
 missing PNG and JPEG support [...]
 SDL_image is installed with both png and jpg support libpng and libjpg
 and respective -dev libraries are also installed. [...]
 I am running this on ubuntu 11.04
 
I had the same pronlem a few weeks ago. Search the mailing list for the
thread titled Compiling pygame on Ubuntu 11.10 oneiric JPGE [sic!] not
found
 
Here's my solution form the last post in the thread:
 
For the record: here's a command line to compile pygame from a pristine
hg checkout that works on Linux systems, which use this new scheme to
install libraries:
 
ORIGLIBDIRS=/lib:/lib/`uname -i`-linux-gnu:/lib64:/X11R6/lib \
python setup.py build
 

 
Chris
 


Re: [pygame] Pygame 2.0

2012-02-13 Thread James Paige
On Mon, Feb 13, 2012 at 05:57:46PM -0800, Keith Nemitz wrote:
 
 I'm happy with the 1.9.2 designation. Though, we all owe a lot of respect to 
 those who added cool new features to pygame. 
 
 It'd be nice to sync up pygame with sdl 2.0.  But that's just the romantic in 
 me.

If the next major release of pygame is ready and SDL 2.0 is not out yet, 
we should be calling it pygame 1.10.0

(but hopefully SDL 2.0 WILL be out by then)

---
James Paige


Re: [pygame] SDL 1.2.15 win32 binary is now available

2012-01-30 Thread James Paige
I am not aware of any good reason why pygame would require python2.6
I have been using pygame with python 2.7 for a long time now, and I have 
not encountered any problems.

---
James Paige

On Mon, Jan 30, 2012 at 10:10:45PM +0100, Florian Krause wrote:
 Good, because I would really like to suggest my users to switch to
 Python 2.7 on Windows as well. Pygame is the only package that holds
 us back. Right now, we tell them to stay at 2.6 anywhere, which is
 difficult in Ubuntu etc. were the official packages are 2.7 (which
 makes sense also).
 Strange, that Pygame was compile for 2.7 for Linux, but not for Windows.
 
 On Mon, Jan 30, 2012 at 9:25 PM, Zack Baker zbaker1...@gmail.com wrote:
  We can only go so far in 1.x right, is 2.0 somewhere on the horizon? With 
  Mac 3.x support?
 
  -Zack
 
 
  On Jan 30, 2012, at 1:47 PM, Lenard Lindstrom le...@telus.net wrote:
 
  This will help. Everything needed for proper alpha testing on Windows is 
  in place. In fact, with the number of Windows installer downloads from 
  bitbucket so far, it has already started.
 
  For me, I want to get the pygame.freetype module out into the wild. The 
  latest Pygame in the repository allows pygame.font to be implemented with 
  pygame.freetype (look, no SDL_ttf). Just set the PYGAME_FREETYPE 
  environment variable to some value. I will update the win32 installers 
  shortly.
 
  I don't know how close the other developers are to reaching their goals, 
  so cannot say how close the 1.9.2 release is. But I don't see any major 
  delays.
 
  Lenard Lindstrom
 
 
  On 30/01/12 01:10 AM, Florian Krause wrote:
  Does that mean that there will finally be a Pygame 1.9.2 release?
 
 
 
  On Mon, Jan 30, 2012 at 5:42 AM, Lenard Lindstromle...@telus.net  wrote:
  Hi,
 
  The SDL 1.2.15 DLL is now available on the Pygame download page at
  https://bitbucket.org/pygame/pygame
 
  61af5d020e14fc27bcc49969371344e5 *SDL-1.2.15-msvcr90-win32.zip
 
  Lenard Lindstrom
 
 
 
 
 
 
 
 -- 
 www.fladd.de - fladd.de: Homepage of Florian Krause
 blog.fladd.de - fladd's Blog: Blog of Florian Krause
 intermezzo.fladd.de - Intermezzo: Music by Florian Krause and Giacomo Novembre
 


Re: [pygame] Pygame subset for Android

2012-01-27 Thread James Paige
On Fri, Jan 27, 2012 at 09:27:20PM +0100, Nathan Biagini wrote:
 Hi guys,
 
 i love developing little games with Pygame and recently heard about a
 way to port your games on Android devices with Pygame subset for
 Android.
 So, i'd like to ask if there are some of you who have already tested
 it? Does it works well? etc...
 
 Thanks.

I have used it, and it worked very well. I found that I had to work very 
hard on performance optimizing my games to work with PGS4A, but that is 
not a fault of PGS4A, that is the simple fact that android phones and 
tablets have less processor power than PCs, so I have to be more careful 
about performance.

If you want an example of a pygame game that was ported to android using 
PGS4A, search the android market for Stegavorto

---
James Paige


Re: [pygame] Beginner Question

2012-01-09 Thread James Paige
On Mon, Jan 09, 2012 at 06:00:49PM -0800, Lenard Lindstrom wrote:
 On 09/01/12 01:03 PM, Nick Arnoeyts wrote:
 Btw, a little bit off-topic, but is it possible to build Pygame with  
 MinGW? I'm using the latest GCC 4.6 on Windows, to clarify.

 Yes, Pygame builds with MinGW GCC 4.6.1-1. But there are problems with  
 the dependency DLLs, specifically smpeg. This is written in C++ and so  
 has special startup and shutdown requirements. It either causes Python  
 is shut down in an unusual way or causes a segfault. Since it is used  
 by SDL_mixer for mp3 support, smpeg is kind of indispensable. However,  
 you can get an earlier version of the prebuilt dependencies at my Pygame  
 page, http://www3.telus.net/len_l/pygame . They were built with GCC  
 4.5.0, so I hope they will also work with GCC 4.6 (or we may have a  
 problem).

 Lenard Lindstrom

Doesn't SDL_mixer allow the use of libmad as an alternative to smpeg?

---
James Paige


Re: [pygame] dmg files vs .zip files on OSX?

2011-12-29 Thread James Paige
On Thu, Dec 29, 2011 at 08:34:33AM +0100, René Dudfield wrote:
Hi,
 
it seemed pip used to mistake all .zip files for being source packages,
and got confused by our .mpkg.zip binaries for OSX.  That has been patched
in pip now, but it might take another 5 or so years before everyone
upgrades...  So, I need to know if .dmg files for OSX are ok?  I seem to
recall some reason why .zip were preferred over .dmg files... but I can
not remember the reason!  I think .dmg files are ok now, since major
projects like VLC etc all use .dmg files.  So maybe the reason does not
exist anymore with modern OSX. I plan on creating new .dmg files from the
existing .zip files, and linking to them from the download page.
 
tldr;
Are .dmg files ok for binaries on OSX now?
 
cheers,

Somebody can correct me if I am wrong, but I think the problem with an 
unzipped .dmg file was that there was no cross-platform tool for 
creating a compressed .dmg file, so if you wanted tocreate a compressed 
.dmg and you didn't have a Mac, you couldn't. A uncompressed 
unencrypted .dmg file is just a disk image in HFS+ format, but the 
compression and encryption are special somehow.

---
James Paige


Re: [pygame] spammity spam on /wiki/patchesandbugs

2011-12-02 Thread James Paige
I have suggested this before, but it bears repeating. Anonymous users, 
and new users should just not be allowed to make any edit that contains 
a url.

---
James Paige

On Fri, Dec 02, 2011 at 11:56:01AM -0430, Ciro Duran wrote:
The wiki is full of them. I tried in the past to edit those, but a few
days later the spammers re edit the page.
 
El dic 2, 2011 11:49 a.m., Sean Wolfe ether@gmail.com escribio:
 
  Hey I was just poking around the pygame.org site and found some spam
  hackness... looks like this page has a lot of hidden links to jokes
  pages, plus some 'diet pills' links etc etc.
 
  http://pygame.org/wiki/patchesandbugs
 
  aach!
 
  --
  A musician must make music, an artist must paint, a poet must write,
  if he is to be ultimately at peace with himself.
  - Abraham Maslow


Re: [pygame] pygame4android - does the end user need P4A?

2011-11-10 Thread James Paige
On Thu, Nov 10, 2011 at 12:46:15PM -0300, Sean Wolfe wrote:
 Rolling around in the Java / Android weeds and hating it. A question
 ... if I build my Android app with P4A, does the end user need to
 install P4A as well?
 
 The answer is no, correct? I mean the P4A build documentation uses Ant
 and a JDK and results in an .apk file, right? The end game doesn't
 even use python on the phone? Or maybe I am misunderstanding the
 thingies.
 
 Thanks!

I distributed my game Stegavorto in the android store that way.

The end user does NOT need to install the Pygame for Android package, 
but there is a complete copy of it embedded into your .apk 
file. Python does indeed run on the android phone.

---
James Paige


Re: [pygame] man oh man Java is painful

2011-11-03 Thread James Paige
On Thu, Nov 03, 2011 at 01:11:08PM -0300, Sean Wolfe wrote:
 really excited just from a religious standpoint... I mean how many
 cool games have been made with Java? ...none?

Minecraft.

But that is the only one I can think of!

Also, I understand that the Android port of Minecraft is NOT the Java 
version, it is mostly re-written in C, so I guess this is the exception 
that proves the rule :)

---
James Paige


Re: [pygame] pygame on android first impressions

2011-10-20 Thread James Paige
I have been playing with the pygame subset for android on a Motorola 
Xoom tablet. it is faster than most phones, but I did notice that the 
slowest stuff seemed to be graphics. Have you tested a pygame program 
with a very low screen resolution like 320x240? I would be curious how 
it runs on your phone.

I tried to do profiling on my Android device. The cProfile module didn't 
work, but the profile module did, unfortunately it is so much slower 
than the cProfile module, so it was difficult to test with on the 
Android device.

---
James Paige

On Thu, Oct 20, 2011 at 04:28:45PM -0200, Sean Wolfe wrote:
 I just set up pygame for android on my LG Optimus phone. The
 documentation is good! The process worked pretty much as advertised.
 
 Looks like my phone is not really strong enough to run the app well
 though. The simple 'flash green' application on the P4A website isn't
 too fast... there is a 0.5-1s latency with the flash feature. I'm
 thinking this is just inherent to running an interpreted language on a
 slow mobile phone processor. Does that sound right?
 
 So it looks like a cool tool, but I think the phone is just not a good
 graphical Python environment.
 
 Any thoughts?
 
 Thanks yall
 
 -- 
 A musician must make music, an artist must paint, a poet must write,
 if he is to be ultimately at peace with himself.
 - Abraham Maslow
 


Re: [pygame] set new recommendation to which version of pygame?

2011-09-30 Thread James Paige
We should not be reccomending any specific version. We should just make 
it clear to new users that they have to get the pygame that matches 
their version of python.

All the nuances of which version is best for different reasons are 
important, but trying to explain them on the download page will only 
confuse newcomers.

Maybe just a link on the downloads page that leads to a separate page 
titled How to decided which python+pygame version is best for me

---
James Paige

On Fri, Sep 30, 2011 at 11:26:56AM -0500, Jake b wrote:
For the updated website, what versions do you think we should recommend?
Here's what I think:
 
1) Python version: 2.7 and 2.6 are good.
(Almost any random module will work with them, many smaller ones are
not updated for 3.x )
 
2) pygame version:
**need link to the new .exe, which is somewhere in the mailing list**
 
3) 32bit python also is more common.
[ You can use 32python on windows 64 bit fine ]
Note:
  * you can install multiple versions of python on your computer.
  * You can install multiple versions of python modules on your computer.
[See virtualenv ]
From the docs, about version number 2.7:
 
Python 2.7 is intended to be the last major release in the 2.x series. The
Python maintainers are planning to focus their future efforts on the
Python 3.x series.
 
This means that 2.7 will remain in place for a long time, running
production systems that have not been ported to Python 3.x :
 
--
Jake


[pygame] pygame download page still reccomends python 2.5

2011-09-29 Thread James Paige
I was talking with a new programmer who is just getting started with 
python and pygame. After a lot of confusion, I realized that he had 
downloaded pygame-1.9.1.win32-py2.5.msi by mistake. The download page 
still has bold text proclaiming (python2.5.4 is the best python on 
windows at the moment)

If anybody knows any reason why that is still true, please correct me, 
but I think instead of bold text to reccomend one version over others, 
there should just be a message saying that a person should take care to 
download the version that matches their python version.

No matter who I am, the best version of pygame is the one that will 
work on my computer ;)

---
James Paige


Re: [pygame] sprite backgrounds saving as white

2011-09-22 Thread James Paige
On Thu, Sep 22, 2011 at 05:08:52PM -0300, Sean Wolfe wrote:
 so my sprites are coming up on screen with a white background. I
 loaded the sprites in my drawing program (paint.net) and removed the
 white so that the only pixels are the character itself. However when I
 save to .bmp format the white background comes back!
 
 A problem because I'm using various colors in the game background.
 
 Any ideas about what I'm doing wrong? I don't think it's a pygame
 problem per se, but I figured somebody here might know the answer.
 
 thanks!

BMP format has no transparency. If you use BMP, then you have no choice 
but to use colorkey transparency. 
http://pygame.org/docs/ref/surface.html#Surface.set_colorkey

But what you probably really want is to ise PNG format instead of BMP. 
PNG actually supports transparency.

---
James Paige


Re: transition plan was Re: [pygame] contemplating move to bitbucket(and hg). what do you think?

2011-08-22 Thread James Paige
On Mon, Aug 22, 2011 at 12:07:30PM +0200, René Dudfield wrote:
Hello again,
 
http://hg.pygame.org/
 
Is the domain name now for source, issues etc.
 
@James
 
The urls should map from 3 through to 73, like this:
http://pygame.motherhamster.org/bugzilla/show_bug.cgi?id=3
http://hg.pygame.org/pygame/issue/3
 
http://pygame.motherhamster.org/bugzilla/show_bug.cgi?id=73
http://hg.pygame.org/pygame/issue/73
 
Thanks!

Okay! All old bugzilla urls now redirect to the new issue tracker!

How did you end up doing to conversion? Any script you used might be of 
interest to others wishing to migrate from bugzilla to bitbucket

---
James


Re: transition plan was Re: [pygame] contemplating move to bitbucket(and hg). what do you think?

2011-08-18 Thread James Paige
If, after the conversion is complete, you can give me a file that maps 
bugzilla bug numbers to bitbucket bug numbers, I can make the old bug 
urls redirect to the new bitbicket urls.

---
James Paige

On Thu, Aug 18, 2011 at 06:59:41PM +0200, René Dudfield wrote:
Hi,
 
I'm making the conversion tool here:
https://bitbucket.org/illume/bugzilla_bitbucket/
 
I did some test create issues and delete issues with the API.  We won't be
able to add things like comments and attachments, because the bitbucket
API is limited.  So I'll have to manually add those.
 
Haven't had much time to work on it... recovering from a blasted HD dying.
 
cu!
 
On Thu, Aug 18, 2011 at 7:01 AM, Lenard Lindstrom le...@telus.net wrote:
 
  No, that's great. I have no access to an I64 machine. It's good someone
  else can handle the Windows development for it.
  Lenard
 
  On 17/08/11 09:11 PM, Christoph Gohlke wrote:
 
Hi,
 
Rene gave me commit access and I already committed the patches. Hope
that is OK.
 
I also realized that libmsvcr90.a does not need to be part of the
repository. I did not add the file.
 
Only two tests fail.
 
Christoph
 
==
FAIL: FontTypeTest.test_set_bold
--
Traceback (most recent call last):
 File X:\Python32\lib\site-packages\pygame\tests\font_test.py, line
347, in test_set_bold
   self.failIf(f.get_bold())
AssertionError: None
 
==
FAIL: FontTypeTest.test_set_italic
--
Traceback (most recent call last):
 File X:\Python32\lib\site-packages\pygame\tests\font_test.py, line
359, in test_set_italic
   self.failIf(f.get_bold())
AssertionError: None
 
--
Ran 575 tests in 49.893s
 
FAILED (failures=2)
 
On 8/17/2011 8:56 PM, Lenard Lindstrom wrote:
 
  Hi,
 
  I'll see about applying the patch. Also the win64 scale_mmx.obj
  should
  be added. The libmsvcr90.a should be part of a prebuilt dependencies
  package, and not included in the repository. I will leave the icon
  for
  Rene to decide on.
 
  Lenard Lindstrom
 
  On 17/08/11 10:17 AM, Christoph Gohlke wrote:
 
On 8/17/2011 7:17 AM, Rene Dudfield wrote:
 
  Hi,
 
  I've converted the repository over to bitbucket:
  https://bitbucket.org/pygame/pygame/
 
  Please have a play and let me know if you see any issues.
 
Works for me. The attached patch fixes some minor Python 3 and
win-amd64 issues. I can also provide an improved pygame.ico (up to
256x256 RGBA) and the missing scale_mmx.obj and libmsvcr90.a files
in
obj\win64.
 
Christoph
 
  I've added a file called IMPORTANT_MOVED.txt to subversion
  with a note
  asking people not to commit changes to svn, and saying that
  we've moved
  to bitbucket.
 
  I haven't completed the map from svn revision to hg revision
  yet.
 
  I'm working on the bugzilla to bitbucket issue tracking now.
 
  *Please don't add any issues to the bitbucket issue tracker if
  you can
  help it for the moment - since they might get over written. I'm
  not
  going to download the bugs from bugzilla again either.
 
  So far I have downloaded the bugzilla bugs in xml format, and
  have read
  a bunch of documentation. I'm thinking of doing a quick and
  dirty
  conversion because I don't want to spend all that much time on
  it.
 
  cheers,


Re: [pygame] Articles about game design?

2011-08-17 Thread James Paige
Are you looking for something for yourself, or something for your 
students?

I was pretty impressed with http://inventwithpython.com/

---
James Paige

On Wed, Aug 17, 2011 at 08:44:32PM +0200, Hokan LUNDBERG wrote:
 Hello!
 
 I have used Pygame in my classes for a year now, and it is working
 fine. Now I would like to find good articles about developing games
 and game design in general. Maybe some of you have some ideas? Also
 books in pdf about game design would be great.
 
 Regards,
 Hokan
 (Programming teacher in Stockholm)
 


Re: [pygame] growing out of idle ide

2011-08-11 Thread James Paige
I never mess with the color schemes on them, but I have been very happy 
with both Scite and Geany.

Neither of them has any particularly fancy features. They are simple.

---
James

On Thu, Aug 11, 2011 at 05:43:04PM -0300, Sean Wolfe wrote:
 Hey guys + gals, I am wondering if anybody can recommend a python ide for me.
 
  I'm looking for something that supports different color schemes as I
 prefer a white-on-black setup. Up to this point in my career I've been
 using IDLE with custom color settings, and happily so. It is simple
 and I like simple. However as I get into more complex code for gaming
 I need a more modular project-based approach to my codebase so here I
 am.
 
 I don't particularly like Eclipse... seems pretty bloated especially
 for Python. For a Java developer I'm sure it's great but I don't get a
 happy feeling when I start it up, and for us game programmers it's all
 about the happy.
 
 I looked at Eric, but it doesn't seem to have the simple approach I'm
 looking for. But I may make that my first try.
 
 Is anybody particularly enthusiastic about their IDE? Anybody use a
 black-on-white or similar color scheme?
 
 Thanks d00ds
 
 -- 
 A musician must make music, an artist must paint, a poet must write,
 if he is to be ultimately at peace with himself.
 - Abraham Maslow
 


Re: [pygame] trajectory

2011-07-22 Thread James Paige
In most (but maybe not all) tower defense games I have ever played, 
bullets *can* change direction in flight, and do behave like homing 
missles. This isn't obvious visually if the bullets are fast, but it is 
pretty common in tower defense games that if a target is in range when 
the bullet is launched that it will always hit the target no matter how 
it moves.

That being said, I don't have any idea if Nathan Biagini wants to make 
his own tower defense game work that way or not :)

---
James Paige


On Fri, Jul 22, 2011 at 08:24:51AM -0700, Lee Buckingham wrote:
Unless the bullet can change direction in flight, it will have to choose
one, and only one spot to aim for, and therefore, one vector to guide it. 
Homing missiles are a lot different to code for, since they have to adjust
course, and potentially deal with a synthesized form of inertia.  
 
A bifurcating tree of solutions seems to suggest looking at all possible
'likely' positions for the target in the future.  That's not so much
vector math as it is statistics and player-psychology.
 
You also probably don't want to deal with linear solutions to this
problem, unless you really really need pinpoint accuracy on each shot
(again, assuming NOTHING changes direction or speed after a shot is fired,
which makes all that accuracy useless anyway).  Breaking it up into steps
that are a little smaller than the clipping rectangles involved will
probably get you more than close enough.  Furthermore, there will be a
different solution to the linear form of the problem for every firing
angle (wide angles intercept later, etc...) It would get pretty ugly.
 
It might suit better to 'fudge' in a calculation.  Make an estimated
change (just add a constant or something) to the current position of the
target, based on it's speed and direction, and fire at that position. 
Divide the x and y distance to the target each by the speed of your bullet
(you don't even NEED to do the trigonometry for speed calculations, the
player wouldn't notice much anyway) and make the bullet move that much in
the x and y directions each tick.  Try it out... are your shots firing too
far ahead?  Too far behind??   Change the estimation constant a little bit
and try again.  If the target is in close, you might have to reduce the
estimate a bit, etc...   You can probably tweak this one enough to have a
very satisfying firing computer without having to go through the hassle
of reading the physics chapter on ballistics.
 
Just a few ideas...
 
-Lee-
 
On Fri, Jul 22, 2011 at 7:21 AM, Joe Ranalli jrana...@gmail.com wrote:
 
  I'm not totally clear on what you're asking.  If you're saying that the
  targets might change direction after the bullet is fired, but you still
  want the bullet to hit the target, then my second algorithm wouldn't
  work.  That just doesn't make any sense.  The algorithm I suggested aims
  at the target, then shoots at it.  If the target changes direction, then
  it will no longer go to the spot you were aiming.
 
  If you're having this much trouble figuring this out I would definitely
  suggest you take some time to sit down and think about what it is you're
  trying to do and maybe read about some simple physics.  This part of the
  application really shouldn't be that difficult to figure out.
 
  On Fri, Jul 22, 2011 at 9:08 AM, Nathan BIAGINI nathan.o...@gmail.com
  wrote:
 
Hi. Thanks all for you replies i have one more question before trying
to write something on top of that, your algorithme Joe, does it works
if the way has some bifurcations, i mean, a fully linear way but that
contain bifurcations.
 
Thanks.
 
2011/7/20 Joe Ranalli jrana...@gmail.com
 
  It depends what you're trying to do. 
 
  If you draw the straight line between the tower and the enemy and
  use that vector to translate a bullet each tick, the bullets might
  miss the enemy.  Think about it this way, the bullet moves 2 steps
  toward the enemy, then the enemy moves 1 step, then the bullet moves
  2, etc.  Because the enemy moves the bullet will have to change its
  direction through the flight.  So you could calculate the direction
  vector between the bullet and the enemy every tick and have the
  bullet move that direction.  That would make the bullets kind of arc
  to the target.
 
  If you want to have the bullet go straight to the right spot, you
  need to:
  1) calculate how long the bullet will take to get to the enemy
  2) calculate where the enemy will be at that time (newposition)
  3) calculate how long it will take the bullet to get to newposition
  4) recalculate newposition based on the new time
 
  Technically you could

Re: [pygame] trajectory

2011-07-20 Thread James Paige
Not built into pygame, but there is a good one on the pygame wiki:

http://pygame.org/wiki/2DVectorClass

On Wed, Jul 20, 2011 at 04:33:16PM +0200, Nathan BIAGINI wrote:
There is a pygame object to create a 2d vector?
 
2011/7/20 Joe Ranalli jrana...@gmail.com
 
  Yes a vector is probably appropriate.
 
  On Wed, Jul 20, 2011 at 10:20 AM, Nathan BIAGINI nathan.o...@gmail.com
  wrote:
 
Ok. But all the calcul of how long the bullet will take to reach the
target etc... will be made byn using vector? I mean, using a vector
still viable?
 
2011/7/20 Joe Ranalli jrana...@gmail.com
 
  It depends what you're trying to do. 
 
  If you draw the straight line between the tower and the enemy and
  use that vector to translate a bullet each tick, the bullets might
  miss the enemy.  Think about it this way, the bullet moves 2 steps
  toward the enemy, then the enemy moves 1 step, then the bullet moves
  2, etc.  Because the enemy moves the bullet will have to change its
  direction through the flight.  So you could calculate the direction
  vector between the bullet and the enemy every tick and have the
  bullet move that direction.  That would make the bullets kind of arc
  to the target.
 
  If you want to have the bullet go straight to the right spot, you
  need to:
  1) calculate how long the bullet will take to get to the enemy
  2) calculate where the enemy will be at that time (newposition)
  3) calculate how long it will take the bullet to get to newposition
  4) recalculate newposition based on the new time
 
  Technically you could iterate that repeatedly until newposition
  converges.  Practically, iterating once probably gets you close
  enough unless the movement is extremely complicated.
 
  On Wed, Jul 20, 2011 at 9:14 AM, Nathan BIAGINI
  nathan.o...@gmail.com wrote:
 
Hi everyone,
 
i would like to know what are the common way to handle
trajectory in a 2d game. In fact, i think of writing a tower
defense game and i wonder how to handle the trajectory of the
missile launch by the towers. I though of getting the pos of the
tower and the target and create a vector between this two
entitites to make a sprite translation of this vector but there is
maybe some tricky stuff to do it.
 
Thanks in advance and happy game making all :-)


[pygame] pygame bug tracking (bugzilla alternative?)

2011-05-18 Thread James Paige
I have been hosting the pygame bug tracker at 
http://pygame.motherhamster.org/bugzilla/ it seems to be getting a 
little usage, but not a whole lot.

Is a bugzilla tracker still a desirable thing for the pygame 
developers? Does anybody have interest in taking over hosting of it, or 
converting the bugs already filed in it into a different bug tracker? 
(maybe even a python-based one?)

I am not going to suddenly stop hosting it or anything like that, I just 
want to find out if there is anybody out there who is interested in 
taking it over and/or making it better.

---
James Paige


Re: [pygame] Resolution for a 2d game

2011-05-16 Thread James Paige
On Mon, May 16, 2011 at 07:25:02AM -0400, R. Alan Monroe wrote:
 
  Please don't force a fullscreen resolution. It doesn't restore properly on
  dual-head setups.
 
 Agreed. Even on single screens it often repositions other running apps'
 windows. A real nuisance.
 
 Alan

Another big advantage of NOT automatically forcing forcing fullscreen, 
is that it makes it very easy for you as the developer to test various
resolutions that are smaller than your desktop size.

---
James Paige


Re: [pygame] Frames per seconds

2011-05-02 Thread James Paige
On Mon, May 02, 2011 at 07:48:17PM +0200, Nathan BIAGINI wrote:
Hi everyone,
 
I'm writing using twisted for the network then i would like to know the
for getting the exact seconds to wait each loop to have 60 frames per
seconds. Actually i have to specify a value in seconds. There is a way to
know the time in seconds to wait depending of the computer proc to have
exactly 60 frames per seconds?
 
Thanks.

Have you read this?:

http://www.pygame.org/wiki/ConstantGameSpeed

It is a good idea to make your display fps separate from your game logic 
fps. Even if you want them both to be 60 fps, it can still be a big 
advantage to separate them, because a slowdown in one doesn't always 
have to affect the other.

---
James Paige


Re: [pygame] Making UPS smart with Pygame and Joystick input socket

2011-04-13 Thread James Paige
Oh! I understand now! You are going to take a joystick, disassemble it, 
and splice it together with your UPS so the buttons get pushed as you 
describe.

Pygame's joystick support is nice and simple and easy to use-- the only 
problem I could forsee is that AKAIK you have to initialize a pygame 
window before you can read joystick events. You said this was a server, 
so if it is not running a graphical environment, initializing that 
window could possibly be a problem.

Otherwise, sounds like fun :)

---
James Paige

On Wed, Apr 13, 2011 at 04:55:53PM +0200, slawko.skrzy...@poczta.fm wrote:
 1) I am sure my UPS is neither being read as a Joystick nor any other device. 
 It is because it has only 2 connections: AC-input and AC-output. 
 2) This UPS is made by Ever type MP300.
 3) It is connected to the computer by AC-output socket on the UPS and 
 AC-input of the PSU in my PC. It has no data connections that smart UPS 
 usually have that connect to the COM port of a computer and can be monitored 
 by special software.
 That is the point.
 I would like to make use of existing gameport (that is not used by the server 
 at this moment) and perform basic communication, like this:
 Button_1 OFF , Buton_2 OFF - state A
 Button_1 ON , Buton_2 OFF - state B
 Button_1 ON , Buton_2 ON - state C
 The other actions described already before.
 For this task some piece of software is needed that reads the Joystick port.
 Therefore my interest in Pygame's Joystick module.
 The necessary hardware upgrade to the UPS is very simple and requires just 2 
 additional relays an some cabling. It will electrically be equivalent to a 
 joystick hardware that simply connect 2 pairs of wires by the button. In this 
 application the human finger and the button switch is replaced by a relay.
 
 
 SlawKo
 
 Użytkownik James Paige b...@hamsterrepublic.com napisał(a): 
  Temat: Re: [pygame] Making UPS smart with Pygame and Joystick input socket
  Data: 2011-04-13 1:16
  Nadawca: James Paige b...@hamsterrepublic.com
  Adresat: pygame-users@seul.org; 
  
  Are you sure your UPS device is actually being read as a Joystick? 
  Exactly what kind of UPS do you have, and how is it connected to the 
  computer?
  
  There are probably better tools for doing what you want to do than 
  pygame.
  
  ---
  James Paige
  
  On Wed, Apr 13, 2011 at 12:42:18AM +0200, slawko.skrzy...@poczta.fm wrote:
   Hello,
   
   I would like to get some information whether it would be possible to use 
   Pygame's Joystick package to process simple signal from UPS to trigger 
   clean shutdown of the Linux machine.
   
   I would like to use 2 buttons from Joystick interface to sense 3 states 
   from UPS:
   A) AC power OK
   B) no AC power - using battery
   C) battery low - shutdown now
   
   The program should run as a demon and check every 10 second if the UPS 
   entered B state. Then would monitor every second if UPS reached C state. 
   At this moment daemon should copy files stored in RAMdisk onto HDD and 
   request runging programs to close and finally invoke system shutdown.
   
   This architecture would improve my Linux 
   net_router/web_proxy/home_automation/etc. server with simple solution 
   using existing gameport, 2 relays and some cabling, upgrading it to a 
   smart system.  :)
   
   
   Is it difficult to create this piece of software ?
   
   
   Kind Regards,
   
   SlawKo
   
   
   Najlepsze oferty na domy i mieszkania w Polsce!
   Szutkaj tutaj  http://linkint.pl/f2974
   
   
  
 
 -
 Ksiegowa radzi: Jak załozyc firme w 15 minut?
 http://linkint.pl/f2968
 
 


Re: [pygame] Making UPS smart with Pygame and Joystick input socket

2011-04-13 Thread James Paige
I was assuming that you were talking about a USB joystick or gamepad. 
Are you talking about the old midi-port style joysticks? the ones where 
the port is usually on the sound card?

I have no idea if pygame supports those at all... I am not sure if they 
even show up as joystick devices in the linux /dev tree. I suspect that 
they probably do not (not unless you are using a really ancient kernel)

The reason I assumed that you were going to disasemble a joystick is 
because I was thinking of a USB joystick. You need the joystick to 
identify itself as a joystick on the USB bus. You could probably still 
connect your UPS to the joystick as you planned, although now I am 
thinking you might have an easier time connecting to one of the analog 
inputs instead of the buttons.

(Also, that file you attached was an inkscape SVG file, renamed to have 
a PNG extension, in case anybody tried to look at it and wondered why it 
seemed to be a broken PNG)

---
James Paige

On Wed, Apr 13, 2011 at 06:49:47PM +0200, slawko.skrzy...@poczta.fm wrote:
 No, I do not want to disassemble a Joystick.
 I simply want to add a relay that would be connected to existing relay in UPS 
 that switches battery ON.
 See a picture with connections in enclosed file.
 
 
 SlawKo
 
 
 
 
 
 
 Użytkownik James Paige b...@hamsterrepublic.com napisał(a): 
  Temat: Re: [pygame] Making UPS smart with Pygame and Joystick input socket
  Data: 2011-04-13 17:24
  Nadawca: James Paige b...@hamsterrepublic.com
  Adresat: pygame-users@seul.org; 
  
  Oh! I understand now! You are going to take a joystick, disassemble it, 
  and splice it together with your UPS so the buttons get pushed as you 
  describe.
  
  Pygame's joystick support is nice and simple and easy to use-- the only 
  problem I could forsee is that AKAIK you have to initialize a pygame 
  window before you can read joystick events. You said this was a server, 
  so if it is not running a graphical environment, initializing that 
  window could possibly be a problem.
  
  Otherwise, sounds like fun :)
  
  ---
  James Paige
  
  On Wed, Apr 13, 2011 at 04:55:53PM +0200, slawko.skrzy...@poczta.fm wrote:
   1) I am sure my UPS is neither being read as a Joystick nor any other 
   device. It is because it has only 2 connections: AC-input and AC-output. 
   2) This UPS is made by Ever type MP300.
   3) It is connected to the computer by AC-output socket on the UPS and 
   AC-input of the PSU in my PC. It has no data connections that smart UPS 
   usually have that connect to the COM port of a computer and can be 
   monitored by special software.
   That is the point.
   I would like to make use of existing gameport (that is not used by the 
   server at this moment) and perform basic communication, like this:
   Button_1 OFF , Buton_2 OFF - state A
   Button_1 ON , Buton_2 OFF - state B
   Button_1 ON , Buton_2 ON - state C
   The other actions described already before.
   For this task some piece of software is needed that reads the Joystick 
   port.
   Therefore my interest in Pygame's Joystick module.
   The necessary hardware upgrade to the UPS is very simple and requires 
   just 2 additional relays an some cabling. It will electrically be 
   equivalent to a joystick hardware that simply connect 2 pairs of wires by 
   the button. In this application the human finger and the button switch is 
   replaced by a relay.
   
   
   SlawKo
   
   Użytkownik James Paige  napisał(a): 
Temat: Re: [pygame] Making UPS smart with Pygame and Joystick input 
socket
Data: 2011-04-13 1:16
Nadawca: James Paige 
Adresat: pygame-users@seul.org; 

Are you sure your UPS device is actually being read as a Joystick? 
Exactly what kind of UPS do you have, and how is it connected to the 
computer?

There are probably better tools for doing what you want to do than 
pygame.

---
James Paige

On Wed, Apr 13, 2011 at 12:42:18AM +0200, slawko.skrzy...@poczta.fm 
wrote:
 Hello,
 
 I would like to get some information whether it would be possible to 
 use Pygame's Joystick package to process simple signal from UPS to 
 trigger clean shutdown of the Linux machine.
 
 I would like to use 2 buttons from Joystick interface to sense 3 
 states from UPS:
 A) AC power OK
 B) no AC power - using battery
 C) battery low - shutdown now
 
 The program should run as a demon and check every 10 second if the 
 UPS entered B state. Then would monitor every second if UPS reached C 
 state. At this moment daemon should copy files stored in RAMdisk onto 
 HDD and request runging programs to close and finally invoke system 
 shutdown.
 
 This architecture would improve my Linux 
 net_router/web_proxy/home_automation/etc. server with simple solution 
 using existing gameport, 2 relays and some cabling, upgrading it to a 
 smart system.  :)
 
 
 Is it difficult

Re: [pygame] Making UPS smart with Pygame and Joystick input socket

2011-04-13 Thread James Paige
On Wed, Apr 13, 2011 at 10:18 AM, James Paige b...@hamsterrepublic.com wrote:
 I was assuming that you were talking about a USB joystick or gamepad.
 Are you talking about the old midi-port style joysticks? the ones where
 the port is usually on the sound card?

 I have no idea if pygame supports those at all... I am not sure if they
 even show up as joystick devices in the linux /dev tree. I suspect that
 they probably do not (not unless you are using a really ancient kernel)

I should correct myself here. I just checked, and yes, the current
stable linux kernel does still have support for these, but only if
compiled with CONFIG_GAMEPORT enabled. Whether that is enabled by
default would probably depend on your distribution.

I am going to guess that if the kernel creates a /dev/input/js# device
for it then pygame will have no trouble reading from it.

---
James Paige


Re: [pygame] Making UPS smart with Pygame and Joystick input socket

2011-04-12 Thread James Paige
Are you sure your UPS device is actually being read as a Joystick? 
Exactly what kind of UPS do you have, and how is it connected to the 
computer?

There are probably better tools for doing what you want to do than 
pygame.

---
James Paige

On Wed, Apr 13, 2011 at 12:42:18AM +0200, slawko.skrzy...@poczta.fm wrote:
 Hello,
 
 I would like to get some information whether it would be possible to use 
 Pygame's Joystick package to process simple signal from UPS to trigger clean 
 shutdown of the Linux machine.
 
 I would like to use 2 buttons from Joystick interface to sense 3 states from 
 UPS:
 A) AC power OK
 B) no AC power - using battery
 C) battery low - shutdown now
 
 The program should run as a demon and check every 10 second if the UPS 
 entered B state. Then would monitor every second if UPS reached C state. At 
 this moment daemon should copy files stored in RAMdisk onto HDD and request 
 runging programs to close and finally invoke system shutdown.
 
 This architecture would improve my Linux 
 net_router/web_proxy/home_automation/etc. server with simple solution using 
 existing gameport, 2 relays and some cabling, upgrading it to a smart 
 system.  :)
 
 
 Is it difficult to create this piece of software ?
 
 
 Kind Regards,
 
 SlawKo
 
 
 Najlepsze oferty na domy i mieszkania w Polsce!
 Szutkaj tutaj  http://linkint.pl/f2974
 
 


Re: [pygame] Whoa! Bad slowdown!

2011-04-12 Thread James Paige
Use python's cProfile module to quickly pinpoint the slowest parts of 
your code.

http://docs.python.org/library/profile.html

---
James Paige

On Tue, Apr 12, 2011 at 04:02:35PM -0700, Julian Marchant wrote:
I have actually mentioned this project of mine on this list before, but it
was about a Windows-specific issue. This time, it's about slowdown. Now,
my laptop is very low-end, so it's not surprising to me when I experience
lag in particularly graphically-intensive games, but this is ridiculous.
 
All the files of my project can be found in this download:
http://www.mediafire.com/?pbr8kubwu9q7vg0
 
The slowdown I'm experiencing (under Fedora 14/GNOME, at least) is a
ridiculous level. Each frame takes something like 10-20 seconds, which is
just plain unimaginable. I have looked through my code, and I find nothing
which should cause this massive scale of slowdown. A fair amount of stuff
happens, and even some pixel work with surfarray happens, but I would not
expect any less than maybe 10 FPS, and that's really stretching it.
 
Most of the slowdown seems to occur in the PlayerSprite.update and
PlayerView.update methods. Looking at the system monitor, it seems that
the program is eating up clock cycles like a starving lion. My question
is: can anyone see a good reason why these methods would cause as much
slowdown as they do? If so, any recommendations for optimizing it better?
 
Thanks! :)


Re: [pygame] Using reStructuredText for document sources

2011-03-04 Thread James Paige
On Thu, Mar 03, 2011 at 10:06:34PM -0800, Lenard Lindstrom wrote:
 One advantage with formal documentation is it can be kept synchronized  
 with Python doc strings. The current Pygame doc system does this in a  
 limited way. Hopefully a move to reST will encourage even greater  
 coordination. How would this be done with a wiki? Only the author of a  
 new Pygame feature knows what it should actually do. Unfortunately the  
 existing docs containing many second hand guesses. How will a wiki give  
 better descriptions. As a developer, it is as easy for me to edit the  
 docs in SVN as a wiki page. The Python approach to cooperative  
 documenting is to encourage users to submit patches which are then  
 incorporated into the formal documents. But this is not to discourage a  
 wiki document. But maybe it can complement the formal docs, be more of a  
 user's guide then a api reference.

 Lenard

Just a thought-- is there any possible interface where volunteers could 
have a wiki-like interface for contributing updates directly to the reST 
format docs?

---
James Paige


Re: [pygame] Re: [Py2exe-users] Error with pygame

2010-10-30 Thread James Paige
On Sat, Oct 30, 2010 at 07:15:19PM -0400, Zachary Uram wrote:
 Thanks to everyone who responded. It was indeed a conflict between
 32-bit and 64-bit versions. I installed 64-bit Python 2.6, pygame and
 py2exe and now all is well.
 
 Zach

Does anybody on list have any experience with having both 32-bit 
python+pygame+py2exe and 64-bit python+pygame+py2exe installed 
simultaneously on the same system? That seems ideal for being able to 
distribute executables for both architechtures

---
James Paige


Re: [pygame] frame independant movement

2010-08-27 Thread James Paige
On Fri, Aug 27, 2010 at 10:59:09AM -0400, Kris Schnee wrote:
 On 2010.8.27 10:36 AM, B W wrote:
 Howdy,

 Reviving this old thread. The comments by Patrick and Brian really
 intrigued me, so I pursued the topic. Found a few interesting articles
 and one great article. My study has resulted in a recipe for those of us
 continually nagged by the question, how can I get constant game speed
 independent of frame rate?. The demo requires Pygame, but the clock
 module only requires Python.

 Isn't it simply a matter of creating a Pygame Clock object and calling  
 clock.tick() to delay until the appropriate time to maintain some max  
 framerate?

That only caps a max framerate. What Gumm is talking about is when your 
framerate and your game simulation rate can be adjusted independantly

---
James Paige


Re: [pygame] frame independant movement

2010-08-27 Thread James Paige
On Fri, Aug 27, 2010 at 08:43:59AM -0700, Brian Fisher wrote:
So you asked what else do you need? well the answer is if you want
consistent non-linear physics (like say you want the players to jump the
same all the time), then the else you need is fixed size timesteps for
your physical simulation.

I seem to remember that one of the Quake games (or was it all of them?) 
did this /wrong/. The distance your character could jump was affected by 
your frame rate, making certain hard jumps impossible at certain frame 
rates.

---
James Paige


Re: [pygame] Re: Keeping a sprite on screen with rect.clamp

2010-08-16 Thread James Paige
step = distance / time

On Tue, Aug 17, 2010 at 10:43:30AM +0800, Mark Reed wrote:
 I want to calculate a straight path of points between two points and
 each frame do:
 
 sprite.x, sprite.y = sprite.path[step]
 step++
 
 And have the sprite move along that line.  I've lost all basic math
 skills, and don't want to spend an hour debugging such a simple thing.
 
 Mark
 
 On Tue, Aug 17, 2010 at 9:41 AM, Luke Paireepinart
 rabidpoob...@gmail.com wrote:
  Can you be more specific about what you mean? Are you trying to 
  interpolated points between two endpoints or what?
 
  Sent from my iPhone
 
  On Aug 16, 2010, at 8:13 PM, Mark Reed markree...@gmail.com wrote:
 
  Anyone have a function for calculating all the points on a line to be
  used for sprite movement?
 
  Mark
 
 
 


Re: [pygame] Spam on Tutorials page

2010-08-05 Thread James Paige
On Thu, Aug 05, 2010 at 09:59:54AM -0430, Ciro Duran wrote:
Hi,
I've taken the task since some days ago to clean link spam from the
tutorials page in pygame.org. Sadly, this is a losing battle, it's only a
few hours before some guys adds the same links as always. And some of them
don't even bother to edit the site, but rather revert to their spammy
version. Is there any way to semi-protect this page and have someone
curate this page?
Ciro.

I think I have mentioned this before, but I will bring it up again.

If you auto-block posts that contain a url, you block 99.?% of spam.

This doesn't interfere too badly with normal comments. Only a minor 
inconveneince for legit users, really. Even anonymous legit users!

There could be a whitelist of users who are allowed to post urls, or you 
could send comments that contain urls to a queue for moderation fi you 
want to get fancy.

---
James Paige


Re: [pygame] Spam websites hijacking the wiki

2010-07-07 Thread James Paige
I suggest auto-rejecting any post that contains a url unless the post is 
from a whitelist of known non-spammer users.

---
James Paige

On Tue, Jul 06, 2010 at 09:32:19PM -0700, scribbler95 wrote:
 Hi, I'm new to this mailing list though I've been using pygame for
 about 2 years.
 
 I have noticed that most of the extremely useful links on the
 Resources page are gone, to be replaced with trash links going to
 various shady websites
 Here is the text of the last links on the page:
 
 # So You Want To Be A Pixel Artist? - [version for printing] Belly
 Button Ring red cross cna classes cna certification test
 
 Red cross? CNA certification?
 
 The links page is completely empty now, and the title is:
 burmeh yaza lida fx15 biber hapý ile formda girin
 
 I have no idea what that means.
 
 This newly posted project is also extremely suspicious:
 http://pygame.org/project-Matrimonial-1574-2775.html
 
 What is going on with the site?
 
 


Re: [pygame] Running Python 2.5 alongside 2.6

2010-04-28 Thread James Paige
On Tue, Apr 27, 2010 at 10:18:34PM -0300, claudio canepa wrote:
On Tue, Apr 27, 2010 at 10:13 PM, Julian Marchant onp...@gmail.com
wrote:
 
  The pygame download page's message that python 2.5 is the best for
  Windows probably made him think that Pygame was for Python 2.5.
 
That was a very old sugestion.
I run pygame with python 2.6, and a lot of people in the pyweek event,
with diferent operating systems the same.
There are no problems.
In the download select the the file for your operating system marked with
the py2.6

Yeah, a lot of people have been confused by that. Can someone who has 
access permissions to edit http://www.pygame.org/download.shtml please 
remove it?

I suggest adding a link on that page like How do I decide which python 
version to use with pygame? which could point to a wiki page which 
could outline the pros and cons of each python version as it applies to 
pygame.

... I just tried to create a wiki page for that purpose, but I can't 
figure out how to create new pages, only edit existing ones :(

---
James Paige


Re: [pygame] Running Python 2.5 alongside 2.6

2010-04-28 Thread James Paige
Thanks!

I created a rough draft at http://www.pygame.org/wiki/PythonVersions

I would appreciate it if anybody who has personal experience with 
advantages or disadvantages of using certain python versions could add 
them to that page.

I am also curious what versions people actually use on windows, so we 
can actually say which is more popular, rather than speculating. (I'll 
start a separate thread for that)

---
James Paige

On Wed, Apr 28, 2010 at 05:22:18PM +0100, René Dudfield wrote:
you just go to the url you want to create, then edit it.
 
cu.
 
On Wed, Apr 28, 2010 at 5:00 PM, Khono Hackland
generousparas...@gmail.com wrote:
 
  I believe this is the link to page creation:
  http://www.pygame.org/wiki/CreatePage
 
  I don't see any fields for entering the title though.
  On 28 April 2010 11:39, James Paige b...@hamsterrepublic.com wrote:
   On Tue, Apr 27, 2010 at 10:18:34PM -0300, claudio canepa wrote:
  On Tue, Apr 27, 2010 at 10:13 PM, Julian Marchant
  onp...@gmail.com
  wrote:
  
The pygame download page's message that python 2.5 is the best
  for
Windows probably made him think that Pygame was for Python 2.5.
  
  That was a very old sugestion.
  I run pygame with python 2.6, and a lot of people in the pyweek
  event,
  with diferent operating systems the same.
  There are no problems.
  In the download select the the file for your operating system
  marked with
  the py2.6
  
   Yeah, a lot of people have been confused by that. Can someone who has
   access permissions to edit http://www.pygame.org/download.shtml please
   remove it?
  
   I suggest adding a link on that page like How do I decide which
  python
   version to use with pygame? which could point to a wiki page which
   could outline the pros and cons of each python version as it applies
  to
   pygame.
  
   ... I just tried to create a wiki page for that purpose, but I can't
   figure out how to create new pages, only edit existing ones :(
  
   ---
   James Paige
  


[pygame] informal poll on Windows python version

2010-04-28 Thread James Paige
This is an informal poll to figure out which version of python people 
use with pygame on Windows

Just reply and post your versions in this format


Windows Version: Windows XP

Pygame Version: 1.9.1

Python Version: 2.5 and 2.6 (I have both installed)

Reason (optional): Until recently I thought python 2.5 + was the only 
version to work with pygame and py2exe. Recently switched to 2.6 as my 
default, but won't removed 2.5 yet until I have tested py2exe on all my 
projects.

---
James Paige


Re: [pygame] problems getting python 3.1 to work with pygame 1.9

2010-04-18 Thread James Paige
I have read that book. It starts with Python 3 but when you get to the 
chapters that use pygame it instructs you to switch to python 2.6.

---
James Paige

On Sat, Apr 17, 2010 at 11:46:49PM -0400, Khono Hackland wrote:
 It is indeed for python 3.1.  The book tells the user, on page 5,
 specifically to get 3.1 and gives this link:
 http://www.delmarlearning.com/companions/index.asp?isbn=1435455002
 
 Presumeably the downloads link there allows the reader to get a
 working set of programs but the link's not working for me.
 
 On 17 April 2010 23:29, Luke Paireepinart rabidpoob...@gmail.com wrote:
  Hence why I asked for the names of the books... He says they are for
  py3.1 and pygame which I thought was quite odd. I'm on my phone so I
  can't check. Not many people use py3 yet.
 
  On 4/17/10, Greg Ewing greg.ew...@canterbury.ac.nz wrote:
  Luke Paireepinart wrote:
  Pygame 1.9 was written for 2.x.  python 3.x is not backwards
  compatible.
 
  On 4/17/10, Pierces pier...@midcoast.com wrote:
 
 I'm trying to set up an Ubuntu 10.04 machine so my son can follow a book
  on
 learning Python programming with pygame 1.9 and python 3.1.
 
  If the book talks about PyGame, it's probably also
  talking about Python 2.x, in which case giving him
  a 3.x Python will only lead to confusion.
 
  --
  Greg
 
 
  --
  Sent from my mobile device
 
 
 


Re: [pygame] newbie

2010-03-29 Thread James Paige
grep is a unix command for searching files. All us cool Linux kids know 
it :)

But the Windows equivalent would just be to search in the pygame 
examples folder for any files that contain the word SLK_

---
James

On Mon, Mar 29, 2010 at 09:24:56PM +0100, sne...@msn.com wrote:
grep -r for SDLK_ ? O.o
 
Just so you know, i'm 100% new at programming, so all input is greatly
received and please be patient if I need everything spelled out.
 
Thanks for the help Mark
From: 0wl
Sent: Sunday, March 28, 2010 9:06 PM
To: pygame-users@seul.org
Subject: Re: [pygame] newbie
Hi,
Here's a little trick: try grep -r for SDLK_ for example in some game's
code, it will search recursively through all the game's files. this way
you do not have to reinvent the wheel.
Love, tullarisc.
 
2010/3/26 sne...@msn.com
 
  These are gems Kris, thanks, if I had to figure all this out by trial 
  error, i'd still be here till next millenium not have a beta churned
  out!
 
  some one mentioned to look at  the mvc on another mailing list which is
  what
  i'm trying to follow, it kinda makes sense but my learning resources are
  limited to the internet at the minute. I have been reading through the
  codes of the games on pygame to get an idea of how it works thought they
  can be quite difficult to follow  find how they have structured it, if
  anyone feels the need to write a really simplified game  put it up on
  pygame... :.P
 
  The variables have no specific meaning bar easy reference as the numpad
  on
  my keyboard has arrows on it.
 
  I haven't had a chance to read through your sudjestions yet (on the
  books 2nite) but I will get back with more Q's (if that's cool.
 
  If anyone's interested, Py Em Up has a really interesting way of
  levelmakeing using bmp images
  --
  From: Kris Schnee ksch...@xepher.net
  Sent: Thursday, March 25, 2010 11:20 PM
  To: pygame-users@seul.org
  Subject: Re: [pygame] newbie
 
On 3/25/2010 6:03 PM, sne...@msn.com wrote:
 
  Ah, yes I see what's happening, the last time I was doing it I was
  using:
  ...KEYDOWN:
  if event.key == K_LEFT:
  foreward = True
  ...KEYUP:
  if event.key == K_LEFT:
  foreward = False
  meaning it was staying true, until key up but now it's not keeping
  the
  output next time round  waiting for it again.
  could you elaborate on this bit 'You could make the character move
  every
  frame (eg. setting a speed and
  moving by that speed per frame) until a KEYUP event happens', or is
  that
  pretty much what I 'was' doing?
 
If you said, On a KEYDOWN event, set speed to N and set direction to
whatever; and on a KEYUP event, stop, then the result should be that
the
character keeps moving until you let go of the key. If you said, On a
KEYDOWN event, move, then you should get one frame of movement each
time
you press (not hold) the key.
 
My advice is to figure out what the player's trying to do first, like
move right, and then actually execute the movement in a separate bit
of
code (if moving right...). That's useful for things like replacing
what
keys do what, or having some non-interactive event steer the
character.
 
  Could I use keys_down = pygame.key.get_pressed then
  if keys_down[K_RIGHT] ## move right,
 
  in this way:
  class character():
  
  def update(self, d, sp):
  if d == 6:
  self.x += sp
  elif d == 4:
  self.x -= sp
  elif d == 8:
  self.y -= sp
  elif d == 2:
  self.y += sp
 
Why use this odd numeric-keypad code for the direction? Other than the
variable names and that code, this looks usable. But think about
what'd
happen if I pressed RIGHT and UP at the same time: the code would see
the
RIGHT, set the direction to right, then probably see the UP (depending
on
which was mentioned last in the code) and change the direction to up.
 
A different way to handle the movement would be something like:
player.coords = [42,100] ## some starting value
## In a loop:
movement = [0,0]
if keys_down[K_RIGHT]:
 movement[0] = speed
...
if keys_down[K_UP]:
 movement[1] = speed
...
player.move(movement)
 
def Move(movement):
 self.coords[0] += movement[0]
 self.coords[1] += movement[1]
 
You'd then get diagonal movement, and not have to specify the
direction,
and could apply 

Re: [pygame] Python 2.5.4 or 2.6

2010-03-25 Thread James Paige
IDLE != python

On Thu, Mar 25, 2010 at 06:48:27PM -, sne...@msn.com wrote:
 I do like 3.1 for learning, if something goes wrong in 2.5.4 it cuts out 
 and all your work is lost, 3.1, if something doesn't add up you can close 
 the program but it doesn't close your .py files so you can save then go 
 back and check what's wrong. As far as i'm aware 3.1 doesn't have a 
 compiler so it's just a matter of editing (find  replace)your code to 
 2.5.4.
 
 --
 From: Kris Schnee ksch...@xepher.net
 Sent: Thursday, March 25, 2010 6:08 PM
 To: pygame-users@seul.org
 Cc: B W stabbingfin...@gmail.com
 Subject: Re: [pygame] Python 2.5.4 or 2.6
 
 On 3/25/2010 1:41 PM, B W wrote:
 Pygame download page claims python2.5.4 is the best python on windows
 at the moment.
 Why should I prefer Python 2.5.4 on Windows?
 
 I've found that when I tried to build a Windows EXE of a program I'd 
 written, I got inexplicable errors when I tried to use the latest version 
 of Python and Pygame. Only 2.5.4 and the matching Pygame worked for EXEs. 
 The experience was frustrating enough -- fatal errors just when I thought 
 the project was ready to show off! -- that I've not tried since then to 
 use a newer version.
 
 
 


Re: [pygame] Pygame and Enthought

2010-01-07 Thread James Paige
On Thu, Jan 07, 2010 at 10:13:15AM -0800, David Arnold wrote:
 Hi,
 
 I've installed the latest EPD 6.0 on a Macbook Pro running Snow Leopard from 
 www.enthought.com. I'd like to give pygame a try, but I am unsure as to how 
 it should be installed on my environment.
 
 On www.pygame.org, I did see some installation instructions for Snow Leopard, 
 but these depended on Macpython, a different distribution.
 
 Has anyone installed pygame in the Enthought distribution that could lend 
 some advice?

I had never heard of EPD before your mail... but I spent some time 
reading their website, and I am a little bit suspicious of their 
license. IANAL, but their licencing terms look like they might possibly 
violate some of the licenses of the packages they are bundling inside 
EPD. I could be wrong about this, I'm just saying that it smelled a tiny 
bit fishy to me...

Is there any special reason why you have to use EPD instead of some 
other version of Python?

This page of their FAQ 
http://www.enthought.com/products/epdfaq.php#installlocation
says that on Mac, EPD installs python into 
/Library/Frameworks/Python.framework/Versions/version

That leads me to believe that EPD's python is just an ordinary Python 
framework install. Don't the regular Mac install packages on pygame.org 
work with that?

---
James Paige


Re: [pygame] Bugtracking for the camera module?

2010-01-04 Thread James Paige
On Mon, Jan 04, 2010 at 12:29:50PM +, René Dudfield wrote:
 On Mon, Jan 4, 2010 at 4:01 AM, Alexandre Quessy alexan...@quessy.net wrote:
  Hello,
  I have a few bugs and features requests to report for the camera module.
  I might be one of the user/developer that uses it the most, with Toonloop.
 
  In the bugtracker at http://pygame.motherhamster.org/bugzilla/ there
  is no component named pygame.camera.
  Also, there is no version 1.9 in the choices. There are only 1.8, svn
  or unspecified.
  Thanks !
 
  --
  Alexandre Quessy
  http://alexandre.quessy.net/
 
 
 Hi,
 
 reporting them to the mailing list will probably get you more of a
 response I think.
 
 cheers,

I updated the bugtracker to add the 1.9 version and the pygame.camera 
module. If there is anything else missing, just say so, and I can fix 
it.

Although Rene is correct, the mailing list does tend to get faster 
results :)

---
James Paige


Re: [pygame] Bug: Python crash after switch to directx fullscreen quit

2009-12-11 Thread James Paige
On Fri, Dec 11, 2009 at 02:20:33PM -0800, Yanom Mobis wrote:
pygame does directx? that's new. But i suggest you use openGL so your game 
is cross-platform. 

SDL has a directx backend, but it only gets used by default under 
certain situations.

---
James


Re: [pygame] How do you do the sound?

2009-12-10 Thread James Paige
On Thu, Dec 10, 2009 at 09:21:16PM +, Kris Schnee wrote:
 On Thu, 10 Dec 2009 21:36:10 +0100, inigo delgado inigo.delg...@gmail.com
 wrote:
  Hi all:
  
  And sorry but my not to good english
  
  I'm pretty new in pygame, and in my freetime i'm doing a shooter based en
  star wars -sh!!! don't tell it to George, he don't know nothing-.
  
  Well, that's my problem. I'd and pretty xwing firing lasers and frying
  ties,
  so I decided to do the sound with pygame.mixer and...
  
  #~@|!#¬[ ! It's and incredible lag between the 'key is pressed' and
  'the
  sound is played' (about one second)
  
  I have a Ubuntu 9.10, so I googled and saw that the problem should be
 (and
  is) in SDL's interaction with pulseaudio (or in pulseaudio itself... i
  don't
  know). Well, I solved it unistalling pulseaudio and installing esound...
  but
  I think thats not the best solution... How do you do ubuntu
 compatibility?
  
  I've ear about pyaudio but I don't know... I'll prefer to ear your
  experiences before learning a new API
  
  How do you do the sound?
 
 It might help to give more detail about what you're doing, and how.
 
 But you might want to look at where in your program's main loop you're
 playing the sound. For instance, is the sound getting called only after
 some complex processing of other game events? That would delay the sound.

It is also a good idea to open up your sound files in audacity and check 
to see if they have any silence at the beginning of the file. If so, you 
can delete it easily.

---
James


Re: [pygame] Ncurses RTS?

2009-12-06 Thread James Paige
On Sun, Dec 06, 2009 at 05:34:30PM -0800, Yanom Mobis wrote:
I know this doesn't actually involve pygame, but I was wondering if it 
would be possible to use the Python Ncurses module to make a realtime  
strategy game. Something in the vein of dwarf fortress (you can see
screenshots at: http://www.bay12games.com/dwarves/screens.html ), but more 
of a traditional RTS than a rougelike/citybuilder game.

I am sure you could, but one word of warning is that python's standard 
curses module doesn't have a Windows version last time I checked 
(*checks again, yep*)

There is a wcurses work-alike module that you can find, although IIRC it 
has some minor differences that you will have to keep in mind if you 
want your game to work cross-platform.

Gosh I love/hate Dwarf Fortress :)

---
James Paige


Re: [pygame] Re: loss of rapidly repeated keypresses (from a barcode gun keyboard)

2009-12-03 Thread James Paige
On Wed, Dec 02, 2009 at 04:39:00PM -0800, Brian Fisher wrote:
What that suggests to me is that the problem lies with the way the USB
barcode scanner interacts with system components, well below the
application layer. So like maybe with the HID driver or windowing system
of your computer.
 
I'd try it on a different platform, to confirm.

I just wanted to mention that I tested this on a Mac OS X 10.3 box 
today, and the barcode scanner never dropped any characters at all with 
pygame, so you may be on to something here.

...Although that still doesn't explain why it has no problem with any of 
the non-SDL apps I have tested on Linux.

---
James Paige


Re: [pygame] loss of rapidly repeated keypresses (from a barcode gun keyboard)

2009-12-03 Thread James Paige
On Thu, Dec 03, 2009 at 12:12:14AM -0600, Jake b wrote:
Have you tried changing .key.set_repeat(something_small) ?

I tried that, but it made no difference.

And how are you polling for the events?

Here is my test code:


#!/usr/bin/env python

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480))
font = pygame.font.Font(None, 24)
clock = pygame.time.Clock()

text = 

def say(s, ypos, col=(255,255,255)):
  img = font.render(s, True, col)
  screen.blit(img, (0, ypos))
  if img.get_rect().width  screen.get_rect().width:
return True # overflowed the screen width
  return False

while True:
  clock.tick(60)
  for event in pygame.event.get():
if event.type == pygame.QUIT:
  raise SystemExit
if event.type == pygame.KEYDOWN:
  if event.key == K_ESCAPE:
raise SystemExit
  text += event.unicode
  screen.fill((0,0,0))
  say(If first input comes from a barcode gun keyboard,, 0)
  say(repeated characters will be lost., 20)
  if say(text, 80, (128, 255, 128)):
text = 
  pygame.display.flip()



Re: [pygame] loss of rapidly repeated keypresses (from a barcode gun keyboard)

2009-12-03 Thread James Paige
On Thu, Dec 03, 2009 at 05:04:05PM +, René Dudfield wrote:
Hi,
 
I think this has to do with SDL and xevents.  It's possible SDL can lose
events if they come in too fast.  Since it tries to prevent flooding of
the event queue.  Well it does for mouse events anyway.
 
I can't remember if they fixed/changed stuff for the recent 1.2.14
release... but it's worth trying out if you haven't already.

Interesting. My main Linux testing box has SDL 1.2.13. I'll give it a 
shot.

Also, maybe try out the 'xev' command - which prints x events.  Then you
can see if it is printing out all the events at the X level.
man xev

I just tried that, and no X events are being lost.

Oh, also, I figured out why I was getting almost universal failure in my 
test app but only the first scan was failing in my production app.

In the production app I was only testing with barcodes, and only the 
first scan would lose repeitious events.

In my simplified test app, I was actually switching between the barcode 
scanner and my regular keyboard. I would scan 222333 and then 
I would type z to have a visual delimiter between that and the next 
scan. When I did that, almost every single scan would lose events.

So it seems that SDL actually only loses events from the first scan 
after the main keyboard has been used.

I tested this further, by launching my test.py script, testing it, then 
closing it only using the mouse, then running it again only using the 
mouse. Then the first scan did NOT lose events.

This is very encouraging to me, since it means that solving this problem 
or working around it is no longer a critical issue for me, since this 
barcode application is going to be running on an embedded computer with 
no main keyboard anyway..

But I do still want to solve this mystery from a mystery-solving 
perspective. I just no longer need to solve it from a 
getting-my-work-done perspective :)

---
James


Re: [pygame] Re: loss of rapidly repeated keypresses (from a barcode gun keyboard)

2009-12-03 Thread James Paige
On Thu, Dec 03, 2009 at 09:26:18AM -0800, Brian Fisher wrote:
On Thu, Dec 3, 2009 at 8:54 AM, James Paige b...@hamsterrepublic.com
wrote:
 
  ...Although that still doesn't explain why it has no problem with any of
  the non-SDL apps I have tested on Linux.
 
pyglet is non-SDL, and you saw the same problem with pyglet, yeah? So
either SDL has some problem that pyglet also has, or they both use some
common mechanism that the console and other apps don't.

Ah, interesting! I had mistakenly assumed that pyglet also used sdl (I 
knew it uses opengl, but I had incorrectly assumed that it was using 
sdl+opengl together)

Assuming a new SDL doesn't simply fix it for you, pyglet source should be
easily available and fairly easy to read (being pure python), so you might
be able to understand the problem better by looking at pyglet. And you
could modify it pretty easily too.

Good idea. maybe I will take a look at that. I was browsing through SDL 
source code yesterday, but my learning curve was feeling pretty slow :)

---
James


Re: [pygame] Re: loss of rapidly repeated keypresses (from a barcode gun keyboard)

2009-12-02 Thread James Paige
On Wed, Dec 02, 2009 at 03:07:30PM -0600, Luke Paireepinart wrote:
  3) Reading the SDL Mailing list, I learned that event loss when the
  event queue is full is already a topic of discussion for SDL1.3
 
I wouldn't think this is the issue you're running into, otherwise you'd
lose other characters too.  It sounds like there's some debouncing code in
the SDL keyboard input handler, which probably shouldn't be there...

Yes, that is right. 1234567890 never drops a single event, but 
11 almost always drops all but one or two events... although 
this behavior is strangely inconsistent. In my stripped-down mimimal 
test app, the events are lost almost 100% of the time. In my actual full 
aplication, the events are only ever lost on the first scan. Weird.

I'm sure you've already thought of this, but you could always just open
/dev/keyboard or whatever and manually post keyboard events yourself, or
just use the keyboard data directly...

I have no idea where to look for the usb keyboard device associated with 
the barcode scanner... and even if I could find it, I am fairly certain 
that my app would have to be running as root if I wanted to read 
directly fom it, so that would be unacceptable :(

And you could even roll this in to
a module so other people could use it too.  Might be hard to make it
cross-platform though and it sucks to have to completely throw out SDL's
keyboard event handling.  Also I don't know how you'd keep SDL from
posting repeated events, I guess you'd just create your custom events
under a different event ID and just watch for that ID instead.

Re-implementing my application in pygtk or wxpython sounds like a hell 
of a lot less work :)

  4) I also discovered, while searching for a workaround, an SDL mailing
  list post from Sam Lantinga last January mentioning a simple callback
  mechanism for SDL events that bypasses the event queue. Does anybody
  know if there is a pygame way to make event callbacks?
 
I don't know, but I'd guess it would be possible with Pygame-Ctypes.  But
I think Alex is no longer maintaining that module in preference to his
Pyglet module.

I did a quick test with Pyglet, and it suffers from the same problem. I 
take that to mean that using sdl event callbacks does not work around 
this problem.

---
James Paige


Re: [pygame] Re: loss of rapidly repeated keypresses (from a barcode gun keyboard)

2009-12-02 Thread James Paige
On Wed, Dec 02, 2009 at 04:39:00PM -0800, Brian Fisher wrote:
On Wed, Dec 2, 2009 at 1:51 PM, James Paige b...@hamsterrepublic.com
wrote:
 
  I did a quick test with Pyglet, and it suffers from the same problem. I
  take that to mean that using sdl event callbacks does not work around
  this problem.
 
What that suggests to me is that the problem lies with the way the USB
barcode scanner interacts with system components, well below the
application layer. So like maybe with the HID driver or windowing system
of your computer.

As I said before, the scanner never drops even a single char when the 
keyboard focus is on the console, a terminal, a text editor or a word 
processor. I think it is safe to say that neither HID or windowing 
system can be to blame.

I'd try it on a different platform, to confirm.

I will try Mac and Windows tomorrow, although I have to stick to Linux 
for the final product.

... and as far as workarounds go, maybe you can build this into the game
design? Like make gameplay be about how digits change? or the number of
distinct digits found? something like that...

Heh, although making a Barcode Battler game sounds like fun, :) this 
is actually a business app for data-entry. I chose pygame for the job 
because of easy fullscreen support, easy sound effect support, and (I 
thought) easy keyboard input handling.

---
James Paige


Re: [pygame] Limited Range?

2009-11-04 Thread James Paige
A quick test with the timeit module suggest that the ** operator is not 
slower.

x*x and x**2 are exactly the same speed.

However, you are correct that x**0.5 is a slow operation.
raising something to the power of 0.5 is the same as taking its square 
root

x**0.5 is the same as math.sqrt(x)

Here is how I would write the distance check:

def is_in_range(enemy, tower):
  return (enemy.x-tower.x)**2 + (enemy.y-tower.y)**2 = tower.range**2

---
James Paige


On Tue, Nov 03, 2009 at 09:24:50PM -0500, Michael George wrote:
 If you find this is too slow, you'll get much better performance by 
 removing the **'s, they're quite slow compared to other arithmetic.  Use 
 x*x instead of x**2 and square both sides of the inequality to remove 
 the **0.5.
 
 P.F.C. wrote:
 I'm not getting the attachment but this might help.
 
 If your doing range as a circle with radius = r then:
 
 if ((enemy.x-tower.x)**2+ (enemy.y-tower.y)**2)**0.5=r: attack!!!
 
 basically, you'd be using Pythagorean theorem to find the distance to 
 check if it attacks or not.
 
 Checking distances for every tower and every unit could become a 
 bottle neck but would work.
 
 If you have performance problems you could also incorporate a grid.
 When every unit moves it can do a check to see in what section of the 
 map it is found in (ie, grid could have 10x10 tiles in each square) 
 and you would only check the distance of creeps in the grids that are 
 in range of the tower.
 
 One thing to keep in mind would be that in some cases you may be able 
 to stop the iteration as soon as you find someone who is attackable 
 (if the tower attacks random creeps) otherwise you just compare the 
 distances of the creeps and sort.
 
 You may want to google for circle collision detection
 
 
 -- Maranatha!
 -
 PFC aka Fezzik aka GAB
 
 
 On Tue, Nov 3, 2009 at 8:27 PM, Yanom Mobis ya...@rocketmail.com 
 mailto:ya...@rocketmail.com wrote:
 
 so, I wrote this tower defense game (zip archive attached) and I
 was wondering how I should go about implementing limited range
 (each tower can only shoot so far) in the code.
 
 
 
 
 


Re: [pygame] Limited Range?

2009-11-04 Thread James Paige
On Wed, Nov 04, 2009 at 05:23:42PM +, Kris Schnee wrote:
 On Wed, 4 Nov 2009 09:21:58 -0800, James Paige b...@hamsterrepublic.com
 wrote:
  A quick test with the timeit module suggest that the ** operator is not
  slower.
 
  Here is how I would write the distance check:
  
  def is_in_range(enemy, tower):
return (enemy.x-tower.x)**2 + (enemy.y-tower.y)**2 = tower.range**2
 
 If speed is important, how about trying a cruder orthogonal method?
 
 def IsInRange(enemy,tower):
 return (enemy.x-tower.x) + (enemy.y-tower.y) = tower.range

Did you mean?:

def IsInRange(enemy,tower):
return abs(enemy.x-tower.x) + abs(enemy.y-tower.y) = tower.range

That gives you a diamond-shaped range instead of a round range, which 
would be fine for some games, but maybe not a tower defence game.

I was curious how much faster it would be, so I ran some tests:

ja...@rhinoctopus:~/tmp$ ./timeit.py -n 1000 'import range1'
15 10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . # . . . . . . . . . . . . . . 
. . . . . . . . . . . . # # # # # # # . . . . . . . . . . . 
. . . . . . . . . . # # # # # # # # # # # . . . . . . . . . 
. . . . . . . . . # # # # # # # # # # # # # . . . . . . . . 
. . . . . . . . . # # # # # # # # # # # # # . . . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . # # # # # # # # X # # # # # # # # . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . . . # # # # # # # # # # # # # . . . . . . . . 
. . . . . . . . . # # # # # # # # # # # # # . . . . . . . . 
. . . . . . . . . . # # # # # # # # # # # . . . . . . . . . 
. . . . . . . . . . . . # # # # # # # . . . . . . . . . . . 
. . . . . . . . . . . . . . . # . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
1000 loops, best of 3: 0.976 usec per loop
ja...@rhinoctopus:~/tmp$ ./timeit.py -n 1000 'import range2'
15 10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . # . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . # # # . . . . . . . . . . . . . 
. . . . . . . . . . . . . # # # # # . . . . . . . . . . . . 
. . . . . . . . . . . . # # # # # # # . . . . . . . . . . . 
. . . . . . . . . . . # # # # # # # # # . . . . . . . . . . 
. . . . . . . . . . # # # # # # # # # # # . . . . . . . . . 
. . . . . . . . . # # # # # # # # # # # # # . . . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . # # # # # # # # X # # # # # # # # . . . . . . 
. . . . . . . . # # # # # # # # # # # # # # # . . . . . . . 
. . . . . . . . . # # # # # # # # # # # # # . . . . . . . . 
. . . . . . . . . . # # # # # # # # # # # . . . . . . . . . 
. . . . . . . . . . . # # # # # # # # # . . . . . . . . . . 
. . . . . . . . . . . . # # # # # # # . . . . . . . . . . . 
. . . . . . . . . . . . . # # # # # . . . . . . . . . . . . 
. . . . . . . . . . . . . . # # # . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . # . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
1000 loops, best of 3: 0.969 usec per loop

So I think the difference is too small to be worth it.

range1 and range2 are just two copies of this script, with one of the 
tests commented out at the end:


#!/usr/bin/env python

width = 30
height = 20

center_x = int(width / 2)
center_y = int(height / 2)

radius = 8

print center_x, center_y

def in_range(x1, y1, x2, y2, r):
  return (x1 - x2)**2 + (y1 - y2)**2 = r**2

def in_ortho_range(x1, y1, x2, y2, r):
  return abs(x1 - x2) + abs(y1 - y2) = r

def draw_field(dist_func):
  for y in xrange(height):
for x in xrange(width):
  if x == center_x and y == center_y:
print X,
  elif dist_func(x, y, center_x, center_y, radius):
print #,
  else:
print .,
print 

draw_field(in_range)
draw_field(in_ortho_range)


Re: [pygame] Limited Range?

2009-11-04 Thread James Paige
On Wed, Nov 04, 2009 at 10:31:24AM -0800, Ian Mallett wrote:
On Wed, Nov 4, 2009 at 9:21 AM, James Paige b...@hamsterrepublic.com
wrote:
 
  x**0.5 is the same as math.sqrt(x)
 
x**0.5 is faster than math.sqrt()
Ian

Interesting! You are absolutely right about that.
x**0.5 takes about 1/3 of the time that math.sqrt(x) does.

I wonder why?

(googles)

part of the overhead comes from looking up sqrt in the math 
namespace. That can be avoided by doing from math import sqrt

But even then, sqrt() is still slower because it links to the sqrt() C 
function, whereas x**0.5 uses python's own implementation.

Good to know! Thanks for bringing that to my attention.

---
James Paige


Re: [pygame] Advice on turning sprite (newbie)

2009-10-26 Thread James Paige
On Mon, Oct 26, 2009 at 04:03:20PM +, AdamC wrote:
 Currently, the tank moves around (although only once every time the
 key is pressed down - it doesn't move again if you hold the key down).
 
 Also, the tank doesn't turn. It would be nice to clear up these couple
 of problems.
 
 Here is the code as it stands:
 
 http://dpaste.com/112175/
 
 Thanks
 Adam

Your tank's .move_me() method should be called once in every single 
cycle of the while loop. You should not be calling it at all inside 
the event.key checks. I would put tank.move_me(x_move, y_move) right 
before the screen.blit(background, (0,0))

---
James Paige


Re: [pygame] Tower Defense game criticism

2009-10-18 Thread James Paige
On Sun, Oct 18, 2009 at 06:12:15PM -0700, Yanom Mobis wrote:
I recently wrote a simple tower-defense game (zip archive attatched to the 
email). I'd like to know what you like, what you don't, what improvements  
I could make, etc. 

I couldn't figure out how to do anything other than watch my towers get 
overrun.

Most woer defense games I have played are based on maze-like passages. 
This free-form open-space layout can be interesting, but as it is now it 
is over way to fast. It should start out slow, and only get harder 
slowly.

Also, it looked to me as if all the towers had unlimited range. I think 
limited range is a pretty important gameplay element for a tower defense 
game.

---
James Paige


Re: [pygame] Function Inheritance

2009-10-14 Thread James Paige
On Wed, Oct 14, 2009 at 05:27:50PM -0400, Kris Schnee wrote:
 This is more of a general Python question.
 
 [clip..]
 
 Seems cumbersome, doesn't it? I'm basically trying to give my new class 
 access to the neat functions while putting them into a separate module, 
 so that the main module isn't cluttered by them. Or should I rely on a 
 linear chain of inheritance, so that FancyClass is a subclass of 
 BasicClass from another module?

Make FancyClass a subclass of BasicClass from another module. I do that 
frequently. Works great, very simple.

---
James


Re: [pygame] Function Inheritance

2009-10-14 Thread James Paige
On Wed, Oct 14, 2009 at 10:37:41PM -0400, Kris Schnee wrote:
 Kevin wrote:
 Don't forget Python supports multiple inheritance as well, which can be 
 very useful.
 
 So that'd be like so:
 
 class Basic:
   def __init__(self):
 pass
   def DoStuff(self):
 print Hello World
 
 class Advanced( Basic, SomeOtherClass ):
   def __init__(self):
 Basic.__init__(self)
 SomeOtherClass.__init__(self)
 
 Basically, putting my basic functions into a class just for the sake of 
 copying them all over into a new class at once. I thought multiple 
 inheritance was kind of frowned upon...? But it does sound like the best 
 route to do what I'm doing in a tidy and reliable way. Thanks to everyone.

I think it is mostly frowned upon in other languages because of 
ambiguity over which parent takes priority. I don't think that is an 
issue with python.

I think another reason it is frowned upon is that if you go overboard 
with it you can end up with a needlessly complicated class heirarchy.

But used in moderation with an understanding of how it works, you should 
be fine with it.

But perhaps someone else knows some complaints about multiple 
inheritance that I am not aware of...

---
James Paige


Re: [pygame] Capture tablet pressure?

2009-10-11 Thread James Paige
On Sun, Oct 11, 2009 at 03:21:20PM -0700, Eric Pavey wrote:
Been searching around, and haven't come up with anything:  Anyone know how
to capture tablet pressure in Pygame?  Pygame recognizes my tablet (Wacom
Bamboo) just fine as a mouse, buttonclicks etc, but no pressure based on
those clicks.  Any advice?  Is it possible that SDL doesn't support
tablets?
 
thanks

No, I'm pretty sure SDL does not have any pressure support. Although I 
think that pressure sensitivity and multitouch may be planned for SDL 
1.3/2.0, (maybe somebody can correct me if I am mistaken on that)

I remember hearing a rumor that pygtk supports pressure sensitivity, but 
making pygame and pygtk work together might prove to be more trouble 
than it is worth.

Also, some quick googling turns up pymt, which might be helpful, but I 
haven't tried it myself.

---
James


Re: [pygame] 10 bits per color

2009-10-01 Thread James Paige
On Thu, Oct 01, 2009 at 09:34:35AM -0400, pierrelafran...@sympatico.ca wrote:
  Sounds lik yet another gimmick to get uneducated folk to buy another TV
 LOL, I like this one.
 But I'm not sure I understand your statement on NTSC.
 
 This is what my research subject is all about.  My boss asked me to
 optimize my hardware design (0.35u CMOS image sensor) to fit eyes and
 equipement limitations.  But I need first to create RGB101010 software
 to see if DeepColor makes sense or not, before optimizing CMOS chips.
 Since I like Python and I have Pygame experiences, I wanted to do that
 software with Pygames.
 
 Thanks
 
 Pierre

Regarding the limitations on the human eye: I am no expert on this, but 
from what I have read, the average human eye can distinguish somewhere 
from 7 to 10 million different colors.

RGB888 is 24 bit color, which is enough for over 16 million colors.

So by that measure, average human eyes should not be able to tell the 
difference between RGB888 and RGB101010

Of course, I am no expert on this, and I know that the way the rods and 
cones in an eye encode color is very different from the way digital 
color is encoded in pixels, so there may possibly be other reasons why 
RGB888 might be less that mathematically perfect for human color vision.

I would be interested to hear from someone who IS an expert. Do we have 
any Opticians on-list? :)

---
James Paige


Re: [pygame] 10 bits per color

2009-10-01 Thread James Paige
On Thu, Oct 01, 2009 at 09:57:32AM -0700, Brian Fisher wrote:
Your facts are all basically correct, but some things you are missing is
the fact that human vision is both dynamic in terms of it's ability to
perceive ranges of intensity and color and able to support a very wide
contrast ratio (around 1,000,000 to 1) compared to what contrast ratio
monitors are currently pumping out (somewhere between 350:1 to 1000:1)
(btw, our perception is basically decibel based, so it's more like the
best monitors are 1/4th of what we can do rather than 1/1000th)
 
What that means is our monitors are pretty much crap when it comes to
maxing out our eyes contrast-wise, and that even though our eyes have
limited color perception, the limits and use of that limited color
perception depend on what we are looking at - or to put another way, which
7-10 million colors the average person is distinguishing depends largely
on what colors and intensities there are to look at. (btw, this is why
contrast ratio doesn't matter so much for home or movie theatres with
paltry contrast ratios of 1:500 but the environment is blacked out - our
vision readjusts very well to just using the range provided)
 
The big thing about all this new monitor stuff is the new high-contrast
displays, as Pierre said new TV with
retro light using LEDs has higher contrast (up to 200:1 wich is about
126 DB dynamic range). People who have seen those new monitors have told
me the pictures looked like real life, that it was like looking out a
window, not at a monitor.
 
With those new high contrasts though, if you aren't using the full
contrast range for a particular scene, RGB888 can be way too small. So
more range is needed if you wanna do something like go from a cave to the
out of doors - if the cave is half as bright with RGB888, you dropped half
your range, to RGB777, and your eyes can start seeing bands and such
better.

So the big difference, if I inderstand you correctly, is: RGB888 is over 
16 million colors MAX, but the average human eye, being dynamic, 
distinguishes somewhere around 7 to 10 million colors AT A TIME.

RGB is designed to be close to our rods and cones, which for most people
see an R with very good color range, a G with good color range, and a B
with mostly OK color range (relatively speaking). That's why many
restricted bit color schemes with uneven bit allocation put the extra bits
in the R or G but never the B. But there are actually some people (I've
heard they are mostly if not all women) with an extra cone (I think) that
is pretty close to the B, and those people have amazing color perception
much much better than RGB888, and usually work in color and print related
fields cause they can do things like match paint samples and colors at a
level beyond what us normal people can.

I have heard of that! Tetrachromatism!

Apparently the most common forms of red-colorblindness and 
green-colorblindness are not that the red or green cones are missing, 
but that they are present but picking up the wrong wavelengths. So if 
you are Red-blind that means your cones are GgB Green, Different Green, 
and Blue. And if you are green-blind then your cones are Red, Different Red, 
and Blue. RrB

Both mutations are carried on the X chromozome, and both are recessive 
traits. Since women have two copies of the X chromosome, they rarely 
have any colorblindness, because they almost always have a good copy 
of the Red or Green gene on the other X, but men having just one X are 
far more likely to have colorblindness.

Tetrachromatism (If I recall correctly) happens when a woman gets one 
different kind of colorblindness on each X. Somehow, sometimes this 
results in the Other Red and Other Green cones combining to behave 
like a population of Orange cones, so her vision is effectively 
Red-Orange-Green-Blue and she can see orange as if it was a primary 
color, instead of as a secondary color like most of the rest of us do.

---
James Paige


Re: [pygame] 10 bits per color

2009-10-01 Thread James Paige
/CarlsbadCaverns?page=6
The brightness-adjusted photos are really easy to spot in comparison to 
the flash-photos because of the color-shift.

---
James Paige



Re: [pygame] 10 bits per color

2009-09-30 Thread James Paige
On Wed, Sep 30, 2009 at 07:46:01PM -0400, pierrelafran...@sympatico.ca wrote:
 Hi
 Is Pygame supports 10 bits per color (ex RGB101010) ?
 Windows 7 is going to support it
 Thanks!
 
 Pierre

Pygame uses the SDL library for graphics, so you should ask at the 
libsdl mailing list whether or not a future version of SDL will support 
it. http://www.libsdl.org/mailing-list.php

---
James Paige


Re: [pygame] EXE: Narrowing Down the Problem

2009-09-18 Thread James Paige
On Fri, Sep 18, 2009 at 03:36:35PM +, Kris Schnee wrote:
 Could it be that I'm doing something wrong with the basic steps involved?

I can't tell you if this is causing your problems, but you definitely 
don't want to be copying your .py file or anything else into C:\Python26

You should not be manually modofying that directory or anything in it.

 -Copy the .py files used in the program to C:\Python26
 -Have a setup.py in that directory too
 -Open a command prompt and go to C:\Python26

Your program should be somewhere else. I usually keep mine in My 
Documents\src\projectname

 -Type python setup.py py2exe
 -Go to C:\Python26\dist
 -Copy relevant graphics c. directories into C:\Python26\dist; N/A for test
 program
 -Type the program's name as an EXE
 -Copy *.dll from C:\Python26\libs\site-packages\pygame when that doesn't
 work, along with freesansbold.ttf, and try again.

I don't know whether working in the C:\python26 directory could be 
interfering with the operation of py2exe, but it is not impossible.

I have done all of my py2exe packaging using python 2.5
If I get a chance to upgrade to 2.6 I'll let you know if your simple 
text case works for me.

---
James Paige


Re: [pygame] Numeric wireless keyboard

2009-09-09 Thread James Paige
Have you asked on the SDL mailing list yet? Since this does indeed seem 
to be an SDL problem, they are likely to be interested in the problem 
too.

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

---
James Paige

On Wed, Sep 09, 2009 at 08:52:38PM -0400, pierrelafran...@sympatico.ca wrote:
 Hi
 I have succeffully (with a certain amount of pain to update Ubuntu and
 ARM systems  ;-)  compiled a SDL program.
 
 On ARM system, SDL doesn't receive good event ID (if I may call it like
 this).  When pressing any digit from wired keyboard, it works fine.
 When pressing any digit from wireless keyboard, it receive : numlock
 key was pressed.
 
 So Pygames is out of the loop, like you all suspected (I have to learn).
  Now what do I do to progress in my investigation ?
 Can I recompile SDL with different options ?
 Is SDL relies on an other librairy ?
 Both system have libsdl version 1.2
 
 Thanks
 
 -- 
 Pierre Lafrance
 
 pierrelafran...@sympatico.ca wrote:
  James Paige wrote:
  On Thu, Aug 20, 2009 at 08:58:27AM -0400, pierrelafran...@sympatico.ca 
  wrote:
  René Dudfield wrote:
  yeah, looks like somewhere the keyboard mappings aren't working.
  Likely in linux, C or SDL land.
 
  This is not a pygame level issue.
 
  Check on the SDL mailing list, or the arm platform mailing list perhaps?
 
 
  cheers,
 
 
  Hi Rene.
  What I don't understand is :
  + The alphanumeric keyboards works fine with ARM plateform and Pygame
  + The numeric keyboard works fine with ARM plateform in a text editor
  + The numeric keyboard does't works fine with ARM plateform and Pygame
 
  So I'm not sure what to look at yet since hardware and software is ok.
  Anyway, I'll keep you post on progress
 
  Thanks
 
  Pierre
  I would suggest writing a very small test program in C using SDL. You 
  can find some suitable example code at 
  http://www.libsdl.org/intro.en/usingevents.html
 
  Compile it with gcc, and use it to test and see if this problem affects 
  the underlying SDL library when python and pygame are not involved.
 
  That will narrow down where the problem is.
 
  ---
  James Paige
 
 
  Hi
  I have succeffully (with a certain amount of pain to update Ubuntu and
  ARM systems ;-) compiled a SDL program.
  
  On ARM system, SDL doesn't receive good event ID (if I may call it like
  this).  When pressing any digit from wired keyboard, it works fine.
  When pressing any digit from wireless keyboard, it receive : numlock
  key was pressed.
  
  So Pygames is out of the loop, like you all suspected (I have to learn).
   Now what do I do to progress in my investigation ?
  Can I recompile SDL with different options ?
  Is SDL relies on an other librairy ?
  Both system have libsdl version 1.2
  
  Thanks
  
 
 
 
 


Re: [pygame] Picking monitor...

2009-08-30 Thread James Paige
On Sun, Aug 30, 2009 at 11:10:30AM -0700, Gene Buckle wrote:
 On Sun, 30 Aug 2009, Brian Fisher wrote:
 
 On Fri, Aug 28, 2009 at 10:08 AM, Gene Buckle ge...@deltasoft.com wrote:
 
 The main issue is that the avionics computer will have more than a couple
 of these USB video adapters.  Is it possible to discover the current 
 window
 position from within pygame?  That would allow me to manually position the
 window and then save the current position as the start position.
 
 Hey Gene,
   stuff like that is always possible - and ctypes is usually the best way
 to do little hack stuff like this in python.
 
 For getting the window pos, the function pygame.display_get_info gives 
 you
 a dictionary with window set the HWND of your window, and the OS function
 GetWindowRect can be called on that HWND to get the window position/size
 
 
 Thanks for that Brian!  I found out I had another problem on Friday.  It 
 seems that OpenGL isn't working in a window on my auxillary adapters.  The 
 scene is frozen and just smears as I move the window around.  I think I'm 
 pretty much SOL until the 1.3 version of SDL comes out.  My only other 
 choice is DirectX and I really don't want to have to go there if I don't 
 have to.
 
 Thanks!

If these auxillary adapters are anything like the USB video adapters I 
have used myself, they just flat out don't support 3D acceleration of 
any kind. SDL 1.3 and DirectX will not help. They will have the same 
problem as OpenGL does.

I am going to guess that you will have to do software rendering if you 
want any kind of 3D. (And software rendering at good speeds only works 
at /very/ low resolutions)

---
James


Re: [pygame] Picking monitor...

2009-08-28 Thread James Paige
On Thu, Aug 27, 2009 at 08:13:56PM -0700, Gene Buckle wrote:
 
 Is it possible to choose which display pygame uses for full screen mode? 
 If so, how is it done?
 
 thanks!
 g.

pygame is built on SDL version 1.2, and SDL version 1.2 does not have 
the ability to control which screen is sused for fullscreen. it will 
take whichever screen is identified as being primary.

SDL version 1.3 adds commands like SDL_GetNumVideoDisplays() and 
SDL_SelectVideoDisplay()

SDL 1.3 is actually a testing version, and when it matures to a public 
release, it will be renamed SDL 2.0. After that point, maybe pygame will 
migrate to it (and correct me if I am wrong, but I think somebody is 
already working on this, right?)

---
James Paige


Re: [pygame] Numeric wireless keyboard

2009-08-25 Thread James Paige
On Tue, Aug 25, 2009 at 01:14:52AM -0400, pierrelafran...@sympatico.ca wrote:
 James Paige wrote:
  On Thu, Aug 20, 2009 at 08:58:27AM -0400, pierrelafran...@sympatico.ca 
  wrote:
  René Dudfield wrote:
  yeah, looks like somewhere the keyboard mappings aren't working.
  Likely in linux, C or SDL land.
 
  This is not a pygame level issue.
 
  Check on the SDL mailing list, or the arm platform mailing list perhaps?
 
 
  cheers,
 
 
  Hi Rene.
  What I don't understand is :
  + The alphanumeric keyboards works fine with ARM plateform and Pygame
  + The numeric keyboard works fine with ARM plateform in a text editor
  + The numeric keyboard does't works fine with ARM plateform and Pygame
 
  So I'm not sure what to look at yet since hardware and software is ok.
  Anyway, I'll keep you post on progress
 
  Thanks
 
  Pierre
  
  I would suggest writing a very small test program in C using SDL. You 
  can find some suitable example code at 
  http://www.libsdl.org/intro.en/usingevents.html
  
  Compile it with gcc, and use it to test and see if this problem affects 
  the underlying SDL library when python and pygame are not involved.
  
  That will narrow down where the problem is.
  
  ---
  James Paige
  
  
 Hi
 I'm compiling the code (my first prg with gcc), and doesn't find SDL.h.
  I have done a find on SDL (find -name SDL.h), without success. Where
 and how can I find this file ?  Do I have to install SDL ? (I'm assuming
 Python is using it and its there...)
 
 Thanks!

Your probably don't have the development files for SDL installed. If I 
recall correctly, pygame only uses the runtime files, and doesn't need 
the development files.

If you are using Debian or a derivative like Ubuntu, you need to install 
the libsdl1.2-dev package. I don't know the package name for other 
distributions, but it will be something similar.

---
James Paige


Re: [pygame] Pygame Installation problems (Python 2.6.2)

2009-08-20 Thread James Paige
Has anybody tried to build a 64-bit pygame? (either Windows or Linux?) I 
assume that would mean building 64-bit versions of all the dependancy 
libraries too.

I would give it a shot myself, but I don't actually have any 64 bit 
machines :)

---
James


On Thu, Aug 20, 2009 at 10:26:56AM -0700, Scott K. wrote:
It's really my own fault for not paying attention.  I did have 64bit
Python 2.6.2 installed and then tried to install the 32bit Pygame (for
2.6) which of course didn't work. 
 
I got rid of the 64bit Python and installed 32bit Python and now pygame is
recognized with no problems.
 
 Date: Thu, 20 Aug 2009 08:57:15 +0100
 Subject: Re: [pygame] Pygame Installation problems (Python 2.6.2)
 From: ren...@gmail.com
 To: pygame-users@seul.org

 I'll have to put a note on the download page for win64 peoples on what
to do.

 I guess there are a few people using 64bit windows now.

 cheers,
 
  --
 
Get back to school stuff for them and cashback for you. Try BingT now.


Re: [pygame] Pygame Installation problems (Python 2.6.2)

2009-08-20 Thread James Paige
Ah, that is cool. I had a feeling it would be easy on Linux ;)

My comment about manually building the dependencies was actually 
directed to the 64-bit Windows side of things.

For 64-bit Linux all that needs to be done is verification that 64-bit 
works (as you have done)

For 64-bit Windows, I think it might be good to actually post a prebuild 
installer alongside the 32-bit one on pygame.org

---
James

On Thu, Aug 20, 2009 at 07:33:47PM -0400, Evan Kroske wrote:
I just built Pygame on a 64 bit Ubuntu Linux Intrepid Ibex, but I didn't
compile the dependencies myself. No compile errors, but 8 errors and 2
failures in the tests. Output is attached. Is this what you were asking
for, James?
 
On Thu, Aug 20, 2009 at 4:14 PM, Lenard Lindstrom le...@telus.net wrote:
 
  Hi James,
 
  I did compile the dependencies once with gcc 4.x since the 64bit cross
  compiler is itself a 4.x version. But that is as far as I got. I too
  don't have a 64bit machine.
  Lenard
 
  James Paige wrote:
 
Has anybody tried to build a 64-bit pygame? (either Windows or Linux?)
I assume that would mean building 64-bit versions of all the
dependancy libraries too.
 
I would give it a shot myself, but I don't actually have any 64 bit
machines :)
 
---
James
 
On Thu, Aug 20, 2009 at 10:26:56AM -0700, Scott K. wrote:
 
 
It's really my own fault for not paying attention.  I did have
  64bit
Python 2.6.2 installed and then tried to install the 32bit Pygame
  (for
2.6) which of course didn't work.
I got rid of the 64bit Python and installed 32bit Python and now
  pygame is
recognized with no problems.
 
 Date: Thu, 20 Aug 2009 08:57:15 +0100
 Subject: Re: [pygame] Pygame Installation problems (Python
  2.6.2)
 From: ren...@gmail.com
 To: pygame-users@seul.org

 I'll have to put a note on the download page for win64 peoples
  on what
to do.

 I guess there are a few people using 64bit windows now.

 cheers,
 
 
  
 --
 
Get back to school stuff for them and cashback for you. Try BingT
  now.
 
 
--
Evan Kroske
http://welcome2obscurity.blogspot.com/
The code, comments, and challenges of a novice
software developer desperate for attention.

 ==
 ERROR: MovieTypeTest.test_height
 --
 Traceback (most recent call last):
   File /home/evan/Source/pygame/test/_movie_test.py, line 124, in 
 test_height
 movie_file = trunk_relative_path('examples/data/blue.mpg')
 NameError: global name 'trunk_relative_path' is not defined
 
 ==
 ERROR: MovieTypeTest.test_init
 --
 Traceback (most recent call last):
   File /home/evan/Source/pygame/test/_movie_test.py, line 45, in test_init
 movie_file = trunk_relative_path('examples/data/blue.mpg')
 NameError: global name 'trunk_relative_path' is not defined
 
 ==
 ERROR: MovieTypeTest.test_play_pause
 --
 Traceback (most recent call last):
   File /home/evan/Source/pygame/test/_movie_test.py, line 58, in 
 test_play_pause
 movie_file = trunk_relative_path('examples/data/blue.mpg')
 NameError: global name 'trunk_relative_path' is not defined
 
 ==
 ERROR: MovieTypeTest.test_resize
 --
 Traceback (most recent call last):
   File /home/evan/Source/pygame/test/_movie_test.py, line 136, in 
 test_resize
 movie_file = trunk_relative_path('examples/data/blue.mpg')
 NameError: global name 'trunk_relative_path' is not defined
 
 ==
 ERROR: MovieTypeTest.test_rewind
 --
 Traceback (most recent call last):
   File /home/evan/Source/pygame/test/_movie_test.py, line 99, in test_rewind
 movie_file = trunk_relative_path('examples/data/blue.mpg')
 NameError: global name 'trunk_relative_path' is not defined
 
 ==
 ERROR: MovieTypeTest.test_stop
 --
 Traceback (most recent call last):
   File /home/evan/Source/pygame/test

Re: [pygame] default font

2009-08-12 Thread James Paige
On Wed, Aug 12, 2009 at 04:04:56PM +0200, Bo Jangeborg wrote:
 Two problems with pygame.font.SysFont:
 
 1.
 How do I determine which font face it actually returned ? If
 it fails it returns the default font, but how do I know that
 it failed ?
 
 2.
 If I make an exe file with py2exe,  freesansbold.ttf is not copied
 with it. So when I use pygame.font.SysFont it fails without
 an error message and just terminates the application. Try: and
 except: wont catch it which seems a bit harsh. It Took me a while
 to figure it out.
 I tried to put the font in the same directory as the exe and
 in the library.zip, and all over the place in the build
 directory but neither works. Any way to make it work ?
 Or is it broken ?
 
 Bo)

Personally I never use the default font. I always include the ttf file 
with my game's data files, and load it explicitly.

However, there is a workaround for the problem you describe here:

  http://pygame.org/wiki/Pygame2exe

I don't know how current that page is.

---
James Paige


Re: [pygame] Scrolling

2009-08-04 Thread James Paige

On Mon, Aug 03, 2009 at 05:58:48PM -0700, Yanom Mobis wrote:
so... blit them all to the screen and change their x and y values as you
scroll?

If you do that, you have to update the x/y of every single sprite or 
tile for every movement.

What I like to do is to make all my sprite position relative to the 
whole map.

Then I maintain a camera x/y position.

When I blit, I use sprite position minus camera position to get screen 
position.

---
James


Re: [pygame] The great pySchism, was: how to remove spam comments in pygame wiki

2009-08-03 Thread James Paige
On Fri, Jul 31, 2009 at 06:53:50PM -0700, Nirav Patel wrote:
 First, It is clear that having two pygame websites will do nothing but
 confuse the community of users and developers.

I just want to comment that I don't think that having two (or more) 
websites will really be confusing. I have a non-python project 
(OHRRPGCE) which has 5 different sites all run by different people with 
different (often overlapping) goals and it all works together pretty 
well in spite of having a much smaller active community than pygame has. 

I have not seen any evidence of user-confusion caused by the presence of 
more than one website (any user confusion is due to the messyness of 
the software, not the website ;)

---
James Paige


Re: [pygame] Sending key-pressing input to a window

2009-08-03 Thread James Paige
On Sun, Aug 02, 2009 at 06:22:24PM -0700, Ian Mallett wrote:
Hi,
 
I want to make a PyGame application that will send key press data to the
currently active window.  So, if I ran the program, and then switched to
another window, the program should send data to that window just as if I
had typed in that window.  Can it be done with PyGame?  Thanks,
 
Ian

pygame cannot do that.

I have never done this before. You might want to look at the pyhook 
and/or SendKeys packages, althouth I believe those are both 
windows-only. There is probably not any cross-platform python library to 
do this.

---
James Paige


Re: [pygame] Scrolling

2009-08-03 Thread James Paige
Is your scrolling map based on tiles?

if so, this problem gets easier...

---
James Paige

On Mon, Aug 03, 2009 at 11:30:25AM -0700, Yanom Mobis wrote:
well i need it to work with a BIG surface at 30 fps. and i need
something that would work with Rabbyt
 
  --
 
From: Casey Duncan ca...@pandora.com
To: pygame-users@seul.org
Sent: Monday, August 3, 2009 12:51:32 PM
Subject: Re: [pygame] Scrolling
You can blit a surface that is bigger than the pygame screen and it should
efficiently crop it for you without extra work on your part. At some point
though you will probably run into surface size limitations, in which case
you can just tile surfaces together.
 
In my experience with pygame, full screen blitting is really only fast
enough at fairly low resolutions. But of course YMMV.
 
-Casey
 
On Aug 3, 2009, at 11:32 AM, Yanom Mobis wrote:
 
 How is scrolling done in pygame? i was thinking of blitting all
gameobjects to a surface, then blitting part of that surface to the screen
like this:
 +-+
  |  +---+|
  |  |||
  |  +---+|
  ||
 +-+
 where the big box is the surface, and the small box is the screen.




Re: [pygame] noob questions about creating and playing sounds

2009-07-20 Thread James Paige
On Mon, Jul 20, 2009 at 09:44:45AM -0400, Jerzy Jalocha N wrote:
 Hi, I am starting to experiment with Pygame and how to generate sounds
 and play them back. Here is a code snippet, the full (working) code is
 below.
 
 def play_maxtime(sound, duration):
 sound.play(loops=-1, maxtime=duration)
 pygame.time.delay(duration)
 
 I have a few questions about this:
 
  * Why is it that play_maxtime doesn't work without the time.delay?
 When I remove the delay line, no sound is played, despite the use of
 the maxtime argument.

Because without that the program finishes and quits. You would not need 
the time.delay if you were using this in a game, since you would be 
playing your sounds inside the game's loop.

---
James Paige


Re: [pygame] diff util?

2009-07-10 Thread James Paige
On Fri, Jul 10, 2009 at 02:54:52PM -0500, Jake b wrote:
 My brother is getting interested in programming, so I'm showing him pygame.
 
 I need a 'diff' like utility that's easy to use in ideally geany/scite.
 
 It could be another program -- I need an easy way to show what lines are new.
 
 (we both are using win32)

Not sure if this is what you are looking for, but Geany has a built-in 
diff plugin called Version Diff which can be enabled from 
Tools-Plugin Manager

---
James Paige


Re: [pygame] Implementing save feature

2009-05-22 Thread James Paige
On Fri, May 22, 2009 at 02:23:45PM -0700, Nevon wrote:
 I'm currently part of a group developing a FOSS point-and-click
 adventure game using Python and Pygame. The game engine is actually a
 fork of the engine used in the game Colonel Wiljafjord and the
 Tarbukas Tyranny, and entry in Pyweek #3. Right now we're working on
 improving the engine in whatever way we can. If you're interested, the
 source is available here: 
 http://github.com/kallepersson/subterranean/tree/master.
 
 So now I'd like to implement a save/load feature, but I don't really
 know where to start. I have no idea how game save systems are usually
 constructed, so I'm kind of lost. If anyone has any ideas, links to
 resources, or pointers on how to best do this, please share.
 
 Thank you!
 
 Tommy Brunn
 http://www.blastfromthepast.se/blabbermouth

There are a lot of ways to do this.

What sort of game-state do you have? A big part of setting up a save 
game format is sorting out what data is runtime-state that doesn't 
matter for save games, and what data is persistant game state that needs 
to be saved.

I don't know how the engine works, but since it is a point-and-click 
adventure, I am going to say right off that you will probably be saving 
things like:

* hero's location
* hero's inventory
* whatever flags or bits or variables track who you have talked to and 
what quests you have completed

As for the format of the data, you have a lot of options. xml, pickle, 
json, yaml, binary files of you're own devising, etc. 

---
James


Re: [pygame] Re: Implementing save feature

2009-05-22 Thread James Paige
Well, I assume this is an open source game, so protecting the save state 
from editing is not of highly critical importance, right?

But you do want to inconvenience casual cheaters.

I suggest saving your state to an XML file, and then compressing that 
xml file with python's built-in zip module. Then rename the save zip 
some non .zip filename like .save so that double-clicking on a save file 
won't open it in your unzipping tool.

If you want to try harder to prevent cheating you can run your xml 
through some kind of scrambling, or obfuscation, but personally I don't 
think it is worth the trouble. But it's up to you of course.

---
James

On Fri, May 22, 2009 at 02:57:27PM -0700, Nevon wrote:
 Yeah, I figure those are the things I need to save. The location, the
 inventory and all the flags, bits and variables that are assigned as
 you go through the game. But how would I go about saving those things?
 And what data format would I choose to avoid players simply going in
 and editing the save game in plain text? Have there been any articles
 or tutorials written on this?
 
 On May 22, 11:50 pm, James Paige b...@hamsterrepublic.com wrote:
  There are a lot of ways to do this.
 
  What sort of game-state do you have? A big part of setting up a save
  game format is sorting out what data is runtime-state that doesn't
  matter for save games, and what data is persistant game state that needs
  to be saved.
 
  I don't know how the engine works, but since it is a point-and-click
  adventure, I am going to say right off that you will probably be saving
  things like:
 
  * hero's location
  * hero's inventory
  * whatever flags or bits or variables track who you have talked to and
  what quests you have completed
 
  As for the format of the data, you have a lot of options. xml, pickle,
  json, yaml, binary files of you're own devising, etc.
 
  ---
  James
 
 


Re: [pygame] Re: Implementing save feature

2009-05-22 Thread James Paige
Unfortunately, no, I don't have any good examples for you, because most 
of my xml experience has not been python based. You might want to look 
at the xml modules available in the python standard library 
documentation. You can choose from expat, minidom, pulldom, sax, 
elementtree, or maybe some I am forgetting. Maybe somebody else on the 
list can suggest which is the best match for pygame.

In general though, you will probably end up with a file that has a 
node for general data, with some named data elements inside it, and a 
node for inventory with a list of item elements inside it, and a node 
for flags with a list of flag elements inside it.

---
James

On Fri, May 22, 2009 at 03:09:59PM -0700, Nevon wrote:
 No, it's not super important. I just don't want to make too darn easy
 to cheat. Your way should suffice.
 
 Now what about storing the data in an xml-file. Do you have any
 examples of how this is done?
 
 On May 23, 12:04 am, James Paige b...@hamsterrepublic.com wrote:
  Well, I assume this is an open source game, so protecting the save state
  from editing is not of highly critical importance, right?
 
  But you do want to inconvenience casual cheaters.
 
  I suggest saving your state to an XML file, and then compressing that
  xml file with python's built-in zip module. Then rename the save zip
  some non .zip filename like .save so that double-clicking on a save file
  won't open it in your unzipping tool.
 
  If you want to try harder to prevent cheating you can run your xml
  through some kind of scrambling, or obfuscation, but personally I don't
  think it is worth the trouble. But it's up to you of course.
 
  ---
  James
 
 
 


  1   2   3   >