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