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

  • Home
  • SEARCH
  • 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 7720661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:43:54+00:00 2026-06-01T03:43:54+00:00

I have a block of code that worked outside of a function, but not

  • 0

I have a block of code that worked outside of a function, but not inside.

I also made sure the necessary variables were global.

I can get the width of the surface using chair.get_width() inside the function and it works fine, but I cannot execute screen.blit(chair, (10,10)) for some reason. I don’t get an error, it just doesn’t do anything…

Here is my script (it creates a window, then calls a function every 100 milliseconds that gets the mouse position, rotates an image x degrees and then blits (or should blit) the image to the window):

    cif = "images/chair3.png"

    import pygame, sys
    from pygame.locals import *

    pygame.init()

    screen = pygame.display.set_mode((640,480),0,32)

    chair = pygame.image.load(cif).convert_alpha()

    pygame.time.set_timer(USEREVENT + 1, 100)

    def cursor(speed):
        global i
        global chair
                    global screen
        x,y = pygame.mouse.get_pos()
        x -= chair.get_width()/2
        y -= chair.get_height()/2

        if i < 360:
            i = i + 360/(1000/speed)
        else:
            i = 0

        orig_chair_rect = chair.get_rect()
        chair1 = pygame.transform.rotate(chair, i);
        rot_chair_rect = orig_chair_rect.copy()
        rot_chair_rect.center = chair1.get_rect().center
        chair1 = chair1.subsurface(rot_chair_rect).copy()

        print chair.get_width()

        screen.blit(chair1,(x,y))

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                cursor(50)
  • 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-01T03:43:55+00:00Added an answer on June 1, 2026 at 3:43 am

    You do need to use pygame.display.flip() or pygame.display.update(), the screen will never update if you don’t, and therefore your chair will not be blitted onto the screen.

    Tried it, it works. If it doesn’t work for you, reinstall Pygame, and try again.

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

Sidebar

Related Questions

I have a block of code that basically intializes several classes, but they are
I have a block of code that works and I wanted to ask what
I have a block of code that is repeated within a DB2 stored procedure.
I have a block of code that serializes a type into a Html tag.
I have a block of JSP code that needs to be used in several
I have a small code block that should append text to the beg of
I have a submit button that is a block of HTML code because of
I have a code snippet written in PHP that pulls a block of text
If you have some blocks of code that you would like to prevent execution
I have a black box of code that contains many threads. There is no

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.