This commit is contained in:
GordonDaFreeman 2017-09-24 20:34:33 +02:00
parent 795873c502
commit 391e9ac5be
4 changed files with 31 additions and 13 deletions

View File

@ -20,12 +20,12 @@ public class Main {
spiel.tick();
System.out.println(spiel.getSpielzeit());
sf.refresh();
// try {
// Thread.sleep(200);
// } catch (InterruptedException e) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
// }
e.printStackTrace();
}
}
}

View File

@ -23,8 +23,8 @@ public class Position {
double cosA = (y - t.y)/getDistance(t);
double ax = cosT*d;
double ay = cosA*d;
x += ax;
y += ay;
x -= ax;
y -= ay;
}
public String toString() {

View File

@ -13,15 +13,15 @@ public class JLabelSpieler extends JLabel{
// 0 SpielerA
// 1 SpielerB
// 2 Ball
private static final ImageIcon spielerA = new ImageIcon("resources/nocoin.png");
private static final ImageIcon spielerB = new ImageIcon("resources/coin.png");
private static final ImageIcon ball = new ImageIcon("resources/nocoin.png");
private static final ImageIcon spielerA = new ImageIcon("resources/spielerA.png");
private static final ImageIcon spielerB = new ImageIcon("resources/spielerB.png");
private static final ImageIcon ball = new ImageIcon("resources/ball.png");
private static final ImageIcon[] icons = {spielerA,spielerB,ball};
private int id;
public JLabelSpieler(int id,Position p) {
super(icons[id]);
this.id = id;
this.setBounds((int)p.x, (int)p.y, 10, 10);
this.setBounds((int)p.x*10, (int)p.y*10, 10, 10);
}
}

View File

@ -3,6 +3,7 @@ package fussballmanager.gui;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
@ -35,7 +36,7 @@ public class SpielFrame extends JFrame {
public SpielFrame(Spiel sp) {
spiel = sp;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 655, 432);
setBounds(100, 100, 937, 511);
contentPane = new JPanel();
contentPane.setMinimumSize(new Dimension(size*90, size*45));
contentPane.setMaximumSize(new Dimension(size*90, size*45));
@ -51,12 +52,29 @@ public class SpielFrame extends JFrame {
feld.setBounds(10, 10, size*90, size*45);
contentPane.add(feld);
feld.setLayout(null);
JLabel test = new JLabel(new ImageIcon("resources/spielerA.png"));
test.setBounds((int)45*size, (int)20*size, 10, 10);
contentPane.add(test);
}
public void refresh() {
feld.removeAll();
for(Spieler s:spiel.heimteam.spieler) {
feld.add(new JLabelSpieler(0, s.p));
JLabelSpieler tmp = new JLabelSpieler(0, s.p);
tmp.setBounds((int)s.p.x*size, (int)s.p.y*size, 10, 10);
feld.add(tmp);
}
for(Spieler s:spiel.auswärtsteam.spieler) {
JLabelSpieler tmp = new JLabelSpieler(1, s.p);
tmp.setBounds((int)s.p.x*size, (int)s.p.y*size, 10, 10);
feld.add(tmp);
}
JLabelSpieler tmp = new JLabelSpieler(2, spiel.b.s.p);
tmp.setBounds((int)spiel.b.s.p.x*size-5, (int)spiel.b.s.p.y*size-5, 10, 10);
feld.add(tmp);
this.invalidate();
this.validate();
this.repaint();
}
}