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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:20:45+00:00 2026-06-11T11:20:45+00:00

In the same game as last time, I’ve ran into a new problem. When

  • 0

In the same game as last time, I’ve ran into a new problem. When I move the mouse, FPS increases from around 60 to over 500. I know what you’re thinking; it’s not because of on_draw() getting fired each event (I think), since I already did override of pyglet.app.EventLoop.idle:

class EventLoop:
    def idle(self):
        pyglet.clock.tick(poll=True)
        return pyglet.clock.get_sleep_time(sleep_idle=True)

pyglet.app.EventLoop = EventLoop()

Also I call flip() on the window in my drawing function. All the useless mouse motion events take up a lot of CPU, which is annoying. What can I do about it?

Edit

I added window.invalid = False to my drawing function and window.invalid = True to my update function, this seems to reduce CPU usage with other mouse actions.

Edit 2

The drawing function is a typical on_draw() function.

Edit 3

After some more investigating, it seems that all those events don’t take that much CPU as I thought they would. Still it would be good to know if this is the way Pyglet is supposed to act, or if it’s something that should be avoided.

  • 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-11T11:20:47+00:00Added an answer on June 11, 2026 at 11:20 am

    All you should be doing on mouse events is updating your apps’ model of the input control state and using that in the next regular scheduled update and redisplay of the world model (which is presumably much more complex with physics and rendering and stuff).

    ie just because mouse events come in at ~300fps doesn’t mean you actually have to do all the stuff you want to do at 300fps.

    It’s been a while since I did any Pyglet, but the pattern I seemed to use was to subclass Pyglet’s window.Window as MyGameWindow, then that registered event handlers like

       @self.event
        def on_mouse_motion(x,y,dx,dy):
            self.mouse_position=(x,y)
            self.mouse_buttons=0
            self.invalid = False
    

    (also on_mouse_drag, on_mouse_press, on_mouse_release). Hmmm… actually, I think that assignment to self.invalid might have been crucial for overriding Pyglet’s default behaviour and defering any further updating/drawing until the next “clock tick”.

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

Sidebar

Related Questions

this is the second game that I'm having issues with in the same area...
having same issue, i am totally new in php. i install XAMPP then download
This problem is same as asked in here . Given a list of coins,
I have the same problem that is listed in the following thread. WSDL first
I'm designing a game for the first time, but I wonder on what game
This is the bane of my life: Traceback (most recent call last): File C:\Users\User\Documents\PYTHON\GAME
I've been looking into centralising my computer game saves to make it easier to
I'm writing an online game which allows a user to progress from one puzzle
I'm having a strange problem with the following code, I'm writing a game launcher
I'm using Delphi to develop real-time control software and over the last couple 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.