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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:03:10+00:00 2026-05-27T01:03:10+00:00

I have a bunch of objects at different coordinates, and I need to animate

  • 0

I have a bunch of objects at different coordinates, and I need to animate them moving to another coordinate
ie.
one object is at coodinate (234,30) and I need it to go to (310,540).

How do I do this in pygame? I tried messing around with slope and stuff like that but I couldn’t get my object,s position to smoothly go there.

  • 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-05-27T01:03:11+00:00Added an answer on May 27, 2026 at 1:03 am

    Well, you should just change it’s coordinates in your game loop.

    There’s two ways you can do this.

    First, for example, if you want your object to move 50px per second, you should send your update function ticks in every frame, and then change your object’s x and y coordinates by x + x_speed * ticks / 1000 (here, ticks is in miliseconds, so you should convert it to seconds).

    def update_object(ticks):
        object.x += float(x_speed) * ticks / 1000  # converting to float is needed
    
    # this is your main game loop
    time = pygame.time.Clock()
    ticks = 0
    while running:
        ...
        update_object(ticks)
        ticks = time.tick(30)  # this 30 means time.tick() waits enough to make your max framerate 30
    

    Note that you may need to convert object.x to int while you’re blitting(or drawing) it to a surface. With this, your object moves same amount in every second.

    Second way is moving your object in every frame. This means your object’s speed may change depending on your frame rate(for example, in a crowded scene, your framerate may drop and this makes your objects move slower).

    def update_object():
       object.x += object_vx
       object.y += object.vy
    
    # this is your main game loop
    while running:
        ...
        update_object()
    

    BTW, I forgot to mention your object implementation. My preferred way to save coordinates in my objects is by using pygame.Rect’s. pygame.Rect has 4 properties, x, y, height, and width. With this you can also hold your object’s sprite’s length and height.

    For example:

    character = pygame.Rect(10, 10, 20, 30)
    character_image = pygame.image.load(...)
    screen.blit(character_image, character)  # screen is you surface
    

    And when you want to change your character’s coordinates:

    character.x += x_amount
    character.y += y_amount
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of different objects that are commonly edited in the same
I have a bunch of different objects(and objec types) that i want to write
I have a bunch of shapes that I'm rendering with different graphics objects. I'd
I have a bunch of simple data objects of different types (all properties are
I have a bunch of objects in my application (Organisations, Individuals, Orders, etC) and
I have a bunch of objects in a flat structure. These objects have an
I have a bunch of objects that have a value and a date field:
I currently have a bunch of SQLCHAR objects from a database query. The query
Dumb question. Lets say I have a bunch of person objects with their fields
Is there any method like the array_unique for objects? I have a bunch of

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.