相关疑难解决方法(0)

pygame旋转一条线

我试图在Pygame中创建一个"雷达".我无法旋转雷达的针头.如何旋转它?

import pygame
from pygame.locals import *
SIZE = 800, 800
pygame.init()
screen = pygame.display.set_mode(SIZE)
FPSCLOCK = pygame.time.Clock()
done = False
screen.fill((0, 0, 0))
degree=0
while not done:
    for e in pygame.event.get():
        if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
            done = True
            break
    for x in range(1,400,10):
        pygame.draw.circle(screen,(255,255,255),(400,400),x,1)
    line = pygame.draw.line(screen,(10,100,10),(400,400),(400,0),3)
    pygame.transform.rotate(line,degree)
        pygame.display.flip()   
        degree+=5
        FPSCLOCK.tick(40)
Run Code Online (Sandbox Code Playgroud)

这里解决了:

import pygame
import math
from pygame.locals import *
SIZE = 800, 800
pygame.init()
screen = pygame.display.set_mode(SIZE)
FPSCLOCK = pygame.time.Clock() …
Run Code Online (Sandbox Code Playgroud)

python pygame

2
推荐指数
1
解决办法
4104
查看次数

如何在Python 3中计算两点之间的角度?

我想计算两点之间的角度。例如,假设我正在制作一个游戏,我想要一把枪指向鼠标光标,我得到将枪旋转到该角度所需的角度。

python math pygame angle python-3.x

-1
推荐指数
1
解决办法
4938
查看次数

标签 统计

pygame ×2

python ×2

angle ×1

math ×1

python-3.x ×1