当前位置:网站首页>pygame image rotate continuously
pygame image rotate continuously
2022-08-02 15:27:00 【Tianshan has no longevity tea】
We can know by searching that the method of image rotation in pygame is pygame.transform.rotate(), but in actual use, we will find that if we want to continuously rotate an object, simplyUsing this method will cause the image to be distorted and completely lose its original appearance.
After research, it is found that the reason for the image distortion is that after each rotation using the above method, the center point of the image will change, so our solution is to set the rotation center to remain unchanged every time it rotates.The code is as follows:
x = 0y = 0# import original imageimage_raw = pygame.image.load("your image").convert_alpha()# set the center of rotationcore = (x,y)# Set the angle (0~360)angle = 60# rotate the imageimage = pygame.transform.rotate(image_raw, angle)# Draw the image and set the center position, note that the center here must be a tuple tupleself.screen.blit(image, image.get_rect(center=tuple(core)))If we need to rotate continuously and change the position of the rotation center, just adjust the values of core and angle.Note that the range of angle uses the angle system (0~360)
边栏推荐
猜你喜欢
随机推荐
win10系统更新错误代码0x80244022怎么办
镜像法求解接地导体空腔电势分布问题
基于最小二乘法的线性回归分析方程中系数的估计
yolov5官方代码解读——前向传播
define #使用
The overlapping effect of the two surfaceviews is similar to the video and handout practice in the live effect
Compilation error D8021: Invalid numeric argument '/Wextra' cl command line error d8021 invalid numeric argument '/Wextra'
Win11怎么在右键菜单添加一键关机选项
Win10安装了固态硬盘还是有明显卡顿怎么办?
TCP三次握手、四次挥手
Publish module to NPM should be how to operate?Solutions to problems and mistake
推开机电的大门《电路》(二):功率计算与判断
General code for pytorch model to libtorch and onnx format
[STM32 Learning 1] Basic knowledge and concepts are clear
Win10 Settings screen out from lack of sleep?Win10 set the method that never sleep
刷卡芯片CI520可直接PIN对PIN替换CV520支持SPI通讯接口
MATLAB图形加标注的基本方法入门简介
FP6195耐压60V电流降压3.3V5V模块供电方案
win10无法直接用照片查看器打开图片怎么办
Mysql connection error solution









