i'm trying to use subsurfaces of Pygame to draw multiple cartesian plans, each one with your shapes inside your space.
At first, i call display method on init
self.screen = pygame.display.set_mode((width, height))
self.screen.fill(Colors.WHITE)
I have a surfaces dict, that storage all surfaces created.
At this part, i'm creating each subsurface, based on mainscreen, that takes all screen space.
for canvas in canvas_list:
surface = self.screen.subsurface(pygame.Rect(canvas.start.x, canvas.start.y,
canvas.width, canvas.height))
surface.fill(Colors.WHITE)
self.surfaces[canvas.tag] = surface
I also tried to create using this way
surface = pygame.Surface([canvas.width, canvas.height])
surface.fill(Colors.WHITE)
self.surfaces[canvas.tag] = surface
And at render moment, i'm using this code to draw plan lines
half_height = canvas.height / 2
half_width = canvas.width / 2
pygame.draw.line(surface, Colors.BLACK, (0, half_height), (canvas.width, half_height))
pygame.draw.line(surface, Colors.BLACK, (half_width, 0), (half_width, canvas.height))
pygame.draw.circle(surface, Colors.BLACK, (half_width, half_height), 2, 0)
The problem is that, at to call method to render one more surface, only last surface is rendered, using different start points to Rect. I tried to use Surface.blit to fix position too, but only work when i used a new Surface, and not a surface created apart from another surface.
Follow about main code that call Pygame methods
canvas1 = Canvas(250, 250, Point(x=200, y=200), "canvas1")
canvas2 = Canvas(260, 260, Point(x=450, y=450), "canvas2")
canvas3 = Canvas(270, 270, Point(x=710, y=710), "canvas3")
I also tried change display.flip method location, if i call this method, after each surface object rendered, i see all surfaces blinking on each one position.
This way:
for canvas in self.canvas_list:
self._draw_at_canvas(canvas)
pygame.display.flip()
Any suggestion to solve the problem