package nummer2;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
/**
*
* @author
*/
public class Nummer2 extends javax.swing.JFrame {
Kartenstore Field;
private static final int x = 1000;
private static final int y = 700;
boolean a=true,H1F=false,H2F=false,H3F=false;
int o=0;
Spritestore spst;
public Nummer2() throws IOException
{
setLocationRelativeTo(null);
try {
spst = new Spritestore();
spst.add(1, "Links.jpg"); //Fehler IOException Inputt==Null
spst.add(2, "Spielfeld.jpg");
a = true;
Field = new Kartenstore();
Field.add(1, ImageIO.read(getClass().getResource("/images/Flügelweber.jpg")), "Spalt", "Zerstört 1 offenes Monster auf der Spielfeldseite deines Gegners mit der niedrigsten ATK.", "Z0-MG1_ZMNA", -1, -1, -1);
inputimage = ImageIO.read(getClass().getResource("/images/Rückens.jpg"));
drehebild(180);
Field.add(0, filterimage, "Rücken", "Rücken", "Rücken", -1, -1, -1);
initComponents();
setCursor(Toolkit.getDefaultToolkit().createCustomCursor(ImageIO.read(getClass().getResource("/images/Standart_Cursor4.gif")),
new Point(0, 0), "standart"));
} catch (IOException io) {
Logger.getLogger(Nummer2.class.getName()).log(Level.SEVERE, null, io);
}
}
public static void main(final String args[]) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
Nummer2 frame = new Nummer2();
} catch (IOException ex) {
Logger.getLogger(Nummer2.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
private void initComponents() {
jPanel3 = new javax.swing.JPanel()
{
@Override
public void paint(Graphics g)
{
g.drawImage(Field.getKarte(0).getimg(), 0, 0,x*80/100/6 , y*9/100,0,310,346,500, null);//=346/438
}
};
jPanel1 = new javax.swing.JPanel(){
@Override
public void paint(Graphics g) {
super.paint(g);
if (a)
{
g.drawImage(spst.getSprite(2).getImage(), 0, 0, null);
}
}};
jPanel2 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel()
{
@Override
public void paint(Graphics g)
{
g.drawImage(Field.getKarte(0).getimg(), 0, 0,x*80/100/6 , y*9/100,0,310,346,500, null);//=346/438
}
};//
jPanel5 = new javax.swing.JPanel()
{
@Override
public void paint(Graphics g)
{
g.drawImage(Field.getKarte(0).getimg(), 0, 0,x*80/100/6 , y*9/100,0,310,346,500, null);//=346/438
}
};
setForeground(new java.awt.Color(0, 204, 204));
setResizable(false);
setLayout(new BorderLayout());
//.....//
jPanelI2 = new javax.swing.JPanel();
jPanelI2.setLayout(new BorderLayout());
add("Center",jPanelI2);
//.....//
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setFont(new java.awt.Font("Dialog", 0, 10));
setBackground(null);
//jPanel1
jPanel1.setPreferredSize(new Dimension (x*80/100,y*75/100));
jPanel1.setMaximumSize(new Dimension (x*80/100,y*75/100));
jPanel1.setMinimumSize(new Dimension (x*80/100,y*75/100));
jPanel1.setBackground(Color.YELLOW);
jPanelI2.add("Center",jPanel1);
//jPanel2
jPanel2.setPreferredSize(new Dimension (x*80/100,y*10/100));
jPanel2.setMaximumSize(new Dimension (x*80/100,y*10/100));
jPanel2.setMinimumSize(new Dimension (x*80/100,y*10/100));
jPanel2.setBackground(Color.RED);
jPanelI2.add("North",jPanel2);
jPanel2.setLayout(null);
//jPanel3
jPanel2.add(jPanel3);
jPanel3.setBounds(0, 0, x*80/100/6, y*9/100);
jPanel3.setBackground(null);
//jPanel4
jPanel2.add(jPanel4);
jPanel4.setBounds(x*80/100/5,0 , x*80/100/6, y*9/100);
jPanel4.setBackground(null);
//jPanel5
jPanel2.add(jPanel5);
jPanel5.setBounds(2*x*80/100/5, 0, x*80/100/6, y*9/100);
jPanel5.setBackground(null);
//...//
//...//
jPanelH = new javax.swing.JPanel();
jPanelH.setPreferredSize(new Dimension(x*80/100,y*15/100));
jPanelH.setMaximumSize(new Dimension(x*80/100,y*15/100));
jPanelH.setMinimumSize(new Dimension(x*80/100,y*15/100));
jPanelH.setBackground(Color.CYAN);
jPanelH.setLayout(null);
//SPIELERHAND
jPanelH1 = new javax.swing.JPanel()
{
@Override
public void paint(Graphics g)
{
if(H1F)
{
g.drawImage(Field.getKarte(1).getimg(), 0, 0,x*80/100/6 , y*14/100,0,0,346,252, null);//=346/438
}else
{
g.drawImage(Field.getKarte(1).getimg(), 0, 0,x*80/100/6 , y*9/100,0,0,346,162, null);//=346/438
}
}
};
jPanelH1.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseEntered(java.awt.event.MouseEvent evt) {
liegtUeberHandPlayer(evt,1);}
@Override
public void mouseExited(java.awt.event.MouseEvent evt) {
liegtNebenHandPlayer(evt,1);}
});
jPanelH.add(jPanelH1);
jPanelH1.setBounds(0, (y*15/100)-(y*9/100), x*80/100/6, y*9/100);
jPanelH1.setBackground(null);
jPanelH2 = new javax.swing.JPanel()
{
@Override
public void paint(Graphics g)
{
if(H2F)
{
g.drawImage(Field.getKarte(1).getimg(), 0, 0,x*80/100/6 , y*14/100,0,0,346,252, null);//=346/438
}else
{
g.drawImage(Field.getKarte(1).getimg(), 0, 0,x*80/100/6 , y*9/100,0,0,346,162, null);//=346/438
}
}
};
jPanelH2.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseEntered(java.awt.event.MouseEvent evt) {
liegtUeberHandPlayer(evt,2);}
@Override
public void mouseExited(java.awt.event.MouseEvent evt) {
liegtNebenHandPlayer(evt,2);}
});
jPanelH.add(jPanelH2);
jPanelH2.setBounds(x*80/100/5, (y*15/100)-(y*9/100), x*80/100/6, y*9/100);
jPanelH2.setBackground(null);
jPanelH3 = new javax.swing.JPanel()
{
@Override
public void paint(Graphics g)
{
if(H3F)
{
g.drawImage(Field.getKarte(1).getimg(), 0, 0,x*80/100/6 , y*14/100,0,0,346,252, null);//=346/438
}else
{
g.drawImage(Field.getKarte(1).getimg(), 0, 0,x*80/100/6 , y*9/100,0,0,346,162, null);//=346/438
}
}
};
jPanelH3.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseEntered(java.awt.event.MouseEvent evt) {
liegtUeberHandPlayer(evt,3);}
@Override
public void mouseExited(java.awt.event.MouseEvent evt) {
liegtNebenHandPlayer(evt,3);}
});
jPanelH.add(jPanelH3);
jPanelH3.setBounds(2*x*80/100/5, (y*15/100)-(y*9/100), x*80/100/6, y*9/100);
jPanelH3.setBackground(null);
jPanelI2.add("South",jPanelH);
//...//
jPanelI = new javax.swing.JPanel(){
@Override
public void paint(Graphics g)
{
g.drawImage(spst.getSprite(1).getImage(), 0, 0, null);
}
};
jPanelI.setPreferredSize(new Dimension(x*20/100,y));
jPanelI.setMaximumSize(new Dimension(x*20/100,y));
jPanelI.setMinimumSize(new Dimension(x*20/100,y));
jPanelI.setBackground(Color.GREEN);
add("West",jPanelI);
pack();
setVisible(true);
}
AffineTransform AT;
AffineTransformOp ATO;
BufferedImage filterimage;
BufferedImage inputimage;
private void drehebild(int image_angle)
{
if (image_angle != 0) {
AT = AffineTransform.getRotateInstance(Math.toRadians(-image_angle), inputimage.getWidth() / 2, inputimage.getHeight() / 2);
ATO = new AffineTransformOp(AT, AffineTransformOp.TYPE_BILINEAR);
filterimage = ATO.filter(inputimage, null);
} else {
filterimage = inputimage;
}
}
public void liegtUeberHandPlayer(java.awt.event.MouseEvent evt,int zzz)
{
if(zzz==1)
{
jPanelH1.setBounds(0, (y*15/100)-(y*14/100), x*80/100/6, y*14/100);
H1F=true;
}else if(zzz==2)
{
jPanelH2.setBounds(x*80/100/5, (y*15/100)-(y*14/100), x*80/100/6, y*14/100);
H2F=true;
}else if(zzz==3)
{
jPanelH3.setBounds(2*x*80/100/5, (y*15/100)-(y*14/100), x*80/100/6, y*14/100);
H3F=true;
}
repaint();
}
public void liegtNebenHandPlayer(java.awt.event.MouseEvent evt,int zzza) {
if(zzza==1)
{
jPanelH1.setBounds(0, (y*15/100)-(y*9/100), x*80/100/6, y*9/100);
H1F=false;
}else if(zzza==2)
{
jPanelH2.setBounds(x*80/100/5, (y*15/100)-(y*9/100), x*80/100/6, y*9/100);
H2F=false;
}else if(zzza==3)
{
jPanelH3.setBounds(2*x*80/100/5, (y*15/100)-(y*9/100), x*80/100/6, y*9/100);
H3F=false;
}
repaint();
}
//....//
private javax.swing.JPanel jPanelI2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanelH1;
private javax.swing.JPanel jPanelH2;
private javax.swing.JPanel jPanelH3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
//...//
private javax.swing.JPanel jPanelH;
//...//
private javax.swing.JPanel jPanelI;
}