FPS- frames per second

how to find out the actual FPS and what is the method to get the FPS and print it on the screen

Read the PStats entry in the manual…
To get the performance statistics you can either edit your config.prc or use the code:


OK Thank you.
I got it from the GlobalClock’s method.
However when I use collision detection method the frame rate drops 10 frames per second between every two collisions in my pong game. The ball hitting two walls.
The Code is:

def setcoln(self):

    self.cHandler = CollisionHandlerEvent()        
    self.cTrav = CollisionTraverser()
    base.cTrav = self.cTrav
    self.collEntry = CollisionEntry
    bounds = self.ball.getChild(0).getBounds()
    center = bounds.getCenter()
    radius = bounds.getRadius()                                      
    ballNode = CollisionNode("ball")
    ballNode.addSolid(CollisionSphere(0,0,0, 0.25))
    ballNodePath = self.ball.attachNewNode(ballNode)

    bounds = self.Rwall.getChild(0).getBounds()
    center = bounds.getCenter()
    radius = bounds.getRadius()                                      
    RwallNode = CollisionNode("Rwall")
    RwallNode.addSolid(CollisionSphere(0,0,0, 0.2))
    RwallNodePath = self.Rwall.attachNewNode(RwallNode)

    bounds = self.Lwall.getChild(0).getBounds()
    center = bounds.getCenter()
    radius = bounds.getRadius()                                      
    LwallNode = CollisionNode("Lwall")
    LwallNode.addSolid(CollisionSphere(0,0,0, 0.2))
    LwallNodePath = self.Lwall.attachNewNode(LwallNode)
    self.accept('into-Rwall', self.RwallColliding)
    self.accept('into-Lwall', self.LwallColliding)
# end setupCollisions

def RwallColliding(self, CEntry):

def LwallColliding(self, CEntry):

def moveback(self):
self.px = -(self.px)

def moveagain(self):
self.px = -(self.px)

can you please tell me how to overcome this problem as the speed of the ball goes on reducing and after few collisions the ball goes through the wall.

I don’t see anything obviously wrong. You’re not calling setcoIn with each collision, are you? If you call it more than once in your application, it will set up a new collision traverser each time you call it.

If that’s not the case, it might be useful to follow Legion’s suggestion, and take a look at the output of PStats. It can show you what part of the program is causing the 10fps showdown, so you can know whether it is the collision system itself, or some part of the Python code that is responding to the collision system, or something else altogether. Then it will be clearer how to fix it.

Incidentally, one easy way to see the frames per second is to put:

show-frame-rate-meter 1

in your Config.prc file.


You can use the call:


where flag is either True or False to show or hide the frame rate meter, respectively.