我开始使用 Pycharm,使用 Pygame 创建测试。
我注意到一些 Pygame 方法没有出现在 Pycharm AutoComplete 中。
例如,如果我想输入 a pygame.mask.from_surface (),则键入pygame.mas不会执行任何操作。但如果我手动完成mask并按.,则自动完成from_surface ()会正确显示。
前任:
import pygame
car = pygame.image.load("car.png").convert_alpha()
car_mask = pygame.mas #### .... here, Pycharm should already show autocomplete
Run Code Online (Sandbox Code Playgroud)
这也会出现在其他情况下,例如,如果我想使用car.get_rect(),则在输入后它不再出现car.
如何解决这个问题?
如果我在SFML中有3个不同的形状,并且我想相对于单个中心旋转它们,就好像这3个形状在一个正方形内,那么最好的方法是什么?它会将它们留在视图中并旋转视图吗?还是有更实用的方法?
我需要开发一种以非线性方式(即平滑曲线)连接点的算法连接点的算法,如下图所示:
\n\n\n\n问题是我无法找到最佳解决方案,无论是使用贝塞尔曲线、多项式插值、曲线调整等。
\n\n简而言之,我需要一个公式,根据上图对点进行插值,在一个坐标和另一个坐标之间生成 N 个中间点。
\n\n在上图中,第一个坐标 (c1) 为 (x = 1, y = 220),第二个坐标 (c2) 为 (x = 2, y = 40)。
\n\n因此,如果我想在 c1 和 c2 之间创建 4 个中间坐标,我将必须获得一个由 4 个元素组成的数组 (x, y),如下所示:
\n\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0
\n\n[1.2, 180], [1.4, 140], [1.6, 120], [1.8, 80]\nRun Code Online (Sandbox Code Playgroud)\n\n有人有什么想法吗?
\n使用SFML的代码有什么问题?
在下面的代码中,我有这个图像(1000x1000),我想使用sf :: RenderTexture在一个窗口(500x500)中显示它.但是,只有部分图像出现在第一个象限中:
#include <SFML/Graphics.hpp>
using namespace sf;
int main()
{
RenderWindow window({500, 500}, "SFML Views", Style::Close);
View camera;
camera.setSize(Vector2f(window.getSize()));
Texture background;
background.loadFromFile("numeros.png");
Sprite numeros (background);
RenderTexture texture;
texture.create(window.getSize().x, window.getSize().y);
Sprite content;
content.setTexture(texture.getTexture());
texture.draw(numeros);
texture.display();
while (window.isOpen())
{
for (Event event; window.pollEvent(event);)
if (event.type == Event::Closed)
window.close();
window.clear();
window.setView(camera);
window.draw(content);
window.display();
}
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
据我所知,代码应生成自动调整为500x500的原始图像(1000x1000).
谁能告诉你什么是错的?
c++ ×2
sfml ×2
algorithm ×1
autocomplete ×1
button ×1
graph ×1
kivy ×1
math ×1
orthogonal ×1
pycharm ×1
pygame ×1
python ×1
python-3.x ×1