def _detect_collisions(self): for wall_shape in self.wall_shapes: collisions = wall_shape.shapes_collide(self.robot.shape) if(collisions.points): img_pos, img_ori = self.pm2pgP(self.robot.body.position), degrees(self.robot.body.angle) self._apply_image_to_robot(img_pos, img_ori, damage=True) pg.display.flip() time.sleep(.5) return 1, collisions.points return 0, None
def _draw_everything(self, velocity=False, steering=True): self.screen.fill(WHITE) self.space.debug_draw(self.draw_options) img_pos, img_ori = self.pm2pgP(self.robot.body.position), degrees(self.robot.body.angle) self._apply_image_to_robot(img_pos, img_ori) pm_botPos = self.pm2pgP(self.robot.body.position) if velocity: velocity_vector = pm_botPos + self.pm2pgV(self.robot.body.velocity)*5 velocity_line = pg.draw.line(self.screen, RED, pm_botPos, velocity_vector) if steering: steering_vector = pm_botPos + self.pm2pgV(self.steering_force)*7.5 steering_line = pg.draw.line(self.screen, GREEN, pm_botPos, steering_vector) pg.display.flip()