I am writing a program where sensors(the white circles) are moving on the map to cover things. I counted the number of covered things(the small white dots), it's the right number. But the old covered things and sensor(white circles) are still on the screen. How can I update the display so that only newest objects are on the screen(no red dots should be in the circle path, and the circle path history should not be displayed).
Here is my display code. It gets called every frame.
def _drawMap(self,ticks):
# draw the map
# draw the boundary
boundary = self._polygonCoordinationTransformation(self.data.boundary_polygon_list)
pygame.draw.polygon(self.screen, BLUE, boundary, LINEWIDTH)
# draw obstacles
for polygon in self.data.obstacles_list:
polygon = self._polygonCoordinationTransformation(polygon)
pygame.draw.polygon(self.screen, BLUE, polygon, LINEWIDTH)
# draw agents
self._executeSegment(self.agentsGroup.sprites()[0],(5,10),ticks)
for agent in self.agentsGroup:
pygame.draw.circle(self.screen, WHITE, agent.rect.center, self.data.sensor_range * self.scaleForMap,LINEWIDTH)
# draw items
self.updateUnseenItems()
for itemObj in self.unseenItemGroup:
pygame.draw.rect(self.screen, RED, itemObj, LINEWIDTH)