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:

PStatClient.connect()

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.cHandler.addInPattern('into-%in')        
    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)
    self.cTrav.addCollider(ballNodePath,self.cHandler)

    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)
    self.cTrav.addCollider(RwallNodePath,self.cHandler)

    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.cTrav.addCollider(LwallNodePath,self.cHandler)
    
    self.accept('into-Rwall', self.RwallColliding)
    self.accept('into-Lwall', self.LwallColliding)
# end setupCollisions

def RwallColliding(self, CEntry):
self.moveback()

def LwallColliding(self, CEntry):
self.moveagain()

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.

David

You can use the call:

base.setFrameRateMeter(flag)

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