[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] This program breaks on my Linux
- To: Pygame Users <pygame-users@xxxxxxxx>
- Subject: [pygame] This program breaks on my Linux
- From: bw <stabbingfinger@xxxxxxxxx>
- Date: Fri, 27 Jun 2014 22:35:50 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 28 Jun 2014 01:35:54 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=QdEPCNbDxIMzZF3zGccwshxuc3XzOqwaLe5Xsg8WUCc=; b=GKalsteDpf4YFpyBYR99MNCRC1rXZuo6q1Ex6J3l8E1/lRRGe2YsC7u5JsTyyIL0wA aizYRRaPAGEqzV4s983k6Ay9skfbik/0PjtiYj6A46MdNCmiKtxlSdpzlXOEL0PfjcAg 9fezkaJymDxpo78r4Rg2HT1/fAeqa8LgF80dHqTvkorA6qLbp4prSZdAcDNDxuHAUQq9 zdoPosqMdaXmJCMZ/BBHyo23rlqohc4lu0hKeHvO5X0x5enSKZzokKnQCFSFjD2kBTCk 177dBwu46v0ILq1Kt8Y+ag2u0xXWuOCoypLuRq7TmD/jYDxPkikXxGSamiwHFOYXs5so ZlHQ==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
Howdy,
Hoping some folks can try this out. I have no idea why it is happening.
Not even a theory. Could be anything from drivers to the Python or SDL
build. Here's the scoop...
The environment:
- i5 desktop computer (not a virtual machine)
- Ubuntu 13.04 x86_64
- Python 2.7
- pygame 1.9.1
The program blits a checkerboard background using only two images, and
pans the images diagonally back and forth forever. The clock is not
throttled.
The problem usually occurs anywhere from 3 to 120 seconds after start.
During the normal behavior, I'm getting about 320 fps with occasional
instantaneous spikes to 500+ fps. (I don't know if the spikes are
normal. They do cause visible glitches.)
During the problem behavior the fps spikes permanently to about 580 fps
and stays pegged. Who would complain about sustained 580 fps, ay? :)
Well, then when pygame quits, the program freezes and the window remains
open with the checker pattern intact. SIGTERM (15) does not kill the
program. SIGKILL (9) does.
This issue does not happen in Windows 7. And it does not happen if I
throttle the clock enough to lower the max fps.
I attached the small program. I'm curious if anyone can run it and
reproduce the problem. I plan on upgrading Ubuntu soon, when I am ready
to risk it: maybe the problem will go away. I'll post the outcome--but
I've been too busy to risk the upgrade, so don't hold yer breath. =)
Thanks.
Gumm
import sys
import pygame
from pygame.locals import *
pygame.init()
resolution = 1024, 768
image_size = 200
screen = pygame.display.set_mode(resolution)
screen_rect = screen.get_rect()
scroll_rect = Rect(screen_rect)
scroll_rect.width *= 5
scroll_rect.height *= 5
clock = pygame.time.Clock()
images = (
pygame.Surface((image_size, image_size)),
pygame.Surface((image_size, image_size)),
)
images[0].fill(Color('slategray2'))
images[1].fill(Color('slategray3'))
image_rect = images[0].get_rect()
bg_color = Color('black')
dx = -1
dy = -1
max_fps = 0
while True:
dt = clock.tick(max_fps)
fps = int(round(clock.get_fps()))
meter = 'o' * (fps / 10)
pygame.display.set_caption('Fps {0} {1}'.format(fps, meter))
for e in pygame.event.get():
if e.type == KEYDOWN:
print('keydown',pygame.key.name(e.key))
sys.stdout.flush()
if e.key == K_ESCAPE:
pygame.quit()
quit()
scroll_rect.move_ip(dx, dy)
if not scroll_rect.contains(screen_rect):
dx = -dx
dy = -dy
screen.fill(bg_color)
line_num = 0
for y in xrange(scroll_rect.y, scroll_rect.bottom, image_size):
checker = 0 if line_num % 2 else 1
line_num += 1
for x in xrange(scroll_rect.x, scroll_rect.right, image_size):
image_rect.x = x
image_rect.y = y
if screen_rect.colliderect(image_rect):
screen.blit(images[checker], image_rect)
checker = 0 if checker == 1 else 1
pygame.display.flip()