Re: [pygame] Problems with py2exe and Pygame

2007-12-05 Thread Chris Van Bael
Hi,

you can use the datafiles option in your setup.py to copy the font.

Maybe take a look at my setup.py script:
http://schoolsplay.svn.sourceforge.net/viewvc/schoolsplay/branches/childsplay_sp/windows/setup.py?view=markup
It's fairly straight forward.

Chris

On Dec 5, 2007 2:15 AM, Patrick Mullen [EMAIL PROTECTED] wrote:
 Yes my setup script uses py2exe on windows and cx_freeze on linux,
 while keeping the data movement code generally shared for either
 system.  So it is all in one nice, portable setup file.  Of course, I
 really am a loser.  Instead of using shutil, I wrote all of my own
 shell functions :)

 To answer the actual question...
 We really need to see what code is breaking to know what is wrong
 here.  I think you may need to specify an actual named font rather
 than relying on the default one, in order to pick up the ttf in the
 exe directory.  Uh, one more thing.  Try manually putting the font
 into library.zip.

 You'll be safest to manually load the font yourself though, with the
 pygame.Font function.


 On Dec 4, 2007 1:57 PM, Casey Duncan [EMAIL PROTECTED] wrote:
 
 
  On Dec 4, 2007, at 1:19 PM, Joe Johnston wrote:
 
   hwg wrote:
   I'm trying to make an exe of a simple Pygame program.
Here's the setup.py http://setup.py/:
from distutils.core import setup
   import py2exe, pygame
   import glob, shutil
   setup(windows=[lunarlander.py http://lunarlander.py/])
   shutil.copyfile('moonsurface.png', 'dist/moonsurface.png')
   shutil.copyfile('lunarlander2.png', 'dist/lunarlander2.png')
   shutil.copyfile('C:/Python25/Lib/site-packages/pygame/
   freesansbold.ttf',
   'dist/freesansbold.ttf')
  
   Maybe I'm a loser, but I generally keep the setup.py script short.
   If I've got to move files, I do that from a bat script which can
   call my Windows installer compiler too (inno, my case).
 
  A good reason to keep this stuff in python (regardless of whether it
  is in setup.py or not) is portability. bat files only work on
  Windows. But then again, absolute paths (especially ones that use
  drive letters) are highly non-portable anyhow no matter what language
  they're in (even on different machines that are running Windows).
 
  -Casey
 



Re: [pygame] Problems with py2exe and Pygame

2007-12-05 Thread Brian Fisher
On Dec 4, 2007 12:49 PM, hwg [EMAIL PROTECTED] wrote:
 The default font (freesansbold.ttf) does get copied over to the dist
 folder.  (I saw some posts about that problem)  But the error log when I try
 to run it says this:

 Traceback (most recent call last):
   File lunarlander.py, line 111, in module
   File lunarlander.py, line 49, in display_stats
 RuntimeError: default font not found
 I'm running python 2.5.1, Pygame 1.7.1 and a recent version of py2exe (I
 don't know how to find the version number, but the modified date on the
 build_exe.py file is October 3, 2007).

One way to avoid this problem is to use a font explictly, instead of
using the default. With the font in the dist directory it won't get
loaded as the default, but you ought to be able to load it by name.


Re: Fwd: [pygame] Problems with py2exe and Pygame

2007-12-05 Thread hwg
I did also manually put the font into library.zip.  Still had the same problem.

Then I took the suggestion from another post and explicitly loaded the 
freasnsbold.ttf font, instead of using None (and getting the default.)

That worked, but all my fonts rendered about 50% bigger than before.  Strange.  
But at least now I can distribute it.


hwg


 Try manually putting the font into library.zip.


On Dec 4, 2007 1:57 PM, Casey Duncan [EMAIL PROTECTED] wrote:


 On Dec 4, 2007, at 1:19 PM, Joe Johnston wrote:

  hwg wrote:
  I'm trying to make an exe of a simple Pygame program.
   Here's the setup.py http://setup.py/:
   from distutils.core import setup
 import py2exe, pygame
 import glob, shutil
 setup(windows=[lunarlander.py http://lunarlander.py/])
  shutil.copyfile('moonsurface.png', 'dist/moonsurface.png')
 shutil.copyfile('lunarlander2.png', 'dist/lunarlander2.png')
 shutil.copyfile('C:/Python25/Lib/site-packages/pygame/
  freesansbold.ttf',
 'dist/freesansbold.ttf')
 
  Maybe I'm a loser, but I generally keep the setup.py script short.
  If I've got to move files, I do that from a bat script which can
  call my Windows installer compiler too (inno, my case).

 A good reason to keep this stuff in python (regardless of whether it
 is in setup.py or not) is portability. bat files only work on
 Windows. But then again, absolute paths (especially ones that use
 drive letters) are highly non-portable anyhow no matter what language
 they're in (even on different machines that are running Windows).

 -Casey



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Ian Mallett
On 12/4/07, Greg Ewing [EMAIL PROTECTED] wrote:
 That's true. Probably not something you need to take into
 account in a Pong game, but if you're simulating space
 flight or something like that, you certainly do!
I always wondered how the ball in Pong could bounce indefinitely, and
not accelerate when traveling downwards.


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Patrick Mullen
On Dec 5, 2007 9:59 AM, Ian Mallett [EMAIL PROTECTED] wrote:
 On 12/4/07, Greg Ewing [EMAIL PROTECTED] wrote:
  That's true. Probably not something you need to take into
  account in a Pong game, but if you're simulating space
  flight or something like that, you certainly do!
 I always wondered how the ball in Pong could bounce indefinitely, and
 not accelerate when traveling downwards.


Well pong is viewed from above, so downward acceleration makes no
sense.  (ping pong)  As for bouncing indefinitely, pong takes place in
a magical universe where no energy is ever lost :)  It's funny how you
don't ever have to worry about going over the net.  Why they didn't
just name it hock (air hockey) we'll never know.


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Ian Mallett
On 12/5/07, Patrick Mullen [EMAIL PROTECTED] wrote:
 Well pong is viewed from above, so downward acceleration makes no
 sense.  (ping pong)
So it would be a case where the bounce is sideways, like hockey or soccer.
 As for bouncing indefinitely, pong takes place in
 a magical universe where no energy is ever lost :)
And now, for your random amusement:

Well, some energy must be lost from the ball, and transferred into
the wall, (so the walls should move as well as the ball).  That way,
the energy would be temporarily lost to the ball, but then given back
to it when it hits the other wall, which is moving towards it.
Actually, that's sort of what happens.  The energy of the ball goes
into the Earth, accelerating it VERY slightly.  If collisions were
totally elastic, and friction was zero, the ball would bounce forever.

Either that or the ball must be infinitely light, in which case,
it would be accelerated to the speed of light by a touch.  However, as
long as the object it comes into contact with remains motionless, the
bounce will just be a bounce, and not a speed change.  (Velocity
changes because the direction does).  On the other hand, since the
ball is massless, the ball's velocity can be changed instantaneously.
Because the contact time is nonexistent, the speed of the paddle per
unit of time is irrelevant, so it would always bounce and never
accelerate.  Even friction would have no effect.  (Air friction,
caused by air molecules, for example, would cause the ball to bounce
rapidly between the atoms- no energy would even be lost as heat, or
would it?).

Note that these two cases only work if the ball has a set speed to
begin with.  If it was at rest, a single atom of gas would accelerate
it to light speed.  If it was going at light speed, there is no way to
stop it because it would retain the speed of any collision.  If it hit
another atom of gas, it could not transfer energy because it does not
have any mass to carry the energy.  Or would it?  Physics says that
the same force is required to stop a particle as took to accelerate
it.  So identical atoms at identical speeds could both stop and start
the ball?  However, Physics, as far as I know, does not say what
happens with a particle of no mass.

Now, according to Wikipedia, the mass of a photon is zero.  Yet we
know that photons carry energy (shine this:
http://www.youtube.com/watch?v=vXDYCGVEMac into your face (don't)).
Since energy is mass (the conversion factor is the speed of light
squared), photons must have effective mass.  Yet they don't!  Somehow,
they can obviously be created and accelerated.  So, there are your
magic particles, but we don't often see them going slower than the
speed of light, not to mention small, so they're useless for Pong.

Of course, there is a paradox in all this, that the ball can
retain kinetic energy, yet have no mass.  It could be viewed that, by
Physics, it could not impart energy with no mass, because energy
transfer is proportional to the mass and speed of an object.  But
photons accelerate, at least, so ???  Incidentally, ask someone what
(1/infinity)*(infinity)
is.  I want to know.

Best not to analyse it too much. :-)

Ian


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Greg Ewing

Michael George wrote:
I've thought of writing a game with physics operating at the quantum 
scale, but I couldn't think of anything interesting.


Some things you might be able to exploit:

* Non-commuting observables - an object that you can determine
  two different things about, but not both at the same time.
  Observing one makes the other indeterminate, so by making
  alternating observations you can change its state.

* Interference - something can happen two mutually exclusive
  ways, but to achieve a desired outcome it has to happen
  both ways at the same time. You achieve this by closing
  your eyes and not watching what happens.

* Entanglement - two distant objects are connected in such
  a way that observing something about one of them has an
  effect on the other.

--
Greg


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Greg Ewing

Ian Mallett wrote:

However, Physics, as far as I know, does not say what
happens with a particle of no mass.


Actually, it does -- a photon is an example of an object
with no mass. Such an object always travels at the speed
of light -- it doesn't even need a push to get it going.
It's fundamentally incapable of standing still.

While it has no mass, it does have both energy and
momentum, both of which are proportional to its frequency.
These are conserved in any collision, so when it
bounces off a wall, the wall gains some momentum, just
as it would if a massive particle with the same
momentum bounced off it. And if the wall starts to
move as a result, then it has also gained some energy,
which must have come from the photon, so the reflected
photon must be red-shifted slightly (longer wavelength
= lower frequency = less energy).

--
Greg


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Ian Mallett
On Dec 5, 2007 4:03 PM, Greg Ewing [EMAIL PROTECTED] wrote:

 Actually, it does -- a photon is an example of an object
 with no mass. Such an object always travels at the speed
 of light -- it doesn't even need a push to get it going.
 It's fundamentally incapable of standing still.

Heh heh.  Try hitting that with a paddle.

 While it has no mass, it does have both energy and
 momentum, both of which are proportional to its frequency.

Momentum is defined as mass*velocity.  If mass is zero, how does a photon
have momentum?

 These are conserved in any collision, so when it
 bounces off a wall, the wall gains some momentum, just
 as it would if a massive particle with the same
 momentum bounced off it. And if the wall starts to
 move as a result, then it has also gained some energy,
 which must have come from the photon, so the reflected
 photon must be red-shifted slightly (longer wavelength
 = lower frequency = less energy).

All this is true, but *how* exactly does a massless particle have momentum?

 --
 Greg

Ian


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Luke Paireepinart

Ian Mallett wrote:
On Dec 5, 2007 4:03 PM, Greg Ewing [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Actually, it does -- a photon is an example of an object
with no mass. Such an object always travels at the speed
of light -- it doesn't even need a push to get it going.
It's fundamentally incapable of standing still. 


Heh heh.  Try hitting that with a paddle.

While it has no mass, it does have both energy and
momentum, both of which are proportional to its frequency.

Momentum is defined as mass*velocity.  If mass is zero, how does a 
photon have momentum?


These are conserved in any collision, so when it
bounces off a wall, the wall gains some momentum, just
as it would if a massive particle with the same
momentum bounced off it. And if the wall starts to
move as a result, then it has also gained some energy,
which must have come from the photon, so the reflected
photon must be red-shifted slightly (longer wavelength
= lower frequency = less energy). 

All this is true, but /how/ exactly does a massless particle have 
momentum?
I don't pretend to understand the implications of this discussion, but 
it sounds to me like, at the speed of light, frequency is analogous to 
mass at lower speeds?


Re: [pygame] Why does my ball vibrate?

2007-12-05 Thread Jason Ward
a while ago someone said that the ball speeding up and slowing down
randomly was because it was based on the time elapsed every frame and that
time varies because if other tasks are being run then the cpu is executing
both threads so it doesn't spend all of its time in your game.

But then what workaround is there for physics simulations that are based on
time?