main: use one primary buffer
This commit is contained in:
parent
0fffccad41
commit
0b73dbff8a
27
main.py
27
main.py
@ -92,18 +92,7 @@ def new_tile_surface():
|
||||
x_tiles = (640 // 32)
|
||||
y_tiles = (480 // 32)
|
||||
|
||||
color_buffer_list = [
|
||||
new_tile_surface()
|
||||
for _ in range(x_tiles * y_tiles)
|
||||
]
|
||||
|
||||
depth_buffer_list = [
|
||||
new_tile_surface()
|
||||
for _ in range(x_tiles * y_tiles)
|
||||
]
|
||||
|
||||
color_test_surface = new_tile_surface()
|
||||
depth_test_surface = new_tile_surface()
|
||||
primary_buffer = None
|
||||
|
||||
def draw_background(tile):
|
||||
t = holly.ISP_BACKGND_T
|
||||
@ -127,16 +116,14 @@ def draw_background(tile):
|
||||
points = [(0, 0), (640, 0), (640, 480), (0, 480)]
|
||||
|
||||
tile_ix = tile.tile_y_position * x_tiles + tile.tile_x_position
|
||||
color_buffer = color_buffer_list[tile_ix]
|
||||
pygame.draw.polygon(color_buffer, color, points)
|
||||
pygame.draw.polygon(primary_buffer, color, points)
|
||||
|
||||
def tile_callback(tile):
|
||||
draw_background(tile)
|
||||
|
||||
def flush_callback(tile, *, screen):
|
||||
tile_ix = tile.tile_y_position * x_tiles + tile.tile_x_position
|
||||
color_buffer = color_buffer_list[tile_ix]
|
||||
screen.blit(color_buffer, (tile.tile_x_position * 32, tile.tile_y_position * 32))
|
||||
screen.blit(primary_buffer, (tile.tile_x_position * 32, tile.tile_y_position * 32))
|
||||
pygame.display.flip()
|
||||
|
||||
time.sleep(0.1)
|
||||
@ -150,7 +137,6 @@ def parameter_callback(tile, list_type_name, list_pointer, ol_entry, parameter):
|
||||
top = tile.tile_y_position * 32
|
||||
|
||||
tile_ix = tile.tile_y_position * x_tiles + tile.tile_x_position
|
||||
color_buffer = color_buffer_list[tile_ix]
|
||||
|
||||
assert type(ol_entry) == triangle_array, ol_entry
|
||||
assert len(parameter.vertices) == 3, parameter.vertices
|
||||
@ -170,13 +156,16 @@ def parameter_callback(tile, list_type_name, list_pointer, ol_entry, parameter):
|
||||
|
||||
assert red > 10 or blue > 10 or green > 10, argb_color
|
||||
|
||||
pygame.draw.polygon(color_buffer, color, points)
|
||||
pygame.draw.polygon(primary_buffer, color, points)
|
||||
|
||||
def draw():
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((640, 480))
|
||||
|
||||
sys.stdin.readline()
|
||||
global primary_buffer
|
||||
primary_buffer = new_tile_surface()
|
||||
|
||||
#sys.stdin.readline()
|
||||
|
||||
walk_region_array(tile_callback=tile_callback,
|
||||
parameter_callback=parameter_callback,
|
||||
|
Loading…
x
Reference in New Issue
Block a user