Thread: converting a tick to minutes and seconds

Results 1 to 6 of 6
  1. #1 converting a tick to minutes and seconds 
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    alright so i have this tick

    Code:
    	@Override
    	public Tickable getGameCycle() {
    		return new Tickable(100) {
    			@Override
    			public void execute() {
    				if(!gameStarted && (waitingRoom.size() + participants.size()) >= PestControl.MINIMUM_SIZE && participants.size() <= 1) {
    					start();
    				}				
    			}			
    		};
    	}
    100 ticks = 60s which i know, but how would i do setter and getter for this? so i can display the time remaining on my interfaces
    Reply With Quote  
     

  2. #2  
    Shake n Bake

    Organic's Avatar
    Join Date
    Apr 2010
    Posts
    2,499
    Thanks given
    204
    Thanks received
    324
    Rep Power
    588
    Code:
    			World.getWorld().submit(new Event(XXXX) {
    				@Override
    				public void execute() {
    Dont know if your asking for this but here, XXXX is how many milliseconds you want.

    Just live life at its fullest.

    LOL
    Reply With Quote  
     

  3. #3  
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    Quote Originally Posted by Organic View Post
    Code:
    			World.getWorld().submit(new Event(XXXX) {
    				@Override
    				public void execute() {
    Dont know if your asking for this but here, XXXX is how many milliseconds you want.
    no i mean, ineed to convert this tick to minutes and seconds, and display it on the interface, the tick works fine the game starts, but i need to be able to display the tick time left until it ends on an itnerface lol
    Reply With Quote  
     

  4. #4  
    Registered Member
    thim slug's Avatar
    Join Date
    Nov 2010
    Age
    28
    Posts
    4,132
    Thanks given
    1,077
    Thanks received
    1,137
    Rep Power
    5000
    Quote Originally Posted by Andrew View Post
    alright so i have this tick

    Code:
    	@Override
    	public Tickable getGameCycle() {
    		return new Tickable(100) {
    			@Override
    			public void execute() {
    				if(!gameStarted && (waitingRoom.size() + participants.size()) >= PestControl.MINIMUM_SIZE && participants.size() <= 1) {
    					start();
    				}				
    			}			
    		};
    	}
    100 ticks = 60s which i know, but how would i do setter and getter for this? so i can display the time remaining on my interfaces
    Code:
    	private int elapsed= 0;
    
    	public int getCyclesElapsed() {
    		return elapsed;
    	}
    
    	@Override
    	public Tickable getGameCycle() {
    		return new Tickable(100) {
    			@Override
    			public void execute() {
    				if(!gameStarted && (waitingRoom.size() + participants.size()) >= PestControl.MINIMUM_SIZE && participants.size() <= 1) {
    					start();
    					duration ++;
    				}				
    			}			
    		};
    	}
    getGameCycle is an incorrect name tbh so is duration but I couldn't think of a word for amount of time passed by, lol.
    Edit: elapsed! Lol, just popped into my mind.
    Reply With Quote  
     

  5. #5  
    Registered Member Andrew's Avatar
    Join Date
    Nov 2008
    Posts
    2,890
    Thanks given
    612
    Thanks received
    207
    Rep Power
    551
    Quote Originally Posted by Samuel View Post
    Code:
    	private int duration = 0;
    
    	public int getDuration() {
    		return duration;
    	}
    
    	@Override
    	public Tickable getGameCycle() {
    		return new Tickable(100) {
    			@Override
    			public void execute() {
    				if(!gameStarted && (waitingRoom.size() + participants.size()) >= PestControl.MINIMUM_SIZE && participants.size() <= 1) {
    					start();
    					duration ++;
    				}				
    			}			
    		};
    	}
    the interface appears as 0, but i forget how, but isn't there a void, that convert ticks to minutes and seconds?
    Reply With Quote  
     

  6. #6  
    Registered Member
    thim slug's Avatar
    Join Date
    Nov 2010
    Age
    28
    Posts
    4,132
    Thanks given
    1,077
    Thanks received
    1,137
    Rep Power
    5000
    Quote Originally Posted by Andrew View Post
    the interface appears as 0, but i forget how, but isn't there a void, that convert ticks to minutes and seconds?
    What? The elapsed field will show how many cycles have elapsed? Lol. If you're looking for a method to convert cycles to milliseconds:

    Code:
    	public int cyclesToMilliseconds(int cycles) {
    		return cycles * 600;
    	}
    Then go from there to get seconds or minutes.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2012, 09:51 AM
  2. Minute to seconds and a seconds to minute method
    By Dark Regen in forum Configuration
    Replies: 11
    Last Post: 04-20-2010, 10:47 PM
  3. A simple int to minutes converter
    By Nour in forum Tutorials
    Replies: 20
    Last Post: 01-05-2008, 11:09 PM
  4. Message to Mods and Admins Void!
    By Pkitten in forum Tutorials
    Replies: 6
    Last Post: 08-14-2007, 10:31 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •