mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 08:59:44 +02:00
bugfixes related to game panel visibility and game tick
This commit is contained in:
@@ -232,7 +232,7 @@ public class Main extends JFrame implements Runnable {
|
|||||||
delta += (now-lastTime) / ns;
|
delta += (now-lastTime) / ns;
|
||||||
lastTime = now;
|
lastTime = now;
|
||||||
if (delta >= 1) {
|
if (delta >= 1) {
|
||||||
tick();
|
tick();
|
||||||
updates++;
|
updates++;
|
||||||
delta--;
|
delta--;
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,8 @@ public class Main extends JFrame implements Runnable {
|
|||||||
|
|
||||||
if (System.currentTimeMillis() - timer > 1000) {
|
if (System.currentTimeMillis() - timer > 1000) {
|
||||||
timer += 1000;
|
timer += 1000;
|
||||||
Logger.write(updates +" Ticks, fps " + frames);
|
this.setTitle("HeatUp" + updates +" Ticks, fps " + frames);
|
||||||
|
//Logger.write(updates +" Ticks, fps " + frames);
|
||||||
updates = 0;
|
updates = 0;
|
||||||
frames = 0;
|
frames = 0;
|
||||||
}
|
}
|
||||||
@@ -258,13 +259,19 @@ public class Main extends JFrame implements Runnable {
|
|||||||
}
|
}
|
||||||
// alles was geupdatet werden muss hier rein
|
// alles was geupdatet werden muss hier rein
|
||||||
private void tick() {
|
private void tick() {
|
||||||
PanelBuilder.kb.checkKeyActivity();
|
|
||||||
|
if(MenuPanel.gameExists == 2) {
|
||||||
|
PanelBuilder.kb.checkKeyActivity();
|
||||||
|
}
|
||||||
|
|
||||||
if (!pause) {
|
if (!pause) {
|
||||||
if ( ! gamePanel.isVisible() ) {
|
if ( ! gamePanel.isVisible() ) {
|
||||||
gamePanel.setVisible(true);
|
gamePanel.setVisible(true);
|
||||||
actionPanel.setVisible(true);
|
actionPanel.setVisible(true);
|
||||||
statusPanel.setVisible(true);
|
statusPanel.setVisible(true);
|
||||||
|
|
||||||
|
menuPanel.setVisible(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
PanelBuilder.tick();
|
PanelBuilder.tick();
|
||||||
} else if ( pause ) {
|
} else if ( pause ) {
|
||||||
@@ -272,6 +279,8 @@ public class Main extends JFrame implements Runnable {
|
|||||||
gamePanel.setVisible(false);
|
gamePanel.setVisible(false);
|
||||||
actionPanel.setVisible(false);
|
actionPanel.setVisible(false);
|
||||||
statusPanel.setVisible(false);
|
statusPanel.setVisible(false);
|
||||||
|
|
||||||
|
menuPanel.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// alles was animiert wird hier rein (paints)
|
// alles was animiert wird hier rein (paints)
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ import de.heatup.objects.PowerUpHandler;
|
|||||||
import de.heatup.timers.HardwareResetTimers;
|
import de.heatup.timers.HardwareResetTimers;
|
||||||
import de.heatup.ui.actionPanel.ActionControl;
|
import de.heatup.ui.actionPanel.ActionControl;
|
||||||
import de.heatup.ui.actionPanel.ActionWatcher;
|
import de.heatup.ui.actionPanel.ActionWatcher;
|
||||||
|
import de.heatup.ui.menu.MenuPanel;
|
||||||
|
|
||||||
public class PanelBuilder {
|
public class PanelBuilder {
|
||||||
private static JPanel actionPanel;
|
public static JPanel actionPanel;
|
||||||
private static JPanel outerPanel;
|
private static JPanel outerPanel;
|
||||||
private static JPanel statusPanel;
|
public static JPanel statusPanel;
|
||||||
private static JPanel gamePanel;
|
private static JPanel gamePanel;
|
||||||
|
|
||||||
public static KeyBindings kb;
|
public static KeyBindings kb;
|
||||||
@@ -46,7 +47,7 @@ public class PanelBuilder {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public static void tick() {
|
public static void tick() {
|
||||||
switch (gameState) {
|
switch (MenuPanel.gameExists) {
|
||||||
case 1:
|
case 1:
|
||||||
Logger.write("Menu tick");
|
Logger.write("Menu tick");
|
||||||
break;
|
break;
|
||||||
@@ -104,20 +105,20 @@ public class PanelBuilder {
|
|||||||
public static void startMenu() {
|
public static void startMenu() {
|
||||||
|
|
||||||
// StatusPanel bauen
|
// StatusPanel bauen
|
||||||
StatusPanelAdder.setPanel(statusPanel);
|
//StatusPanelAdder.setPanel(statusPanel);
|
||||||
StatusPanelAdder.createPanel();
|
//StatusPanelAdder.createPanel();
|
||||||
|
|
||||||
// ActionPanel bauen
|
// ActionPanel bauen
|
||||||
ActionControl.setPanel(actionPanel);
|
//ActionControl.setPanel(actionPanel);
|
||||||
|
|
||||||
|
|
||||||
createGame(1); /* wird eigentlich vom menue aufgerufen */
|
//createGame(1); /* wird eigentlich vom menue aufgerufen */
|
||||||
|
|
||||||
}
|
}
|
||||||
public static JPanel getGamePanel() {
|
public static JPanel getGamePanel() {
|
||||||
return gamePanel;
|
return gamePanel;
|
||||||
}
|
}
|
||||||
private static void createGame(int map) {
|
public static void createGame(int map) {
|
||||||
|
|
||||||
instancedObjects = new InstancedObjects();
|
instancedObjects = new InstancedObjects();
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import de.heatup.logging.Logger;
|
|||||||
import de.heatup.ui.FontLoader;
|
import de.heatup.ui.FontLoader;
|
||||||
import de.heatup.ui.Main;
|
import de.heatup.ui.Main;
|
||||||
import de.heatup.ui.PanelBuilder;
|
import de.heatup.ui.PanelBuilder;
|
||||||
|
import de.heatup.ui.StatusPanelAdder;
|
||||||
|
import de.heatup.ui.actionPanel.ActionControl;
|
||||||
|
|
||||||
public class MenuPanel {
|
public class MenuPanel {
|
||||||
|
|
||||||
@@ -28,6 +30,8 @@ public class MenuPanel {
|
|||||||
private static Font emulogic;
|
private static Font emulogic;
|
||||||
private static Font ttfbase;
|
private static Font ttfbase;
|
||||||
|
|
||||||
|
// 1=GameNotInit 2=GameInit
|
||||||
|
public static int gameExists = 1;
|
||||||
|
|
||||||
|
|
||||||
public MenuPanel() {
|
public MenuPanel() {
|
||||||
@@ -75,7 +79,25 @@ public class MenuPanel {
|
|||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
// @TODO: implement start game
|
// @TODO: implement start game
|
||||||
|
|
||||||
//PanelBuilder.createGame(1);
|
// just a trie
|
||||||
|
// StatusPanel bauen
|
||||||
|
StatusPanelAdder.setPanel(PanelBuilder.statusPanel);
|
||||||
|
StatusPanelAdder.createPanel();
|
||||||
|
|
||||||
|
// ActionPanel bauen
|
||||||
|
ActionControl.setPanel(PanelBuilder.actionPanel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PanelBuilder.createGame(1);
|
||||||
|
gameExists = 2;
|
||||||
|
menuPanel.setVisible(false);
|
||||||
|
|
||||||
|
PanelBuilder.getGamePanel().setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
|
//** game, action, status panel redraw and check visibility */
|
||||||
|
|
||||||
Logger.write("Game Started via menu");
|
Logger.write("Game Started via menu");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user