Re: [pygame] p4a animation lag

2012-01-13 Thread Sean Wolfe
On Fri, Dec 30, 2011 at 6:09 PM, Sean Wolfe ether@gmail.com wrote:
 Good info, I'll move the clock tick to the main loop and see what that
 gets me. Thanks for the tip.

Hey guys, just wanted to check in with my p4a work. So after a few
weeks mucking about with Java I went back to my phone and ran a 'top'
while running my game. Turns out I had some HTC Sync software also
running that was really sucking up cpu time. I killed that, then
watched the output while running the animation.

pygame.renpy.org:python was between 60-80% cpu, and the animation was
running much faster.

So, I have new hope for doing this in python! I mean, this is a
two-year-old HTC Sprint Hero I'm running on, so by the time I actually
am looking to beta a game... the technology will be that much better.

Good cause the coding overhead trying to do this in Java makes it a
whole lot of not fun ...

Onwards!


Re: [pygame] p4a animation lag

2011-12-30 Thread Sean Wolfe
Don't have to click for every frame, it will run the whole list of
frames on a single mousebuttondown.

And the blit of the background takes care of drawing on top of one another.

Anybody have any ideas about the lag though? Maybe we need a p4a port
to the Android native kit.




On Thu, Dec 29, 2011 at 6:59 PM, Ian Mallett geometr...@gmail.com wrote:
 On Thu, Dec 29, 2011 at 1:52 PM, Sean Wolfe ether@gmail.com wrote:

 frames = [image1, image2, image3]
 running = True
 while running:
    for event in pygame.event.get():
        if event.type == MOUSEBUTTONDOWN:
            clock.tick(10)
            for img in frames:
                screen.blit(background, (0,0))
                screen.blit(img, position)
                pygame.display.flip()
                clock.tick(10)

 You do realize that you're only ever drawing when the mouse is pressed,
 right?  So, you'll have to click for every frame.

 Also, you're drawing every frame in the animation on top of each other.

 Ian



-- 
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] p4a animation lag

2011-12-30 Thread René Dudfield
Hi,

Do you need to blit the background each time?

Have you used convert() on the surfaces?

cheers,

On Fri, Dec 30, 2011 at 5:00 PM, Sean Wolfe ether@gmail.com wrote:

 Don't have to click for every frame, it will run the whole list of
 frames on a single mousebuttondown.

 And the blit of the background takes care of drawing on top of one another.

 Anybody have any ideas about the lag though? Maybe we need a p4a port
 to the Android native kit.




 On Thu, Dec 29, 2011 at 6:59 PM, Ian Mallett geometr...@gmail.com wrote:
  On Thu, Dec 29, 2011 at 1:52 PM, Sean Wolfe ether@gmail.com wrote:
 
  frames = [image1, image2, image3]
  running = True
  while running:
 for event in pygame.event.get():
 if event.type == MOUSEBUTTONDOWN:
 clock.tick(10)
 for img in frames:
 screen.blit(background, (0,0))
 screen.blit(img, position)
 pygame.display.flip()
 clock.tick(10)
 
  You do realize that you're only ever drawing when the mouse is pressed,
  right?  So, you'll have to click for every frame.
 
  Also, you're drawing every frame in the animation on top of each other.
 
  Ian



 --
 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] p4a animation lag

2011-12-30 Thread Sean Wolfe
I have *not* converted the surfaces ... I will try that!

I'm blitting the background to basically clear the screen for the next
frame. Is there a better way to do this?

Thanks for the pointer...



On Fri, Dec 30, 2011 at 1:05 PM, René Dudfield ren...@gmail.com wrote:
 Hi,

 Do you need to blit the background each time?

 Have you used convert() on the surfaces?

 cheers,


 On Fri, Dec 30, 2011 at 5:00 PM, Sean Wolfe ether@gmail.com wrote:

 Don't have to click for every frame, it will run the whole list of
 frames on a single mousebuttondown.

 And the blit of the background takes care of drawing on top of one
 another.

 Anybody have any ideas about the lag though? Maybe we need a p4a port
 to the Android native kit.




 On Thu, Dec 29, 2011 at 6:59 PM, Ian Mallett geometr...@gmail.com wrote:
  On Thu, Dec 29, 2011 at 1:52 PM, Sean Wolfe ether@gmail.com wrote:
 
  frames = [image1, image2, image3]
  running = True
  while running:
     for event in pygame.event.get():
         if event.type == MOUSEBUTTONDOWN:
             clock.tick(10)
             for img in frames:
                 screen.blit(background, (0,0))
                 screen.blit(img, position)
                 pygame.display.flip()
                 clock.tick(10)
 
  You do realize that you're only ever drawing when the mouse is pressed,
  right?  So, you'll have to click for every frame.
 
  Also, you're drawing every frame in the animation on top of each other.
 
  Ian



 --
 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





-- 
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] p4a animation lag

2011-12-30 Thread René Dudfield
Hi,

after you convert(), it should definitely be much faster.

If you don't change the whole background, it might be good just to redraw
the part you are changing.  It can be easy to use the sprite.DirtySprite
and sprite.LayeredDirty for this.  Or if your other images are completely
over writing it, then you do not need to draw the background at all.  You
want to avoid 'overdraw' of pixels if possible, and the work tracking what
pixels you have drawn already is less than the work drawing those pixels.

Also, the .fill() method is often very fast compared to blit, so that might
be appropriate for you.

cheers,


On Fri, Dec 30, 2011 at 5:18 PM, Sean Wolfe ether@gmail.com wrote:

 I have *not* converted the surfaces ... I will try that!

 I'm blitting the background to basically clear the screen for the next
 frame. Is there a better way to do this?

 Thanks for the pointer...



 On Fri, Dec 30, 2011 at 1:05 PM, René Dudfield ren...@gmail.com wrote:
  Hi,
 
  Do you need to blit the background each time?
 
  Have you used convert() on the surfaces?
 
  cheers,
 
 
  On Fri, Dec 30, 2011 at 5:00 PM, Sean Wolfe ether@gmail.com wrote:
 
  Don't have to click for every frame, it will run the whole list of
  frames on a single mousebuttondown.
 
  And the blit of the background takes care of drawing on top of one
  another.
 
  Anybody have any ideas about the lag though? Maybe we need a p4a port
  to the Android native kit.
 
 
 
 
  On Thu, Dec 29, 2011 at 6:59 PM, Ian Mallett geometr...@gmail.com
 wrote:
   On Thu, Dec 29, 2011 at 1:52 PM, Sean Wolfe ether@gmail.com
 wrote:
  
   frames = [image1, image2, image3]
   running = True
   while running:
  for event in pygame.event.get():
  if event.type == MOUSEBUTTONDOWN:
  clock.tick(10)
  for img in frames:
  screen.blit(background, (0,0))
  screen.blit(img, position)
  pygame.display.flip()
  clock.tick(10)
  
   You do realize that you're only ever drawing when the mouse is
 pressed,
   right?  So, you'll have to click for every frame.
  
   Also, you're drawing every frame in the animation on top of each
 other.
  
   Ian
 
 
 
  --
  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
 
 



 --
 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] p4a animation lag

2011-12-30 Thread Sean Wolfe
sweet, this is a lot of good information. I've incorporated the
convert bit and I'm pushing to the phone now to see. I'll look at the
other pieces as well.

The good news is the music is working well on android, I've got a
background music track playing along with individual sounds for my
characters' various attacks. Sounds killer.


On Fri, Dec 30, 2011 at 1:38 PM, René Dudfield ren...@gmail.com wrote:
 Hi,

 after you convert(), it should definitely be much faster.

 If you don't change the whole background, it might be good just to redraw
 the part you are changing.  It can be easy to use the sprite.DirtySprite and
 sprite.LayeredDirty for this.  Or if your other images are completely over
 writing it, then you do not need to draw the background at all.  You want to
 avoid 'overdraw' of pixels if possible, and the work tracking what pixels
 you have drawn already is less than the work drawing those pixels.

 Also, the .fill() method is often very fast compared to blit, so that might
 be appropriate for you.

 cheers,



 On Fri, Dec 30, 2011 at 5:18 PM, Sean Wolfe ether@gmail.com wrote:

 I have *not* converted the surfaces ... I will try that!

 I'm blitting the background to basically clear the screen for the next
 frame. Is there a better way to do this?

 Thanks for the pointer...



 On Fri, Dec 30, 2011 at 1:05 PM, René Dudfield ren...@gmail.com wrote:
  Hi,
 
  Do you need to blit the background each time?
 
  Have you used convert() on the surfaces?
 
  cheers,
 
 
  On Fri, Dec 30, 2011 at 5:00 PM, Sean Wolfe ether@gmail.com wrote:
 
  Don't have to click for every frame, it will run the whole list of
  frames on a single mousebuttondown.
 
  And the blit of the background takes care of drawing on top of one
  another.
 
  Anybody have any ideas about the lag though? Maybe we need a p4a port
  to the Android native kit.
 
 
 
 
  On Thu, Dec 29, 2011 at 6:59 PM, Ian Mallett geometr...@gmail.com
  wrote:
   On Thu, Dec 29, 2011 at 1:52 PM, Sean Wolfe ether@gmail.com
   wrote:
  
   frames = [image1, image2, image3]
   running = True
   while running:
      for event in pygame.event.get():
          if event.type == MOUSEBUTTONDOWN:
              clock.tick(10)
              for img in frames:
                  screen.blit(background, (0,0))
                  screen.blit(img, position)
                  pygame.display.flip()
                  clock.tick(10)
  
   You do realize that you're only ever drawing when the mouse is
   pressed,
   right?  So, you'll have to click for every frame.
  
   Also, you're drawing every frame in the animation on top of each
   other.
  
   Ian
 
 
 
  --
  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
 
 



 --
 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





-- 
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] p4a animation lag

2011-12-30 Thread Ian Mallett
On Fri, Dec 30, 2011 at 8:00 AM, Sean Wolfe ether@gmail.com wrote:

 Don't have to click for every frame, it will run the whole list of
 frames on a single mousebuttondown.

That wasn't really my point; graphics is only being drawn when the user
clicks.  Generally input and graphics are disassociated.  I see that this
way allows you to only redraw when you need to, but it's a bad idea in
general.

However, given that this *is* your desired behavior, I suspect the actual *
problem* to be with the clock.tick calls.  When passed a framerate
argument, the clock will attempt to average over a certain number of time
samples to get a proper framerate.  You're only ever calling tick when
there's a mouse event, so the average will get screwed up.  Also, it's set
to 10fps, which is kinda low.

Ian


Re: [pygame] p4a animation lag

2011-12-30 Thread Sean Wolfe
Good info, I'll move the clock tick to the main loop and see what that
gets me. Thanks for the tip.


On Fri, Dec 30, 2011 at 5:46 PM, Ian Mallett geometr...@gmail.com wrote:
 On Fri, Dec 30, 2011 at 8:00 AM, Sean Wolfe ether@gmail.com wrote:

 Don't have to click for every frame, it will run the whole list of
 frames on a single mousebuttondown.

 That wasn't really my point; graphics is only being drawn when the user
 clicks.  Generally input and graphics are disassociated.  I see that this
 way allows you to only redraw when you need to, but it's a bad idea in
 general.

 However, given that this *is* your desired behavior, I suspect the actual
 problem to be with the clock.tick calls.  When passed a framerate argument,
 the clock will attempt to average over a certain number of time samples to
 get a proper framerate.  You're only ever calling tick when there's a mouse
 event, so the average will get screwed up.  Also, it's set to 10fps, which
 is kinda low.

 Ian



-- 
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


[pygame] p4a animation lag

2011-12-29 Thread Sean Wolfe
I've got a pretty simple animation running on p4android, but it's
lagging pretty badly.

The code is basically, get a screen touch, run 3 animation frames with
a tick of 10, so it should be pretty snappy. On the computer it's fast
enough but the android it's noticeably slower, to the point where
really the game would be unplayable. chug-chug-chug go the frames,
basically.

This is a Sprint Hero with android 2.1 or 2.2, can't remember exactly.
Am I just running into limitations on the platform? Any optimization I
can do for the android side?

If you want the code I can dig it up but it's just a simple animation
loop along the lines of

frames = [image1, image2, image3]
running = True
while running:
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
clock.tick(10)
for img in frames:
screen.blit(background, (0,0))
screen.blit(img, position)
pygame.display.flip()
clock.tick(10)





-- 
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] p4a animation lag

2011-12-29 Thread Ian Mallett
On Thu, Dec 29, 2011 at 1:52 PM, Sean Wolfe ether@gmail.com wrote:

 frames = [image1, image2, image3]
 running = True
 while running:
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
clock.tick(10)
for img in frames:
screen.blit(background, (0,0))
screen.blit(img, position)
pygame.display.flip()
clock.tick(10)

You do realize that you're only ever drawing when the mouse is pressed,
right?  So, you'll have to click for every frame.

Also, you're drawing every frame in the animation on top of each other.

Ian