Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:10:57+00:00 2026-06-15T14:10:57+00:00

A picture is worth a thousand words, so ultimately, my question is how can

  • 0

A picture is worth a thousand words, so ultimately, my question is “how can I achieve this?”:

enter image description here

Intuitively, I thought this might be achievable by defining a surface within the main display object defined by pygame.display.set_mode, drawing (or blitting) whatever is needed onto that surface, and then rotating it with pygame.transform.rotate. The static dots, I assumed, could be drawn directly to the screen object in the code below, which is the object returned by the pygame.display.set_mode function.

I therefore drafted up the following test code, but I don’t see any rotation. What am I doing wrong?

#!/usr/bin/env python

import pygame as pg
from pygame.locals import *

SIZE = (800, 600)
BGCOL = (128, 128, 128)
STIMCOL = (80, 255, 80)

screen = pg.display.set_mode((SIZE), HWSURFACE | DOUBLEBUF)
screen.fill(BGCOL)

surf = pg.Surface((200, 200), flags=HWSURFACE)
surf.fill(BGCOL)

pg.draw.rect(surf, STIMCOL, (10, 20, 40, 50))
pg.draw.rect(surf, STIMCOL,  (60, 70, 80, 90))

screen.blit(surf, (100, 100))

pg.display.flip()

running = True
while running:
    pg.transform.rotate(surf, -1)
    pg.display.flip()

Of course, if there is a better way of doing this, I’m all ears. Perhaps sprite groups are a good way to go? (Although I’ve never used them before … =/)

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:10:58+00:00Added an answer on June 15, 2026 at 2:10 pm

    You have a few errors in code:

    pygame.transform.rotate(surface,angle) returns a rotated surface

    and you are not blitting the surface in the while loop. So your code should look like this:

    import pygame as pg
    from pygame.locals import *
    
    SIZE = (800, 600)
    BGCOL = (128, 128, 128)
    STIMCOL = (80, 255, 80)
    
    screen = pg.display.set_mode((SIZE), HWSURFACE | DOUBLEBUF)
    screen.fill(BGCOL)
    
    surf = pg.Surface((200, 200), flags=HWSURFACE)
    surf.fill(BGCOL)
    
    pg.draw.rect(surf, STIMCOL, (10, 20, 40, 50))
    pg.draw.rect(surf, STIMCOL,  (60, 70, 80, 90))
    
    screen.blit(surf, (100, 100))
    
    pg.display.flip()
    
    running = True
    while running:
        surf = pg.transform.rotate(surf, -1) # updating rotation on the surface
        screen.blit(surf, (100, 100)) #bliting the resulting image every frame
        pg.display.flip()
    

    EDIT: After looking over comments in the pygame docs, there are many problems with resizing of the image when rotated anything other than 90 degrees. You should keep track of the rotation, and rotate the image from scratch by an increasing angle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A picture says more than a thousand words. As you can see, my fill
Don't really know how to formulate the question. A picture is worth a thousand
A picture is worth a thousand words, and I am guessing that the pictures
A picture is worth a thousand words and so I'll start off with it
A picture's worth a thousand words... For a bit more background, I have a
A picture is worth a thousand words: The app is setup for full screen
A picture is worth a thousand words - so here is the existing against
Because picture (or example) is worth more than thousand words, I'll use an example:
A picture is supposed to be worth a 1000 words, so let's see if
Sorry for the length, but a picture is worth 1000 words: In ASP.NET MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.