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

The Archive Base Latest Questions

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

I’m trying to use Pygame’s Clock.tick, but it’s not there. I’m positive Pygame has

  • 0

I’m trying to use Pygame’s Clock.tick, but it’s not there. I’m positive Pygame has it for Python 3, even if I use dir(pygame.time.Clock), it’s still not there. I’m not sure if I’m doing something drastically wrong or Pygame doesn’t have it for Python 3.

Here’s my code:

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

class Pong_Ball(object):
    def __init__(self, screen, screen_height, screen_width):
        self.screen = screen
        self.screen_height = screen_height
        self.screen_width = screen_width

    def update(self):
        #pong ball's properties
        self.ball_color = 191,191,191
        self.pos_x = 100
        self.pos_y = 100
        self.vel_x = 1
        self.vel_y = 1

        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    sys.exit()

            #clear the screen
            self.screen.fill((0,50,100))

            #move the pong ball
            self.pos_x += self.vel_x
            self.pos_y += self.vel_y

            #keep the ball on the screen
            if self.pos_x > self.screen_width or self.pos_x < 0:
                self.vel_x = -self.vel_x
            if self.pos_y > self.screen_height or self.pos_y < 0:
                self.vel_y = -self.vel_y

            #draw the pong ball
            self.position = self.pos_x, self.pos_y
            pygame.draw.circle(self.screen, self.ball_color, self.position, 10)

            #update the display
            pygame.time.Clock.tick(60)
            pygame.display.update()

def main():
    pygame.init()
    screen = pygame.display.set_mode((800,600))
    ball = Pong_Ball(screen, 600, 800)
    ball.update()

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-15T17:57:36+00:00Added an answer on June 15, 2026 at 5:57 pm

    Ah. The documentation, though perfectly standard, could be a little confusing. Even though they write Clock.tick, they don’t mean that it’s a staticmethod of the class. You call it on an instance:

    >>> import pygame
    >>> clock = pygame.time.Clock()
    >>> clock
    <Clock(fps=0.00)>
    >>> clock.tick
    <built-in method tick of Clock object at 0xb402b408>
    >>> clock.tick()
    14487
    >>> clock.tick()
    836
    

    To confirm that it’s behaving:

    >>> import time
    >>> for i in range(5):
    ...     print clock.tick()
    ...     time.sleep(0.17)
    ...     
    22713
    172
    171
    171
    172
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace

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.