mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 12:49:45 +02:00
EventQueue angepasst
This commit is contained in:
@@ -2,6 +2,7 @@ package de.heatup.testing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
|
||||
@@ -45,23 +46,10 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
public static Opponent opponent04;
|
||||
public static Opponent opponent05;
|
||||
public static Opponent opponent06;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Logging ausgabe auf Console aktivieren bzw. deaktivieren.
|
||||
Logger.enableLogging();
|
||||
|
||||
/*
|
||||
* hier drin bauen wir unser ui zusammen.
|
||||
*/
|
||||
|
||||
GameLoopD frame = new GameLoopD();
|
||||
|
||||
|
||||
frame.setTitle("HeatUP!");
|
||||
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
frame.setResizable(false);
|
||||
public GameLoopD(){
|
||||
setTitle("HeatUP!");
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setResizable(false);
|
||||
|
||||
|
||||
outerPanel = new JPanel();
|
||||
@@ -86,9 +74,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
outerPanel.add(gamePanel,BorderLayout.CENTER);
|
||||
outerPanel.add(actionPanel,BorderLayout.SOUTH);
|
||||
|
||||
frame.add(outerPanel);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
add(outerPanel);
|
||||
pack();
|
||||
setVisible(true);
|
||||
|
||||
// StatusPanel bauen
|
||||
StatusPanelAdder.setPanel(statusPanel);
|
||||
@@ -158,6 +146,35 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
statusPanel.setVisible(true);
|
||||
gamePanel.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Logging ausgabe auf Console aktivieren bzw. deaktivieren.
|
||||
Logger.enableLogging();
|
||||
|
||||
/*
|
||||
* hier drin bauen wir unser ui zusammen.
|
||||
*/
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final GameLoopD frame = new GameLoopD();
|
||||
frame.repaint();
|
||||
Thread ht= new Thread(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
frame.start();
|
||||
}
|
||||
};ht.start();ht.setName("Thread-zum-starten-von -GL");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//GameInterface.getGamePanel().repaint();
|
||||
//GameInterface.getGamePanel().setComponentZOrder(dynO1, 1);
|
||||
//GameInterface.getGamePanel().add(dynO1);
|
||||
@@ -167,8 +184,8 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
* ende
|
||||
*/
|
||||
|
||||
frame.repaint();
|
||||
frame.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static synchronized void pause() {
|
||||
@@ -187,9 +204,9 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
|
||||
running = true;
|
||||
thread = new Thread(this);
|
||||
thread.setName("GameLoopD");
|
||||
thread.start();
|
||||
|
||||
}
|
||||
@@ -258,18 +275,66 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
}
|
||||
kb.checkKeyActivity();
|
||||
if (!pause) {
|
||||
ActionWatcher.tick();
|
||||
ActionControl.tick();
|
||||
HardwareResetTimers.tick();
|
||||
player01.tick();
|
||||
opponent01.tick();
|
||||
opponent02.tick();
|
||||
opponent03.tick();
|
||||
opponent04.tick();
|
||||
opponent05.tick();
|
||||
opponent06.tick();
|
||||
CollisionHandler.tick();
|
||||
StatusPanelAdder.tick();
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
ActionWatcher.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
ActionControl.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
HardwareResetTimers.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
player01.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
opponent01.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
opponent02.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
opponent03.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
opponent04.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
opponent05.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
opponent06.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
CollisionHandler.tick();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
StatusPanelAdder.tick();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// alles was animiert wird hier rein (paints)
|
||||
|
||||
@@ -36,6 +36,9 @@ public class Player extends JComponent {
|
||||
|
||||
public Player() {
|
||||
CollisionHandler.addMovingObject(this);
|
||||
if (bf1 == null) {
|
||||
loadBufferedImage();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSpeedMultiplicator(int factor) {
|
||||
@@ -61,10 +64,6 @@ public class Player extends JComponent {
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
g2d = (Graphics2D) g;
|
||||
if (bf1 == null) {
|
||||
loadBufferedImage();
|
||||
}
|
||||
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.drawImage(bf1, 0, 0, this);
|
||||
g2d.setStroke(new BasicStroke(8.0f));
|
||||
|
||||
@@ -158,7 +158,6 @@ public class KeyBindings extends KeyAdapter {
|
||||
}
|
||||
|
||||
public void checkKeyActivity() {
|
||||
|
||||
if (isLeft() && CollisionHandler.checkCollision(player, 'l')) {
|
||||
if (!player.animate ) {
|
||||
player.setGridLocation(player.getGridLocation().x-1, player.getGridLocation().y);
|
||||
|
||||
@@ -42,6 +42,7 @@ public class ActionControl{
|
||||
resetActionPanel();
|
||||
}
|
||||
public static void setAction(int rd){
|
||||
System.out.println(" 33 "+Thread.currentThread());
|
||||
setKeyA();
|
||||
if(rd==1){
|
||||
option=1;
|
||||
|
||||
Reference in New Issue
Block a user