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 7790361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:33:39+00:00 2026-06-01T21:33:39+00:00

I am new to pygame. I am trying to move a polygon inside a

  • 0

I am new to pygame. I am trying to move a polygon inside a window as the player presses the UP, DOWN, RIGHT or LEFT key.
but I do not know how to do it. Can any one guide me for this problem?

import random, pygame, sys 
from pygame.locals import *
import time

BLACK = (0,0,0)
WHITE = (255,255,255)
RED = (255,0,0)

windowSurface = pygame.display.set_mode((700,700),0,32)
windowSurface.fill(WHITE)



def main():
    pygame.init()
    worm = pygame.draw.polygon( windowSurface, RED, ( (210,350),(220,360),(230,350),(240,360),(250,350),(260,360),(270,350),(280,360),(290,350),(300,360),(300,355),(290,345),(280,355),(270,345)  
                                                                    ,(260,355),(250,345),(240,355),(230,345),(220,355),(210,350) ))


    pygame.display.update()
    time.sleep(25)

    return 0


if __name__ == '__main__':
    main()    
  • 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-01T21:33:41+00:00Added an answer on June 1, 2026 at 9:33 pm

    You draw it in a different position each time, depending on what position it should be drawn, Which is decided on whether the user has pressed a certain key or not.

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

Sidebar

Related Questions

Im New To Pygame But Kinda OK On Python, Im Creating A Zombie Shooting
new to ruby, and rails... but not to the amp stack. my preferred method
I am relatively new to linux and am trying to install the pygame dev
New to Web2py, so my question might not be too clear. I'm trying to
New to Chrome programming, but am more or less familiar with Javascript. Goal: A
I am new to python and graphics but have programmed before. According to http://en.wikipedia.org/wiki/Transformation_matrix#Rotation
New question, but really close to need to refresh page in jquery mobile .
So, Iv'e got a pygame application. Right now, it takes a command line argument
I'm new to stackoverflow, but was hoping for a little insight from more advanced
New to Python and trying to figure out what went wrong here. Making a

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.