[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] Fastest way to plot a map.
Hi, all.
I've got some code that currently keeps a map as an array of integers:
map = [[0] * map_max_y for i in range(map_max_x)]
The map is larger than the viewport.
The current screen is constructed with something like this pseudocode
Assume the viewport is guaranteed to be safely within the boundaries -
it's checked elsewhere.
for x in range(viewport.x, viewport.x + viewport.width):
for y in range(viewport.y, viewport.y + viewport.height):
cell = map[x][y]
if cell != 0:
if cell == 10:
viewport.display.set_at((x,y),(255,255,255))
elif cell ==20:
viewport.display.set_at((x,y),(0,255,255))
else:
viewport.display.set_at((x,y),(128,128,128))
blit_and_flip(Screen)
Of course this is slow. Screen redraws are on the order of a half a
second. Is there something
I can do with pynumeric to make this fast enough for realtime (atleast
10 fps)?
Can I speed up an order of magnitude using map somethow? Do I need to
drop to C?
Any ideas would be appreciated.
- Scott
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org