python - Pygame lines disappear after rotating points -
i new python , tried make game ship rotates. however, after rotating, ship disappears. printed coordinates of 3 points, , should appear on screen. know what's wrong code?
this code rotating ship:
radius = self.width / 2 self.angle += da center = [self.pos[0] + radius, self.pos[1] + radius] point in self.points: dx = int(math.cos(self.angle) * radius) dy = int(math.sin(self.angle) * radius) point[0] = center[0] + dx point[1] = center[1] + dy
this code drawing screen:
while true: event in pygame.event.get(): if event.type == pygame.quit: pygame.quit() sys.exit() keys = pygame.key.get_pressed() if keys[pygame.k_up]: self.ship.move(self) if keys[pygame.k_right]: self.ship.rotate(0.08) if keys[pygame.k_left]: self.ship.rotate(-0.08) self.display.fill(self.bgcolor) self.ship.draw(self.display) pygame.display.update() self.fpsclock.tick(self.fps)
look @ code:
for point in self.points: dx = int(math.cos(self.angle) * radius) dy = int(math.sin(self.angle) * radius) point[0] = center[0] + dx point[1] = center[1] + dy
note you're not using point anything, setting it. assuming self.points list of points make ship, think ship collapsing single point whenever hits code.
Comments
Post a Comment