I am making one game in Java with Eclipse like HaverstMoon
and the time running is soo important, to this i make the class Time:
package com.ecojogos.world;
import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.JLabel;
import com.ecojogos.main.Game;
public class Tempo extends Game{
public int frames;
public static int seconds;
public static int minutes;
public static int hours;
public static int days;
public static int estations;
public static JLabel contagemTempo;
public void tick(){
frames++;
if(frames == 60){
frames = 0;
seconds++;
}
seconds++;
if(seconds == 60){
seconds = 0;
minutos++;
}
minutes++;
if(minutes == 60) {
minutes = 0;
hours++;
}
hours++;
if (hours == 24) {
hours = 0;
days++;
}
days++;
if (days == 30) {
days = 0;
estations++;
}
estations ++;
if(estations == 4){
estations = 0;
}
contingTime = new JLabel ("00:00:00");
contingTime.setFont(new Font(contingTime.getName(), Font.PLAIN, 80));
frame.add(contingTime, BorderLayout.CENTER);
}
public void render() {
contingTime.setText(String.format("%02d:%02d:%02d",seconds, minutes, hours));
}
but when i render the CountingTime in the class Game to appear in the Screen of game, the counting don't count, stay in 00:00:00
class game:
in Game render () {
g.drawString(String.format("%02d:%02d:%02d",Tempo.segundos, Tempo.minutos, Tempo.horas), 180, 180);
}