How To Rotate An Image Around Its Center

preview_player
Показать описание
In this video I will explain the how to rotate an image around its center point using the transform method.

The rotation will be done using the mouse cursor so the image is always pointing at the mouse, which can be used in a top down shooting game.

Рекомендации по теме
Комментарии
Автор

this channel is gold for pygame beginners .... you're underrated man fr

its_stark
Автор

Your tutorials are the best on pygame i found on youtube and so well explained. I learned a lot of your videos.

davewhatever
Автор

Thank you! This video is SO much easier for me to understand than similar information I've found written out in lengthy stack overflow posts.

Gnarz
Автор

AMAZING VIDEO, but i have one question. How would you rotate an image around a fixed point

mustafakhan-foun
Автор

This was great. I am having trouble applying the idea to a moving sprite. Could you do another video on rotating an image that is part of a sprite?

SimplyDudeFace
Автор

Hello Russ, I just ran your code, in Pycharm, and it's working but after several rotations the screen freezes.
I have to close my laptop and reopen it to stop the program. I tried the Escape key but it doesn't do anything.
Any ideas as to what's causing this error?
Thanks, Gary
I think I just discovered the problem. I was using, "pygame.display.flip()", which updates the entire display and was causing the turret to lock up and no longer move. I changed update display to "pygame.display.update()" and no longer am experiencing any display freeze. So, was "flip" using up too much memory?

gaWalt
Автор

Awesome tutorial as always! Extremely helpful, thanks🙂 just what I've been looking for these days, messing around a bit with vectors and basic trigonometry for another practice project.
By the way, do you have any lessons regarding easy ways to swap color palettes on sprite? That be great as well

marlonsolleske
Автор

Bro can't we do it automatically,
Instead of rotating it by mouse it must rotate 360degree by himself, pls tell me the code how to do that or make a video😊😊Nice video

meandmemes
Автор

how do you feel every day when you wake up knowing that you help a lot of people all around the world

hl_l
Автор

Absolutely wonderful and the timing couldn't be more perfect! I needed exactly this.

idiedlastmonth
Автор

You helped me a Lot with your explaining

kaygg
Автор

Instead of atan2 could Vector2.angle_to() be used here?
It seems that pygame.Vector2(1, 0).angle_to((x_dist, y_dist)) would give the same result

MadOgre
Автор

Thank you Russ for your videos, could you help me and maybe others on how to rotate or pivoting an image from an arbitrary point of the image itself, let's say around its midbottom, pivoting either to the right or left or all the way around, 360 degrees, with the bottom remaining at the centre just pivoting like a vertex. I would appreciate that very much. Thank you very much again for your helpful video lessons

paperoga
Автор

when i use convert it says "pygame.error: No video mode has been set" i need help

slowedandreverbX
Автор

but my image gets distorted, and I'm trying to rotate it whenever a right arrow key is pressed.

cienciadelta
Автор

I have a problem, everything you did worked for me but the image keeps printing itself repeateatly and copies don't get deleted.
I believe this happens because the image I used has no background so it doesnt print over already existing copies.

hmmmmmm
Автор

my image its still not rotating correctly but I am drawing it fromthe center

icantthinkofaname
Автор

This only works if you're rotating it about the centre of the screen surely

edwardhudson