【发布时间】:2017-03-11 23:24:55
【问题描述】:
我正在编写一个程序,其中传感器(白色圆圈)在地图上移动以覆盖事物。我数了数被覆盖的东西(小白点)的数量,这是正确的数字。但旧的覆盖物和传感器(白色圆圈)仍在屏幕上。如何更新显示,以便屏幕上只有最新的对象(圆圈路径中不应出现红点,并且不应显示圆圈路径历史)。
这是我的显示代码。每帧都会调用它。
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)
【问题讨论】: