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(); spiel.tick();
System.out.println(spiel.getSpielzeit()); System.out.println(spiel.getSpielzeit());
sf.refresh(); sf.refresh();
// try { try {
// Thread.sleep(200); Thread.sleep(200);
// } catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block // 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 cosA = (y - t.y)/getDistance(t);
double ax = cosT*d; double ax = cosT*d;
double ay = cosA*d; double ay = cosA*d;
x += ax; x -= ax;
y += ay; y -= ay;
} }
public String toString() { public String toString() {

View File

@ -13,15 +13,15 @@ public class JLabelSpieler extends JLabel{
// 0 SpielerA // 0 SpielerA
// 1 SpielerB // 1 SpielerB
// 2 Ball // 2 Ball
private static final ImageIcon spielerA = new ImageIcon("resources/nocoin.png"); private static final ImageIcon spielerA = new ImageIcon("resources/spielerA.png");
private static final ImageIcon spielerB = new ImageIcon("resources/coin.png"); private static final ImageIcon spielerB = new ImageIcon("resources/spielerB.png");
private static final ImageIcon ball = new ImageIcon("resources/nocoin.png"); private static final ImageIcon ball = new ImageIcon("resources/ball.png");
private static final ImageIcon[] icons = {spielerA,spielerB,ball}; private static final ImageIcon[] icons = {spielerA,spielerB,ball};
private int id; private int id;
public JLabelSpieler(int id,Position p) { public JLabelSpieler(int id,Position p) {
super(icons[id]); super(icons[id]);
this.id = 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.BorderLayout;
import java.awt.EventQueue; import java.awt.EventQueue;
import javax.swing.ImageIcon;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -35,7 +36,7 @@ public class SpielFrame extends JFrame {
public SpielFrame(Spiel sp) { public SpielFrame(Spiel sp) {
spiel = sp; spiel = sp;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 655, 432); setBounds(100, 100, 937, 511);
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setMinimumSize(new Dimension(size*90, size*45)); contentPane.setMinimumSize(new Dimension(size*90, size*45));
contentPane.setMaximumSize(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); feld.setBounds(10, 10, size*90, size*45);
contentPane.add(feld); contentPane.add(feld);
feld.setLayout(null); 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() { public void refresh() {
feld.removeAll(); feld.removeAll();
for(Spieler s:spiel.heimteam.spieler) { 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();
} }
} }