Results 1 to 3 of 3
  1. #1
    cyentw is offline Member
    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0

    Default Need help implementing a FPS counter

    Ok, so I'm making a game with a space ship that flies around the universe and discovering new planets. It works fine so far, but I'm looking to make it perform better and be better compatible with lesser-processors. :)

    So, I'm trying to put in an FPS counter and an entirely new game loop so that my game can decide for me what FPS I should use.

    I have two classes. Heres the big, main one:
    [Java] package cyentw.game.src; import java.awt.Color; import java.awt.Font; impor - Pastebin.com *I want to change the loop and put an FPS counter in around line 456, you can scroll past the rest if you'd like*
    And heres the init frame one, in case you'd like to see it for some reason.
    Java Code:
    package cyentw.game.src;
    
    import javax.swing.JFrame;
    
    
    public class Start extends JFrame{
    
    	public static JFrame frame;
    	public static int WIDTH = 500;
    	public static int HEIGHT = 500;
    	public Start() {
    		
    	}
    	public static void run()
    	{
    		frame = new JFrame();
    		frame.setSize(500, 500);
    		frame.add(new Main());
    
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		
    		frame.setLocationRelativeTo(null);
    		frame.setTitle("Spse Shp Gam");
    		frame.setResizable(false);
    		frame.setVisible(true);
    		
    		
    		
    		System.out.println("done w frame");
    		
    
    	}
    	public static void main(String[] args) {
    	    run();
    		
    	}
    }
    I've looked everywhere, but I still can't figure out how to make my game loop as quickly (or a bit slower) as it can, and my FPS is static.

    Any ideas/help?


    Thanks :-)

  2. #2
    cyentw is offline Member
    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0

    Default Re: Need help implementing a FPS counter

    Also for more about the timer goto lines 237 and 22 :)

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,703
    Rep Power
    5

    Default Re: Need help implementing a FPS counter

    Sorry but I'm not going to dig through your code on some external site. Post only the minimal relevant code and post it here if you want help.

    I am unclear on what you actually want here.

    - do you want to measure the realistic FPS of your game (in the range of 0 to the maximum FPS you lock down to)

    or

    - do you want to measure the THEORETICAL FPS that your game could achieve (which might be higher than the FPS you lock your game down to)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Implementing a counter for recursive program
    By wtbarr in forum New To Java
    Replies: 3
    Last Post: 04-20-2013, 11:41 AM
  2. Writing a counter
    By Pojahn_M in forum New To Java
    Replies: 4
    Last Post: 05-03-2011, 03:56 PM
  3. switch (counter) example please
    By erin.ctm in forum New To Java
    Replies: 1
    Last Post: 12-03-2010, 11:21 PM
  4. How to Add a Counter to a Variable?
    By Bbob in forum New To Java
    Replies: 22
    Last Post: 06-05-2010, 03:14 PM
  5. Counter
    By ks1615 in forum New To Java
    Replies: 6
    Last Post: 02-20-2009, 03:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •