annotate anielskiepuzzle/src/trefle/Trefle.java @ 6:542e305f23f4

arkanoid-trix-debian-dir
author prymula <prymula76@outlook.com>
date Wed, 31 Jan 2024 20:40:57 +0100
parents 2787f5e749ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
2 Trefle - ukladanka z puzzli
prymula <prymula76@outlook.com>
parents:
diff changeset
3 Przemyslaw R. Pieraszczyk
prymula <prymula76@outlook.com>
parents:
diff changeset
4 20-01-2021
prymula <prymula76@outlook.com>
parents:
diff changeset
5 licencja - GPL
prymula <prymula76@outlook.com>
parents:
diff changeset
6 powered by ATOM
prymula <prymula76@outlook.com>
parents:
diff changeset
7 */
prymula <prymula76@outlook.com>
parents:
diff changeset
8
prymula <prymula76@outlook.com>
parents:
diff changeset
9
prymula <prymula76@outlook.com>
parents:
diff changeset
10 package trefle;
prymula <prymula76@outlook.com>
parents:
diff changeset
11
prymula <prymula76@outlook.com>
parents:
diff changeset
12 import java.awt.*; // Toolkit
prymula <prymula76@outlook.com>
parents:
diff changeset
13 import javax.swing.JFrame;
prymula <prymula76@outlook.com>
parents:
diff changeset
14 import javax.swing.JLabel;
prymula <prymula76@outlook.com>
parents:
diff changeset
15 import javax.swing.JPanel;
prymula <prymula76@outlook.com>
parents:
diff changeset
16 import javax.swing.JButton;
prymula <prymula76@outlook.com>
parents:
diff changeset
17 //import javax.swing.JComponent;
prymula <prymula76@outlook.com>
parents:
diff changeset
18 import javax.swing.JMenuBar;
prymula <prymula76@outlook.com>
parents:
diff changeset
19 import javax.swing.JMenu;
prymula <prymula76@outlook.com>
parents:
diff changeset
20 import javax.swing.JMenuItem;
prymula <prymula76@outlook.com>
parents:
diff changeset
21 import javax.swing.JOptionPane;
prymula <prymula76@outlook.com>
parents:
diff changeset
22 import javax.swing.Box;
prymula <prymula76@outlook.com>
parents:
diff changeset
23 import javax.swing.JTextArea;
prymula <prymula76@outlook.com>
parents:
diff changeset
24 import javax.swing.JDialog;
prymula <prymula76@outlook.com>
parents:
diff changeset
25 import javax.swing.JTextField;
prymula <prymula76@outlook.com>
parents:
diff changeset
26 import javax.swing.JCheckBox;
prymula <prymula76@outlook.com>
parents:
diff changeset
27 import javax.swing.BorderFactory;
prymula <prymula76@outlook.com>
parents:
diff changeset
28 import javax.swing.WindowConstants;
prymula <prymula76@outlook.com>
parents:
diff changeset
29 import java.awt.event.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
30 import java.awt.event.ActionListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
31 //import java.awt.event.KeyListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
32 import java.awt.event.ActionEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
33 import java.awt.event.WindowEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
34 import java.awt.event.WindowAdapter;
prymula <prymula76@outlook.com>
parents:
diff changeset
35 import java.awt.event.ComponentAdapter;
prymula <prymula76@outlook.com>
parents:
diff changeset
36 import java.awt.event.ComponentEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
37 import java.awt.event.ItemEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
38
prymula <prymula76@outlook.com>
parents:
diff changeset
39 import java.awt.event.MouseListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
40 import java.awt.event.MouseEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
41
prymula <prymula76@outlook.com>
parents:
diff changeset
42 //import java.awt.event.KeyEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
43 import java.util.*; //Timer
prymula <prymula76@outlook.com>
parents:
diff changeset
44 //import java.awt.Robot;
prymula <prymula76@outlook.com>
parents:
diff changeset
45 import java.awt.Toolkit;
prymula <prymula76@outlook.com>
parents:
diff changeset
46
prymula <prymula76@outlook.com>
parents:
diff changeset
47 import java.beans.*; //property change stuff
prymula <prymula76@outlook.com>
parents:
diff changeset
48 import java.io.BufferedReader;
prymula <prymula76@outlook.com>
parents:
diff changeset
49 import java.io.InputStream;
prymula <prymula76@outlook.com>
parents:
diff changeset
50 import java.io.OutputStream;
prymula <prymula76@outlook.com>
parents:
diff changeset
51 import java.io.InputStreamReader;
prymula <prymula76@outlook.com>
parents:
diff changeset
52 import java.io.IOException;
prymula <prymula76@outlook.com>
parents:
diff changeset
53 import java.io.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
54
prymula <prymula76@outlook.com>
parents:
diff changeset
55 import java.awt.image.BufferedImage;
prymula <prymula76@outlook.com>
parents:
diff changeset
56 import java.awt.image.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
57 import javax.imageio.ImageIO;
prymula <prymula76@outlook.com>
parents:
diff changeset
58 import javax.imageio.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
59
prymula <prymula76@outlook.com>
parents:
diff changeset
60
prymula <prymula76@outlook.com>
parents:
diff changeset
61 public class Trefle extends JPanel implements ActionListener {
prymula <prymula76@outlook.com>
parents:
diff changeset
62
prymula <prymula76@outlook.com>
parents:
diff changeset
63 static JMenuBar menuBar;
prymula <prymula76@outlook.com>
parents:
diff changeset
64 static JMenu menu, info, menu2, nowplay;
prymula <prymula76@outlook.com>
parents:
diff changeset
65 static JMenuItem menuItem, menuExit, menuInfo, menuPref;
prymula <prymula76@outlook.com>
parents:
diff changeset
66 static JFrame frame;
prymula <prymula76@outlook.com>
parents:
diff changeset
67 //static boolean go=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
68 //static JPanel screen;
prymula <prymula76@outlook.com>
parents:
diff changeset
69 static Trefle trefle;
prymula <prymula76@outlook.com>
parents:
diff changeset
70 static Timer timer = new Timer();
prymula <prymula76@outlook.com>
parents:
diff changeset
71
prymula <prymula76@outlook.com>
parents:
diff changeset
72 //static Actions actions;
prymula <prymula76@outlook.com>
parents:
diff changeset
73 //static Mata mata;
prymula <prymula76@outlook.com>
parents:
diff changeset
74
prymula <prymula76@outlook.com>
parents:
diff changeset
75 private Graphics bg;
prymula <prymula76@outlook.com>
parents:
diff changeset
76 private Image bufor;
prymula <prymula76@outlook.com>
parents:
diff changeset
77 static private int x;
prymula <prymula76@outlook.com>
parents:
diff changeset
78 static private int y;
prymula <prymula76@outlook.com>
parents:
diff changeset
79 //private Mata mata;
prymula <prymula76@outlook.com>
parents:
diff changeset
80
prymula <prymula76@outlook.com>
parents:
diff changeset
81 //private Puste puste;
prymula <prymula76@outlook.com>
parents:
diff changeset
82 //static boolean zaczynamy;
prymula <prymula76@outlook.com>
parents:
diff changeset
83 static int nmove;
prymula <prymula76@outlook.com>
parents:
diff changeset
84 BufferedImage imageNow;
prymula <prymula76@outlook.com>
parents:
diff changeset
85 static Mouse mouse;
prymula <prymula76@outlook.com>
parents:
diff changeset
86 static MouseMotion mouseMotion;
prymula <prymula76@outlook.com>
parents:
diff changeset
87 //Image img;
prymula <prymula76@outlook.com>
parents:
diff changeset
88 //Image cell[]=new Image[6*4];
prymula <prymula76@outlook.com>
parents:
diff changeset
89 static CellPicture origPicture[][] = new CellPicture[6][4];
prymula <prymula76@outlook.com>
parents:
diff changeset
90 static CellPicture cellPicture[][] = new CellPicture[6][4];
prymula <prymula76@outlook.com>
parents:
diff changeset
91 static CellPicture wallPaper[][] = new CellPicture[6][4];
prymula <prymula76@outlook.com>
parents:
diff changeset
92 //static CellWallPaper wallPaper[][] = new CellWallPaper[6][4];
prymula <prymula76@outlook.com>
parents:
diff changeset
93 static CellPicture dragAndDrop;
prymula <prymula76@outlook.com>
parents:
diff changeset
94 BufferedImage wallPaperImage=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
95 BufferedImage borderImage=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
96 BufferedImage startScreen=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
97 boolean startscreen=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
98 static boolean go=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
99 static int getBorderX;
prymula <prymula76@outlook.com>
parents:
diff changeset
100 static int getBorderY;
prymula <prymula76@outlook.com>
parents:
diff changeset
101
prymula <prymula76@outlook.com>
parents:
diff changeset
102 static int iw,ih,tw,th;
prymula <prymula76@outlook.com>
parents:
diff changeset
103 static int move;
prymula <prymula76@outlook.com>
parents:
diff changeset
104
prymula <prymula76@outlook.com>
parents:
diff changeset
105
prymula <prymula76@outlook.com>
parents:
diff changeset
106 public Trefle (){
prymula <prymula76@outlook.com>
parents:
diff changeset
107
prymula <prymula76@outlook.com>
parents:
diff changeset
108 menuBar = new JMenuBar();
prymula <prymula76@outlook.com>
parents:
diff changeset
109 menu = new JMenu("Plik");
prymula <prymula76@outlook.com>
parents:
diff changeset
110 menuBar.add(menu);
prymula <prymula76@outlook.com>
parents:
diff changeset
111 //menu2 = new JMenu("Options");
prymula <prymula76@outlook.com>
parents:
diff changeset
112 //menuBar.add(menu2);
prymula <prymula76@outlook.com>
parents:
diff changeset
113 // przenosi INFO na prawa strone
prymula <prymula76@outlook.com>
parents:
diff changeset
114 menuBar.add(Box.createHorizontalGlue());
prymula <prymula76@outlook.com>
parents:
diff changeset
115 info = new JMenu("Info");
prymula <prymula76@outlook.com>
parents:
diff changeset
116 // kierunek wyswietlania menu
prymula <prymula76@outlook.com>
parents:
diff changeset
117 info.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
prymula <prymula76@outlook.com>
parents:
diff changeset
118 menuBar.add(info);
prymula <prymula76@outlook.com>
parents:
diff changeset
119
prymula <prymula76@outlook.com>
parents:
diff changeset
120 nowplay = new JMenu("Nowa Gra");
prymula <prymula76@outlook.com>
parents:
diff changeset
121 nowplay.setToolTipText("Rozpoczyna nowa gre.");
prymula <prymula76@outlook.com>
parents:
diff changeset
122 menu.add(nowplay);
prymula <prymula76@outlook.com>
parents:
diff changeset
123
prymula <prymula76@outlook.com>
parents:
diff changeset
124 menuItem = new JMenuItem("Anielica", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
125 menuItem.setActionCommand("NewGame1");
prymula <prymula76@outlook.com>
parents:
diff changeset
126 menuItem.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
127 menuItem.setToolTipText("Piekna Anielica");
prymula <prymula76@outlook.com>
parents:
diff changeset
128
prymula <prymula76@outlook.com>
parents:
diff changeset
129 nowplay.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
130
prymula <prymula76@outlook.com>
parents:
diff changeset
131 menuItem = new JMenuItem("Zielony", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
132 menuItem.setActionCommand("NewGame2");
prymula <prymula76@outlook.com>
parents:
diff changeset
133 menuItem.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
134 menuItem.setToolTipText("Zielony Archaniol");
prymula <prymula76@outlook.com>
parents:
diff changeset
135
prymula <prymula76@outlook.com>
parents:
diff changeset
136 nowplay.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
137
prymula <prymula76@outlook.com>
parents:
diff changeset
138 menuItem = new JMenuItem("Niebieski", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
139 menuItem.setActionCommand("NewGame3");
prymula <prymula76@outlook.com>
parents:
diff changeset
140 menuItem.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
141 menuItem.setToolTipText("Niebieski Archaniol");
prymula <prymula76@outlook.com>
parents:
diff changeset
142
prymula <prymula76@outlook.com>
parents:
diff changeset
143 nowplay.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
144
prymula <prymula76@outlook.com>
parents:
diff changeset
145 menuItem = new JMenuItem("Na Linie", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
146 menuItem.setActionCommand("NewGame4");
prymula <prymula76@outlook.com>
parents:
diff changeset
147 menuItem.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
148 menuItem.setToolTipText("Aniol na linie");
prymula <prymula76@outlook.com>
parents:
diff changeset
149
prymula <prymula76@outlook.com>
parents:
diff changeset
150 nowplay.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
151
prymula <prymula76@outlook.com>
parents:
diff changeset
152 //menuItem = new JMenuItem("Pojedynczy", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
153 //menuItem.setActionCommand("NewGame0");
prymula <prymula76@outlook.com>
parents:
diff changeset
154 //menuItem.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
155 //menuItem.setToolTipText("Wlasciwie nic nie miesza");
prymula <prymula76@outlook.com>
parents:
diff changeset
156
prymula <prymula76@outlook.com>
parents:
diff changeset
157 //nowplay.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
158
prymula <prymula76@outlook.com>
parents:
diff changeset
159 //to nie
prymula <prymula76@outlook.com>
parents:
diff changeset
160 //menu.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
161
prymula <prymula76@outlook.com>
parents:
diff changeset
162 menu.addSeparator();
prymula <prymula76@outlook.com>
parents:
diff changeset
163 menuExit = new JMenuItem("Wyjscie", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
164 menuExit.setActionCommand("EndGame");
prymula <prymula76@outlook.com>
parents:
diff changeset
165 menuExit.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
166 menuExit.setToolTipText("Wyjscie z programu");
prymula <prymula76@outlook.com>
parents:
diff changeset
167 menu.add(menuExit);
prymula <prymula76@outlook.com>
parents:
diff changeset
168
prymula <prymula76@outlook.com>
parents:
diff changeset
169 menuInfo = new JMenuItem("Pomoc", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
170 menuInfo.setActionCommand("Help");
prymula <prymula76@outlook.com>
parents:
diff changeset
171 menuInfo.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
172 menuInfo.setToolTipText("HOWTO");
prymula <prymula76@outlook.com>
parents:
diff changeset
173 info.add(menuInfo);
prymula <prymula76@outlook.com>
parents:
diff changeset
174 menuInfo = new JMenuItem("O Programie", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
175 menuInfo.setActionCommand("About");
prymula <prymula76@outlook.com>
parents:
diff changeset
176 menuInfo.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
177 menuInfo.setToolTipText("Informacje o programie");
prymula <prymula76@outlook.com>
parents:
diff changeset
178 info.add(menuInfo);
prymula <prymula76@outlook.com>
parents:
diff changeset
179
prymula <prymula76@outlook.com>
parents:
diff changeset
180 LoadWallPaper();
prymula <prymula76@outlook.com>
parents:
diff changeset
181 LoadBorder();
prymula <prymula76@outlook.com>
parents:
diff changeset
182 LoadStartScreen();
prymula <prymula76@outlook.com>
parents:
diff changeset
183
prymula <prymula76@outlook.com>
parents:
diff changeset
184 }
prymula <prymula76@outlook.com>
parents:
diff changeset
185 public void actionPerformed(final ActionEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
186
prymula <prymula76@outlook.com>
parents:
diff changeset
187 // Nowa gra
prymula <prymula76@outlook.com>
parents:
diff changeset
188 if(e.getActionCommand().equals("NewGame1")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
189
prymula <prymula76@outlook.com>
parents:
diff changeset
190 imageNow = LoadPicture("/aniol.JPG");
prymula <prymula76@outlook.com>
parents:
diff changeset
191 CropImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
192 MixImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
193 ZerosWallPaper();
prymula <prymula76@outlook.com>
parents:
diff changeset
194 dragAndDrop =null; //= new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null
prymula <prymula76@outlook.com>
parents:
diff changeset
195 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
196 startscreen=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
197 this.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
198 //nmove=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
199
prymula <prymula76@outlook.com>
parents:
diff changeset
200 move=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
201 //mata.setMixedFields(0);
prymula <prymula76@outlook.com>
parents:
diff changeset
202 System.out.println("ZACZNAMY");
prymula <prymula76@outlook.com>
parents:
diff changeset
203 //screen.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
204 //nPuzzle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
205 }
prymula <prymula76@outlook.com>
parents:
diff changeset
206 else if(e.getActionCommand().equals("NewGame2")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
207
prymula <prymula76@outlook.com>
parents:
diff changeset
208 imageNow = LoadPicture("/zielony_archaniol.jpg");
prymula <prymula76@outlook.com>
parents:
diff changeset
209 CropImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
210 MixImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
211 ZerosWallPaper();
prymula <prymula76@outlook.com>
parents:
diff changeset
212 dragAndDrop = null; //new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null
prymula <prymula76@outlook.com>
parents:
diff changeset
213 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
214 startscreen=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
215 this.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
216 move=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
217 System.out.println("ZACZNAMY");
prymula <prymula76@outlook.com>
parents:
diff changeset
218 //screen.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
219 //nPuzzle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
220 }
prymula <prymula76@outlook.com>
parents:
diff changeset
221 else if(e.getActionCommand().equals("NewGame3")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
222
prymula <prymula76@outlook.com>
parents:
diff changeset
223 imageNow = LoadPicture("/niebieski_archaniol.jpg");
prymula <prymula76@outlook.com>
parents:
diff changeset
224 CropImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
225 MixImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
226 ZerosWallPaper();
prymula <prymula76@outlook.com>
parents:
diff changeset
227 dragAndDrop = null; //new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null
prymula <prymula76@outlook.com>
parents:
diff changeset
228 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
229 startscreen=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
230 this.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
231 move=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
232 System.out.println("ZACZNAMY");
prymula <prymula76@outlook.com>
parents:
diff changeset
233 //screen.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
234 //nPuzzle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
235 }
prymula <prymula76@outlook.com>
parents:
diff changeset
236 else if(e.getActionCommand().equals("NewGame4")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
237
prymula <prymula76@outlook.com>
parents:
diff changeset
238 imageNow = LoadPicture("/nalinie.jpg");
prymula <prymula76@outlook.com>
parents:
diff changeset
239 CropImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
240 MixImage();
prymula <prymula76@outlook.com>
parents:
diff changeset
241 ZerosWallPaper();
prymula <prymula76@outlook.com>
parents:
diff changeset
242 dragAndDrop = null; //new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null
prymula <prymula76@outlook.com>
parents:
diff changeset
243 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
244 startscreen=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
245 this.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
246 move=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
247 System.out.println("ZACZNAMY");
prymula <prymula76@outlook.com>
parents:
diff changeset
248 //screen.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
249 //nPuzzle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
250 }
prymula <prymula76@outlook.com>
parents:
diff changeset
251 // Zakonczenie
prymula <prymula76@outlook.com>
parents:
diff changeset
252 else if(e.getActionCommand().equals("EndGame")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
253 System.exit(0);
prymula <prymula76@outlook.com>
parents:
diff changeset
254 }
prymula <prymula76@outlook.com>
parents:
diff changeset
255 else if(e.getActionCommand().equals("About")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
256 String
prymula <prymula76@outlook.com>
parents:
diff changeset
257 s2=" Program napisany na podstawie fragmentow kodow,\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
258 s3=" wyszukanych w wyszukiwarce Google,\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
259 s4=" plus wlasna inwencja\n\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
260 s5=" Przemyslaw R. Pietraszczyk - styczen 2021\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
261 s6=" Licencja: GPL\n\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
262 s7=" Stworzono w oparciu o OpenJDK 11 oraz ANT\n\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
263 s8=" o/s: "+System.getProperty("os.name")+" ver: "+System.getProperty("os.version")+"\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
264 s9=" java ver: "+System.getProperty("java.vm.version")+"\n";
prymula <prymula76@outlook.com>
parents:
diff changeset
265
prymula <prymula76@outlook.com>
parents:
diff changeset
266 JOptionPane.showMessageDialog(frame,
prymula <prymula76@outlook.com>
parents:
diff changeset
267 s2+s3+s4+s5+s6+s7+s8+s9,
prymula <prymula76@outlook.com>
parents:
diff changeset
268 "Anielskie Puzzle - 0.2-1",
prymula <prymula76@outlook.com>
parents:
diff changeset
269 JOptionPane.PLAIN_MESSAGE);
prymula <prymula76@outlook.com>
parents:
diff changeset
270
prymula <prymula76@outlook.com>
parents:
diff changeset
271 }
prymula <prymula76@outlook.com>
parents:
diff changeset
272 else if(e.getActionCommand().equals("Help")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
273 String s1="Ukladanka polegajaca na metodzie przeciagnij i upusc elementow z prawej strony na lewa.\n Dokladniej mowiac nalezy kliknac i przytrzymac lewy klawisz myszki na elemencie\n z prawej strony a nastepnie nie puszczajac przycisku,\n przesunac obrazek nad lewa kratownice, umieszczajac element w wybranym punkcie,\n poprzez puszczenie lewego przycisku myszki.\n Po prawidlowym ulozeniu wszystkich obrazkow w jeden duzy obraz,\n aplikacja wyswietli okienko z iloscia wykonanych posuniec.\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
274 s2="Dozwolone jest rowniez przenoszenie elementow z lewej na prawa strone,\n jak i w zasiegu jednej kratownicy.",
prymula <prymula76@outlook.com>
parents:
diff changeset
275 s3="\n";
prymula <prymula76@outlook.com>
parents:
diff changeset
276 JOptionPane.showMessageDialog(frame,
prymula <prymula76@outlook.com>
parents:
diff changeset
277 s1+s2+s3,
prymula <prymula76@outlook.com>
parents:
diff changeset
278 "Pomoc",
prymula <prymula76@outlook.com>
parents:
diff changeset
279 JOptionPane.PLAIN_MESSAGE);
prymula <prymula76@outlook.com>
parents:
diff changeset
280 }
prymula <prymula76@outlook.com>
parents:
diff changeset
281 }
prymula <prymula76@outlook.com>
parents:
diff changeset
282 private static void createAndShowGUI() {
prymula <prymula76@outlook.com>
parents:
diff changeset
283
prymula <prymula76@outlook.com>
parents:
diff changeset
284 frame=new JFrame("Anielskie Puzzle");
prymula <prymula76@outlook.com>
parents:
diff changeset
285 //mata = new Mata();
prymula <prymula76@outlook.com>
parents:
diff changeset
286 //mata.setUnmixedFields();
prymula <prymula76@outlook.com>
parents:
diff changeset
287 // menuBar z konstruktora
prymula <prymula76@outlook.com>
parents:
diff changeset
288 final int frameWidth = 1200; //1300;
prymula <prymula76@outlook.com>
parents:
diff changeset
289 final int frameHeight = 680;
prymula <prymula76@outlook.com>
parents:
diff changeset
290 final int GNOMEPANEL=80; // nieco nizej niz panel
prymula <prymula76@outlook.com>
parents:
diff changeset
291 final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
prymula <prymula76@outlook.com>
parents:
diff changeset
292 //frame.setBounds((int) screenSize.getWidth() - frameWidth,
prymula <prymula76@outlook.com>
parents:
diff changeset
293 // (int) screenSize.getHeight() - frameHeight, frameWidth, frameHeight);
prymula <prymula76@outlook.com>
parents:
diff changeset
294 frame.setBounds((int) screenSize.getWidth() - frameWidth,
prymula <prymula76@outlook.com>
parents:
diff changeset
295 GNOMEPANEL, frameWidth, frameHeight);
prymula <prymula76@outlook.com>
parents:
diff changeset
296 frame.setResizable(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
297 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
prymula <prymula76@outlook.com>
parents:
diff changeset
298
prymula <prymula76@outlook.com>
parents:
diff changeset
299 trefle= new Trefle();
prymula <prymula76@outlook.com>
parents:
diff changeset
300 //screen = new PuzzleCanvas(true, mata);
prymula <prymula76@outlook.com>
parents:
diff changeset
301 frame.add(trefle);
prymula <prymula76@outlook.com>
parents:
diff changeset
302 //trefle.setPreferredSize(new Dimension(1200, 640));
prymula <prymula76@outlook.com>
parents:
diff changeset
303 trefle.setBounds(5,5, 1170,640); // 1200, 640
prymula <prymula76@outlook.com>
parents:
diff changeset
304 //frame.add(screen);
prymula <prymula76@outlook.com>
parents:
diff changeset
305 //nPuzzle.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
306 frame.add(menuBar);
prymula <prymula76@outlook.com>
parents:
diff changeset
307
prymula <prymula76@outlook.com>
parents:
diff changeset
308 frame.setJMenuBar(menuBar);
prymula <prymula76@outlook.com>
parents:
diff changeset
309 frame.setLayout(null);
prymula <prymula76@outlook.com>
parents:
diff changeset
310 //frame.setSize(250,400); // 400 x 400
prymula <prymula76@outlook.com>
parents:
diff changeset
311 frame.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
312 mouse = new Mouse();
prymula <prymula76@outlook.com>
parents:
diff changeset
313 mouseMotion = new MouseMotion();
prymula <prymula76@outlook.com>
parents:
diff changeset
314 mouse.setCanvas(trefle);
prymula <prymula76@outlook.com>
parents:
diff changeset
315 frame.addMouseListener(mouse);
prymula <prymula76@outlook.com>
parents:
diff changeset
316 frame.addMouseMotionListener(mouseMotion);
prymula <prymula76@outlook.com>
parents:
diff changeset
317 //addMouseListener(mouse);
prymula <prymula76@outlook.com>
parents:
diff changeset
318 //frame.addKeyListener(actions);
prymula <prymula76@outlook.com>
parents:
diff changeset
319 frame.setFocusable(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
320
prymula <prymula76@outlook.com>
parents:
diff changeset
321 // zapobiega utracie KeyEvent po wyjsciu z SoundDialog i ResetDialog
prymula <prymula76@outlook.com>
parents:
diff changeset
322 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
323 frame.addFocusListener(new FocusListener(){
prymula <prymula76@outlook.com>
parents:
diff changeset
324 public void focusGained(FocusEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
325 //System.out.println("Focus GAINED:"+e);
prymula <prymula76@outlook.com>
parents:
diff changeset
326 }
prymula <prymula76@outlook.com>
parents:
diff changeset
327 public void focusLost(FocusEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
328 //System.out.println("Focus LOST:"+e);
prymula <prymula76@outlook.com>
parents:
diff changeset
329
prymula <prymula76@outlook.com>
parents:
diff changeset
330 // FIX FOR GNOME/XWIN FOCUS BUG
prymula <prymula76@outlook.com>
parents:
diff changeset
331 e.getComponent().requestFocus();
prymula <prymula76@outlook.com>
parents:
diff changeset
332 }
prymula <prymula76@outlook.com>
parents:
diff changeset
333 });
prymula <prymula76@outlook.com>
parents:
diff changeset
334 */
prymula <prymula76@outlook.com>
parents:
diff changeset
335 //dragAndDrop = new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null
prymula <prymula76@outlook.com>
parents:
diff changeset
336 timer.schedule(new KeyTicks(), 0, 1000); // lepiej 1000
prymula <prymula76@outlook.com>
parents:
diff changeset
337 //zaczynamy=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
338 }
prymula <prymula76@outlook.com>
parents:
diff changeset
339 protected void paintComponent(Graphics g){
prymula <prymula76@outlook.com>
parents:
diff changeset
340 super.paintComponent(g);
prymula <prymula76@outlook.com>
parents:
diff changeset
341
prymula <prymula76@outlook.com>
parents:
diff changeset
342 //int i, j;
prymula <prymula76@outlook.com>
parents:
diff changeset
343 int fontSize = 60;
prymula <prymula76@outlook.com>
parents:
diff changeset
344
prymula <prymula76@outlook.com>
parents:
diff changeset
345 //y=60;
prymula <prymula76@outlook.com>
parents:
diff changeset
346
prymula <prymula76@outlook.com>
parents:
diff changeset
347 //System.out.println("MATA: "+mata);
prymula <prymula76@outlook.com>
parents:
diff changeset
348 //if (mata != null) {
prymula <prymula76@outlook.com>
parents:
diff changeset
349
prymula <prymula76@outlook.com>
parents:
diff changeset
350 g.setFont(new Font("Serif", Font.PLAIN, fontSize));
prymula <prymula76@outlook.com>
parents:
diff changeset
351 //g.setForeground(Color.BLACK);
prymula <prymula76@outlook.com>
parents:
diff changeset
352 g.setColor(Color.BLACK);
prymula <prymula76@outlook.com>
parents:
diff changeset
353 //g.drawImage(imageNow, 0,0,this);
prymula <prymula76@outlook.com>
parents:
diff changeset
354 if (startscreen){
prymula <prymula76@outlook.com>
parents:
diff changeset
355 g.drawImage(startScreen, 130+getInsets().left, 40+getInsets().top, null); // 160 + getInsets().left
prymula <prymula76@outlook.com>
parents:
diff changeset
356 }
prymula <prymula76@outlook.com>
parents:
diff changeset
357 if (go){
prymula <prymula76@outlook.com>
parents:
diff changeset
358 for (int y=0;y<6;y++){
prymula <prymula76@outlook.com>
parents:
diff changeset
359 for (int x=0; x<4;x++){
prymula <prymula76@outlook.com>
parents:
diff changeset
360 //int i = y*4+x;
prymula <prymula76@outlook.com>
parents:
diff changeset
361 // jesli na tapecie nie ma obrazka wyswietla szachownice
prymula <prymula76@outlook.com>
parents:
diff changeset
362 if (wallPaper[y][x] == null)
prymula <prymula76@outlook.com>
parents:
diff changeset
363 g.drawImage(wallPaperImage, x*wallPaperImage.getWidth(null)+getInsets().left, y*wallPaperImage.getHeight(null)+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
364 else
prymula <prymula76@outlook.com>
parents:
diff changeset
365 g.drawImage(wallPaper[y][x].image, x*wallPaper[y][x].w+getInsets().left, y*wallPaper[y][x].h+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
366 // wallPaper[y][x]=new CellWallPaper(wallPaperImage.getWidth(null)*x, wallPaperImage.getHeight(null)*y,wallPaperImage.getWidth(null), wallPaperImage.getHeight(null), wallPaperImage, i);
prymula <prymula76@outlook.com>
parents:
diff changeset
367
prymula <prymula76@outlook.com>
parents:
diff changeset
368 }
prymula <prymula76@outlook.com>
parents:
diff changeset
369 }
prymula <prymula76@outlook.com>
parents:
diff changeset
370
prymula <prymula76@outlook.com>
parents:
diff changeset
371
prymula <prymula76@outlook.com>
parents:
diff changeset
372 //if (go){
prymula <prymula76@outlook.com>
parents:
diff changeset
373 for (int y=0;y<6;y++){
prymula <prymula76@outlook.com>
parents:
diff changeset
374 for (int x=0; x<4;x++){
prymula <prymula76@outlook.com>
parents:
diff changeset
375 int i = y*4+x;
prymula <prymula76@outlook.com>
parents:
diff changeset
376 // g.drawImage(cell[y*4+x], 650+x*tw+getInsets().left, y*th+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
377 if(cellPicture[y][x]==null){
prymula <prymula76@outlook.com>
parents:
diff changeset
378 g.drawImage(wallPaperImage, 496+124+x*wallPaperImage.getWidth(null)+getInsets().left, y*wallPaperImage.getHeight(null)+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
379 System.out.println("ADRESS: "+cellPicture[y][x]);
prymula <prymula76@outlook.com>
parents:
diff changeset
380 } else
prymula <prymula76@outlook.com>
parents:
diff changeset
381 g.drawImage(cellPicture[y][x].image, 496+124+x*cellPicture[y][x].w+getInsets().left, y*cellPicture[y][x].h+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
382 //} else
prymula <prymula76@outlook.com>
parents:
diff changeset
383 // g.drawImage(wallPaper[y][x].image, 496+124+x*wallPaper[y][x].w+getInsets().left, y*wallPaper[y][x].h+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
384
prymula <prymula76@outlook.com>
parents:
diff changeset
385 }
prymula <prymula76@outlook.com>
parents:
diff changeset
386 }
prymula <prymula76@outlook.com>
parents:
diff changeset
387 if (dragAndDrop != null){
prymula <prymula76@outlook.com>
parents:
diff changeset
388 if (dragAndDrop.image != null){
prymula <prymula76@outlook.com>
parents:
diff changeset
389 System.out.println("JUZ JESTEM!");
prymula <prymula76@outlook.com>
parents:
diff changeset
390 System.out.println("X: "+dragAndDrop.x);
prymula <prymula76@outlook.com>
parents:
diff changeset
391 System.out.println("Y: "+dragAndDrop.y);
prymula <prymula76@outlook.com>
parents:
diff changeset
392
prymula <prymula76@outlook.com>
parents:
diff changeset
393 g.drawImage(dragAndDrop.image, dragAndDrop.x, dragAndDrop.y, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
394
prymula <prymula76@outlook.com>
parents:
diff changeset
395 }
prymula <prymula76@outlook.com>
parents:
diff changeset
396 }
prymula <prymula76@outlook.com>
parents:
diff changeset
397 if (getBorderX !=0 | getBorderY != 0){
prymula <prymula76@outlook.com>
parents:
diff changeset
398 //System.out.println("RRYSUJE BORDER");
prymula <prymula76@outlook.com>
parents:
diff changeset
399 g.drawImage(borderImage, getBorderX*tw+getInsets().left, getBorderY*th+getInsets().top, null);
prymula <prymula76@outlook.com>
parents:
diff changeset
400
prymula <prymula76@outlook.com>
parents:
diff changeset
401
prymula <prymula76@outlook.com>
parents:
diff changeset
402 }
prymula <prymula76@outlook.com>
parents:
diff changeset
403 }
prymula <prymula76@outlook.com>
parents:
diff changeset
404
prymula <prymula76@outlook.com>
parents:
diff changeset
405 }
prymula <prymula76@outlook.com>
parents:
diff changeset
406 private void LoadBorder(){
prymula <prymula76@outlook.com>
parents:
diff changeset
407
prymula <prymula76@outlook.com>
parents:
diff changeset
408 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
409 borderImage = ImageIO.read(getClass().getResourceAsStream("/border.png")); // "/nazwa_pliku"
prymula <prymula76@outlook.com>
parents:
diff changeset
410 } catch (IOException ioe) {
prymula <prymula76@outlook.com>
parents:
diff changeset
411 ioe.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
412 }
prymula <prymula76@outlook.com>
parents:
diff changeset
413
prymula <prymula76@outlook.com>
parents:
diff changeset
414 }
prymula <prymula76@outlook.com>
parents:
diff changeset
415 private BufferedImage LoadPicture(String name){
prymula <prymula76@outlook.com>
parents:
diff changeset
416 BufferedImage image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
417
prymula <prymula76@outlook.com>
parents:
diff changeset
418 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
419 image = ImageIO.read(getClass().getResourceAsStream(name)); // "/nazwa_pliku"
prymula <prymula76@outlook.com>
parents:
diff changeset
420 } catch (IOException ioe) {
prymula <prymula76@outlook.com>
parents:
diff changeset
421 ioe.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
422 }
prymula <prymula76@outlook.com>
parents:
diff changeset
423 iw=image.getWidth(null);
prymula <prymula76@outlook.com>
parents:
diff changeset
424 ih=image.getHeight(null);
prymula <prymula76@outlook.com>
parents:
diff changeset
425 tw=iw/4;
prymula <prymula76@outlook.com>
parents:
diff changeset
426 th=ih/6;
prymula <prymula76@outlook.com>
parents:
diff changeset
427
prymula <prymula76@outlook.com>
parents:
diff changeset
428 return image;
prymula <prymula76@outlook.com>
parents:
diff changeset
429 }
prymula <prymula76@outlook.com>
parents:
diff changeset
430 private void LoadWallPaper() {
prymula <prymula76@outlook.com>
parents:
diff changeset
431
prymula <prymula76@outlook.com>
parents:
diff changeset
432 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
433 wallPaperImage = ImageIO.read(getClass().getResourceAsStream("/wallpaper.jpg")); // "/nazwa_pliku"
prymula <prymula76@outlook.com>
parents:
diff changeset
434 } catch (IOException ioe) {
prymula <prymula76@outlook.com>
parents:
diff changeset
435 ioe.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
436 }
prymula <prymula76@outlook.com>
parents:
diff changeset
437 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
438 for (int y=0;y<6;y++){
prymula <prymula76@outlook.com>
parents:
diff changeset
439 for (int x=0; x<4;x++){
prymula <prymula76@outlook.com>
parents:
diff changeset
440 int i = y*4+x;
prymula <prymula76@outlook.com>
parents:
diff changeset
441 wallPaper[y][x]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
442 // wallPaper[y][x]=new CellWallPaper(wallPaperImage.getWidth(null)*x, wallPaperImage.getHeight(null)*y,wallPaperImage.getWidth(null), wallPaperImage.getHeight(null), wallPaperImage, i);
prymula <prymula76@outlook.com>
parents:
diff changeset
443
prymula <prymula76@outlook.com>
parents:
diff changeset
444 }
prymula <prymula76@outlook.com>
parents:
diff changeset
445 }
prymula <prymula76@outlook.com>
parents:
diff changeset
446 */
prymula <prymula76@outlook.com>
parents:
diff changeset
447 }
prymula <prymula76@outlook.com>
parents:
diff changeset
448 private void LoadStartScreen() {
prymula <prymula76@outlook.com>
parents:
diff changeset
449
prymula <prymula76@outlook.com>
parents:
diff changeset
450 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
451 startScreen = ImageIO.read(getClass().getResourceAsStream("/start.jpg"));
prymula <prymula76@outlook.com>
parents:
diff changeset
452 } catch (IOException ioe) {
prymula <prymula76@outlook.com>
parents:
diff changeset
453 ioe.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
454 }
prymula <prymula76@outlook.com>
parents:
diff changeset
455 }
prymula <prymula76@outlook.com>
parents:
diff changeset
456
prymula <prymula76@outlook.com>
parents:
diff changeset
457 private void ZerosWallPaper() {
prymula <prymula76@outlook.com>
parents:
diff changeset
458 for (int y=0;y<6;y++){
prymula <prymula76@outlook.com>
parents:
diff changeset
459 for (int x=0; x<4;x++){
prymula <prymula76@outlook.com>
parents:
diff changeset
460 int i = y*4+x;
prymula <prymula76@outlook.com>
parents:
diff changeset
461 wallPaper[y][x]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
462 // wallPaper[y][x]=new CellWallPaper(wallPaperImage.getWidth(null)*x, wallPaperImage.getHeight(null)*y,wallPaperImage.getWidth(null), wallPaperImage.getHeight(null), wallPaperImage, i);
prymula <prymula76@outlook.com>
parents:
diff changeset
463
prymula <prymula76@outlook.com>
parents:
diff changeset
464 }
prymula <prymula76@outlook.com>
parents:
diff changeset
465 }
prymula <prymula76@outlook.com>
parents:
diff changeset
466
prymula <prymula76@outlook.com>
parents:
diff changeset
467 }
prymula <prymula76@outlook.com>
parents:
diff changeset
468
prymula <prymula76@outlook.com>
parents:
diff changeset
469 private void CropImage (){
prymula <prymula76@outlook.com>
parents:
diff changeset
470
prymula <prymula76@outlook.com>
parents:
diff changeset
471 CropImageFilter f;
prymula <prymula76@outlook.com>
parents:
diff changeset
472 FilteredImageSource fis;
prymula <prymula76@outlook.com>
parents:
diff changeset
473
prymula <prymula76@outlook.com>
parents:
diff changeset
474 for (int y=0;y<6;y++){
prymula <prymula76@outlook.com>
parents:
diff changeset
475 for (int x=0; x<4;x++){
prymula <prymula76@outlook.com>
parents:
diff changeset
476 f=new CropImageFilter(tw*x, th*y, tw,th);
prymula <prymula76@outlook.com>
parents:
diff changeset
477 fis=new FilteredImageSource(imageNow.getSource(), f);
prymula <prymula76@outlook.com>
parents:
diff changeset
478 int i = y*4+x;
prymula <prymula76@outlook.com>
parents:
diff changeset
479 //cell[i]=createImage(fis);
prymula <prymula76@outlook.com>
parents:
diff changeset
480 cellPicture[y][x]=new CellPicture(tw*x, th*y, tw, th, createImage(fis), i);
prymula <prymula76@outlook.com>
parents:
diff changeset
481 origPicture[y][x]=new CellPicture(tw*x, th*y, tw, th, createImage(fis), i);
prymula <prymula76@outlook.com>
parents:
diff changeset
482
prymula <prymula76@outlook.com>
parents:
diff changeset
483 mouse.set(tw,th);
prymula <prymula76@outlook.com>
parents:
diff changeset
484 }
prymula <prymula76@outlook.com>
parents:
diff changeset
485 }
prymula <prymula76@outlook.com>
parents:
diff changeset
486 }
prymula <prymula76@outlook.com>
parents:
diff changeset
487 private void MixImage(){
prymula <prymula76@outlook.com>
parents:
diff changeset
488
prymula <prymula76@outlook.com>
parents:
diff changeset
489 for (int i=0; i<48; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
490 //int si = (int) (Math.random()*24);
prymula <prymula76@outlook.com>
parents:
diff changeset
491 int sy = (int) (Math.random()*6);
prymula <prymula76@outlook.com>
parents:
diff changeset
492 int sx = (int) (Math.random()*4);
prymula <prymula76@outlook.com>
parents:
diff changeset
493
prymula <prymula76@outlook.com>
parents:
diff changeset
494 //int di = (int) (Math.random()*24);
prymula <prymula76@outlook.com>
parents:
diff changeset
495 int dy = (int) (Math.random()*6);
prymula <prymula76@outlook.com>
parents:
diff changeset
496 int dx = (int) (Math.random()*4);
prymula <prymula76@outlook.com>
parents:
diff changeset
497
prymula <prymula76@outlook.com>
parents:
diff changeset
498 //Image tmp = cell[si];
prymula <prymula76@outlook.com>
parents:
diff changeset
499 //cell[si]=cell[di];
prymula <prymula76@outlook.com>
parents:
diff changeset
500 //cell[di]=tmp;
prymula <prymula76@outlook.com>
parents:
diff changeset
501
prymula <prymula76@outlook.com>
parents:
diff changeset
502 CellPicture tmp_c = cellPicture[sy][sx];
prymula <prymula76@outlook.com>
parents:
diff changeset
503 cellPicture[sy][sx]=cellPicture[dy][dx];
prymula <prymula76@outlook.com>
parents:
diff changeset
504 cellPicture[dy][dx]=tmp_c;
prymula <prymula76@outlook.com>
parents:
diff changeset
505
prymula <prymula76@outlook.com>
parents:
diff changeset
506 //tmp_c = origPicture[sy][sx];
prymula <prymula76@outlook.com>
parents:
diff changeset
507 //origPicture[sy][sx]=origPicture[dy][dx];
prymula <prymula76@outlook.com>
parents:
diff changeset
508 //origPicture[dy][dx]=tmp_c;
prymula <prymula76@outlook.com>
parents:
diff changeset
509
prymula <prymula76@outlook.com>
parents:
diff changeset
510 }
prymula <prymula76@outlook.com>
parents:
diff changeset
511 }
prymula <prymula76@outlook.com>
parents:
diff changeset
512
prymula <prymula76@outlook.com>
parents:
diff changeset
513
prymula <prymula76@outlook.com>
parents:
diff changeset
514 public static void main(final String[] args) {
prymula <prymula76@outlook.com>
parents:
diff changeset
515
prymula <prymula76@outlook.com>
parents:
diff changeset
516 javax.swing.SwingUtilities.invokeLater(new RunnableImplementation());
prymula <prymula76@outlook.com>
parents:
diff changeset
517 }
prymula <prymula76@outlook.com>
parents:
diff changeset
518 private static final class RunnableImplementation implements Runnable {
prymula <prymula76@outlook.com>
parents:
diff changeset
519 public void run(){
prymula <prymula76@outlook.com>
parents:
diff changeset
520 createAndShowGUI();
prymula <prymula76@outlook.com>
parents:
diff changeset
521 }
prymula <prymula76@outlook.com>
parents:
diff changeset
522 }
prymula <prymula76@outlook.com>
parents:
diff changeset
523
prymula <prymula76@outlook.com>
parents:
diff changeset
524
prymula <prymula76@outlook.com>
parents:
diff changeset
525 static private class CellPicture {
prymula <prymula76@outlook.com>
parents:
diff changeset
526 public int x, y, w, h, n;
prymula <prymula76@outlook.com>
parents:
diff changeset
527 public Image image;
prymula <prymula76@outlook.com>
parents:
diff changeset
528 //public boolean view;
prymula <prymula76@outlook.com>
parents:
diff changeset
529 public CellPicture(int x, int y, int w, int h, Image img, int n){
prymula <prymula76@outlook.com>
parents:
diff changeset
530 this.x=x;
prymula <prymula76@outlook.com>
parents:
diff changeset
531 this.y=y;
prymula <prymula76@outlook.com>
parents:
diff changeset
532 this.w=w;
prymula <prymula76@outlook.com>
parents:
diff changeset
533 this.h=h;
prymula <prymula76@outlook.com>
parents:
diff changeset
534 this.n=n; // numer porzadkowy
prymula <prymula76@outlook.com>
parents:
diff changeset
535 this.image=img; // biezacy obrazek
prymula <prymula76@outlook.com>
parents:
diff changeset
536 // this.view=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
537 }
prymula <prymula76@outlook.com>
parents:
diff changeset
538 public void set(int _x, int _y){
prymula <prymula76@outlook.com>
parents:
diff changeset
539 this.x=_x;
prymula <prymula76@outlook.com>
parents:
diff changeset
540 this.y=_y;
prymula <prymula76@outlook.com>
parents:
diff changeset
541 }
prymula <prymula76@outlook.com>
parents:
diff changeset
542
prymula <prymula76@outlook.com>
parents:
diff changeset
543 }
prymula <prymula76@outlook.com>
parents:
diff changeset
544 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
545 static private class CellWallPaper extends CellPicture {
prymula <prymula76@outlook.com>
parents:
diff changeset
546 public Image store; // kopia ukladanki
prymula <prymula76@outlook.com>
parents:
diff changeset
547
prymula <prymula76@outlook.com>
parents:
diff changeset
548 public CellWallPaper(int x, int y, int w, int h, Image img, int n){
prymula <prymula76@outlook.com>
parents:
diff changeset
549
prymula <prymula76@outlook.com>
parents:
diff changeset
550 super(x,y,w,h,img,n);
prymula <prymula76@outlook.com>
parents:
diff changeset
551 store = null;
prymula <prymula76@outlook.com>
parents:
diff changeset
552 }
prymula <prymula76@outlook.com>
parents:
diff changeset
553
prymula <prymula76@outlook.com>
parents:
diff changeset
554 }
prymula <prymula76@outlook.com>
parents:
diff changeset
555 */
prymula <prymula76@outlook.com>
parents:
diff changeset
556 static class KeyTicks extends TimerTask {
prymula <prymula76@outlook.com>
parents:
diff changeset
557 //int cellGetIndex, cellPutIndex; // indeksy z obszaru do obszaru
prymula <prymula76@outlook.com>
parents:
diff changeset
558 Coordinate cellGetCoor, cellPutCoor;
prymula <prymula76@outlook.com>
parents:
diff changeset
559 Coordinate dragGetCoor=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
560 //static CellPicture dragAndDrop;
prymula <prymula76@outlook.com>
parents:
diff changeset
561 boolean redraw = false;
prymula <prymula76@outlook.com>
parents:
diff changeset
562 int tmpx=0, tmpy=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
563 boolean fromLeft=false, fromRight=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
564 //int arr[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
prymula <prymula76@outlook.com>
parents:
diff changeset
565
prymula <prymula76@outlook.com>
parents:
diff changeset
566 public void run() {
prymula <prymula76@outlook.com>
parents:
diff changeset
567
prymula <prymula76@outlook.com>
parents:
diff changeset
568 if (go){
prymula <prymula76@outlook.com>
parents:
diff changeset
569 cellGetCoor=mouse.getCell();
prymula <prymula76@outlook.com>
parents:
diff changeset
570 cellPutCoor=mouse.putCell();
prymula <prymula76@outlook.com>
parents:
diff changeset
571 int gety=getBorderY=(cellGetCoor.y-(th/2))/th; // plus korekta y od belki (th/2)
prymula <prymula76@outlook.com>
parents:
diff changeset
572 int getx=getBorderX=cellGetCoor.x/tw;
prymula <prymula76@outlook.com>
parents:
diff changeset
573 int test = cellGetCoor.x/tw-5;
prymula <prymula76@outlook.com>
parents:
diff changeset
574 int puty=(cellPutCoor.y-(th/2))/th;
prymula <prymula76@outlook.com>
parents:
diff changeset
575 int putx=cellPutCoor.x/tw;
prymula <prymula76@outlook.com>
parents:
diff changeset
576 //int tmpx=0,tmpy=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
577 //System.out.println("KLIKNIETO NA x:"+((cellGetCoor.x/tw))+" y:"+(cellGetCoor.y/th)-20));
prymula <prymula76@outlook.com>
parents:
diff changeset
578 //System.out.println("KLIKNIETO NA x:"+(cellGetCoor.x/tw)+" y:"+gety+" test:"+test);
prymula <prymula76@outlook.com>
parents:
diff changeset
579 //trefle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
580 System.out.println("cellPutCoor.y: "+cellPutCoor.y+" cellPutCoor.x: "+cellPutCoor.x);
prymula <prymula76@outlook.com>
parents:
diff changeset
581 System.out.println("PATYK");
prymula <prymula76@outlook.com>
parents:
diff changeset
582 if (cellGetCoor.click && !redraw && cellGetCoor.y-(th/2)>44 && cellGetCoor.y<645 && cellGetCoor.x<1122){
prymula <prymula76@outlook.com>
parents:
diff changeset
583 System.out.println("przerysowuje -1 x:"+cellGetCoor.x+" y:"+cellGetCoor.y);
prymula <prymula76@outlook.com>
parents:
diff changeset
584
prymula <prymula76@outlook.com>
parents:
diff changeset
585 redraw=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
586 //System.out.println("cellGetCoor:"+cellGetCoor+" gety:"+gety+" getx:"+getx+" wallPaper:"+wallPaper[gety][getx]);
prymula <prymula76@outlook.com>
parents:
diff changeset
587 // drag z lewej strony
prymula <prymula76@outlook.com>
parents:
diff changeset
588 if (getx<4 && cellGetCoor.x/tw<4 && cellGetCoor.y-(th/2)/th>=0 && wallPaper[gety][getx]!=null && wallPaper[gety][getx].image!=null){
prymula <prymula76@outlook.com>
parents:
diff changeset
589 //if (wallPaper[gety][getx]!=null)
prymula <prymula76@outlook.com>
parents:
diff changeset
590 dragAndDrop=new CellPicture(cellGetCoor.x, cellGetCoor.y, tw, th, wallPaper[gety][getx].image, wallPaper[gety][getx].n);
prymula <prymula76@outlook.com>
parents:
diff changeset
591 //else
prymula <prymula76@outlook.com>
parents:
diff changeset
592 // dragAndDrop=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
593 System.out.println("Jestem na lewo");
prymula <prymula76@outlook.com>
parents:
diff changeset
594 tmpx=cellGetCoor.x/tw;
prymula <prymula76@outlook.com>
parents:
diff changeset
595 tmpy=(cellGetCoor.y-(th/2))/th;
prymula <prymula76@outlook.com>
parents:
diff changeset
596 fromLeft=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
597 }
prymula <prymula76@outlook.com>
parents:
diff changeset
598 // drag z prawej strony
prymula <prymula76@outlook.com>
parents:
diff changeset
599 else if (cellGetCoor.x/tw>4 && cellGetCoor.y-(th/2)/th>=0 && cellPicture[gety][getx-5]!=null && cellPicture[gety][getx-5].image!=null){
prymula <prymula76@outlook.com>
parents:
diff changeset
600 // bylo z origPicture
prymula <prymula76@outlook.com>
parents:
diff changeset
601 //dragAndDrop=new CellPicture(cellGetCoor.x, cellGetCoor.y, tw, th, cellPicture[gety][getx-5].image, cellPicture[gety][getx-5].n);
prymula <prymula76@outlook.com>
parents:
diff changeset
602 dragAndDrop=new CellPicture(cellGetCoor.x, cellGetCoor.y, tw, th, cellPicture[gety][getx-5].image, cellPicture[gety][getx-5].n);
prymula <prymula76@outlook.com>
parents:
diff changeset
603 System.out.println("Jestem naprawo");
prymula <prymula76@outlook.com>
parents:
diff changeset
604 tmpx=cellGetCoor.x/tw-5;
prymula <prymula76@outlook.com>
parents:
diff changeset
605 tmpy=(cellGetCoor.y-(th/2))/th;
prymula <prymula76@outlook.com>
parents:
diff changeset
606 fromRight=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
607 }
prymula <prymula76@outlook.com>
parents:
diff changeset
608 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
609 System.out.println("Jestem ELSE");
prymula <prymula76@outlook.com>
parents:
diff changeset
610 redraw=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
611 //return;
prymula <prymula76@outlook.com>
parents:
diff changeset
612 }
prymula <prymula76@outlook.com>
parents:
diff changeset
613 //cellPicture[gety][getx-5].view=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
614
prymula <prymula76@outlook.com>
parents:
diff changeset
615 System.out.println("przerysowuje - 2 x:"+tmpx+" y:"+tmpy);
prymula <prymula76@outlook.com>
parents:
diff changeset
616
prymula <prymula76@outlook.com>
parents:
diff changeset
617
prymula <prymula76@outlook.com>
parents:
diff changeset
618 }
prymula <prymula76@outlook.com>
parents:
diff changeset
619 else if(!cellGetCoor.click && redraw) {
prymula <prymula76@outlook.com>
parents:
diff changeset
620 System.out.println("puszczono");
prymula <prymula76@outlook.com>
parents:
diff changeset
621 redraw=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
622 if (dragAndDrop.image!=null){
prymula <prymula76@outlook.com>
parents:
diff changeset
623 if(dragGetCoor.x/tw<4){
prymula <prymula76@outlook.com>
parents:
diff changeset
624 // drag z prawej na lewo
prymula <prymula76@outlook.com>
parents:
diff changeset
625 if (fromRight){
prymula <prymula76@outlook.com>
parents:
diff changeset
626 if (wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]==null) {
prymula <prymula76@outlook.com>
parents:
diff changeset
627 //wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]=new CellPicture(dragAndDrop.image.getWidth(null)*x, dragAndDrop.image.getHeight(null)*y,dragAndDrop.image.getWidth(null), dragAndDrop.image.getHeight(null), dragAndDrop.image, dragAndDrop.n);
prymula <prymula76@outlook.com>
parents:
diff changeset
628 wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n);
prymula <prymula76@outlook.com>
parents:
diff changeset
629 System.out.println("Dokuje na lewo");
prymula <prymula76@outlook.com>
parents:
diff changeset
630
prymula <prymula76@outlook.com>
parents:
diff changeset
631 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
632 //cellPicture[(cellGetCoor.y-(th/2)/th)][cellGetCoor.x/tw]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
633 System.out.println(" coor.y"+puty+" coor.x"+putx);
prymula <prymula76@outlook.com>
parents:
diff changeset
634 System.out.println(" tmpy"+tmpy+" tmpx"+tmpx);
prymula <prymula76@outlook.com>
parents:
diff changeset
635
prymula <prymula76@outlook.com>
parents:
diff changeset
636 //cellPicture[puty][putx]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
637 cellPicture[tmpy][tmpx]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
638 fromRight=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
639 }
prymula <prymula76@outlook.com>
parents:
diff changeset
640 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
641 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
642 }
prymula <prymula76@outlook.com>
parents:
diff changeset
643 move++;
prymula <prymula76@outlook.com>
parents:
diff changeset
644 }
prymula <prymula76@outlook.com>
parents:
diff changeset
645 // drag z lewej na lewo
prymula <prymula76@outlook.com>
parents:
diff changeset
646 else if (fromLeft){
prymula <prymula76@outlook.com>
parents:
diff changeset
647 if (wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]==null){
prymula <prymula76@outlook.com>
parents:
diff changeset
648 //System.out.println("CELL:"+dragAndDrop.image);
prymula <prymula76@outlook.com>
parents:
diff changeset
649
prymula <prymula76@outlook.com>
parents:
diff changeset
650 wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n);
prymula <prymula76@outlook.com>
parents:
diff changeset
651 System.out.println("Dokuje na lewo");
prymula <prymula76@outlook.com>
parents:
diff changeset
652
prymula <prymula76@outlook.com>
parents:
diff changeset
653 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
654 //cellPicture[(cellGetCoor.y-(th/2)/th)][cellGetCoor.x/tw]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
655 System.out.println(" coor.y"+puty+" coor.x"+putx);
prymula <prymula76@outlook.com>
parents:
diff changeset
656 System.out.println(" tmpy"+tmpy+" tmpx"+tmpx);
prymula <prymula76@outlook.com>
parents:
diff changeset
657
prymula <prymula76@outlook.com>
parents:
diff changeset
658 //cellPicture[puty][putx]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
659 wallPaper[tmpy][tmpx]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
660 fromLeft=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
661 }
prymula <prymula76@outlook.com>
parents:
diff changeset
662 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
663 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
664 }
prymula <prymula76@outlook.com>
parents:
diff changeset
665 move++;
prymula <prymula76@outlook.com>
parents:
diff changeset
666 }
prymula <prymula76@outlook.com>
parents:
diff changeset
667 }
prymula <prymula76@outlook.com>
parents:
diff changeset
668 // drag spowrotem na prawo z lewj
prymula <prymula76@outlook.com>
parents:
diff changeset
669 else if (dragGetCoor.x/tw>4){
prymula <prymula76@outlook.com>
parents:
diff changeset
670 if(fromLeft){
prymula <prymula76@outlook.com>
parents:
diff changeset
671 if (cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]==null){
prymula <prymula76@outlook.com>
parents:
diff changeset
672 System.out.println("Dokuje z lewa na prawo");
prymula <prymula76@outlook.com>
parents:
diff changeset
673 cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n);
prymula <prymula76@outlook.com>
parents:
diff changeset
674 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
675 wallPaper[tmpy][tmpx]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
676 fromLeft=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
677 }
prymula <prymula76@outlook.com>
parents:
diff changeset
678 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
679 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
680 }
prymula <prymula76@outlook.com>
parents:
diff changeset
681 }
prymula <prymula76@outlook.com>
parents:
diff changeset
682 else if(fromRight){
prymula <prymula76@outlook.com>
parents:
diff changeset
683 if (cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]==null){
prymula <prymula76@outlook.com>
parents:
diff changeset
684 System.out.println("Dokuje z prawa na prawo");
prymula <prymula76@outlook.com>
parents:
diff changeset
685 cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n);
prymula <prymula76@outlook.com>
parents:
diff changeset
686 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
687 cellPicture[tmpy][tmpx]=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
688 fromRight=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
689 }
prymula <prymula76@outlook.com>
parents:
diff changeset
690 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
691 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
692 }
prymula <prymula76@outlook.com>
parents:
diff changeset
693
prymula <prymula76@outlook.com>
parents:
diff changeset
694 }
prymula <prymula76@outlook.com>
parents:
diff changeset
695 }
prymula <prymula76@outlook.com>
parents:
diff changeset
696 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
697 dragAndDrop.image=null;
prymula <prymula76@outlook.com>
parents:
diff changeset
698 fromLeft=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
699 fromRight=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
700 }
prymula <prymula76@outlook.com>
parents:
diff changeset
701
prymula <prymula76@outlook.com>
parents:
diff changeset
702
prymula <prymula76@outlook.com>
parents:
diff changeset
703 }
prymula <prymula76@outlook.com>
parents:
diff changeset
704 }
prymula <prymula76@outlook.com>
parents:
diff changeset
705 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
706 System.out.println("POZA ZAKRESEM");
prymula <prymula76@outlook.com>
parents:
diff changeset
707 }
prymula <prymula76@outlook.com>
parents:
diff changeset
708
prymula <prymula76@outlook.com>
parents:
diff changeset
709 //System.out.println("DRAGANDDROP:"+dragAndDrop);
prymula <prymula76@outlook.com>
parents:
diff changeset
710
prymula <prymula76@outlook.com>
parents:
diff changeset
711 dragGetCoor = mouseMotion.get();
prymula <prymula76@outlook.com>
parents:
diff changeset
712 //if(dragGetCoor.x!=0 && dragGetCoor.y!=0){
prymula <prymula76@outlook.com>
parents:
diff changeset
713 System.out.println("drag x: "+dragGetCoor.x+" drag y: "+dragGetCoor.y+" xputcoor:"+putx+" yputcoor:"+puty);
prymula <prymula76@outlook.com>
parents:
diff changeset
714 if (dragAndDrop!=null)
prymula <prymula76@outlook.com>
parents:
diff changeset
715 dragAndDrop.set(dragGetCoor.x, dragGetCoor.y);
prymula <prymula76@outlook.com>
parents:
diff changeset
716 //}
prymula <prymula76@outlook.com>
parents:
diff changeset
717 trefle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
718
prymula <prymula76@outlook.com>
parents:
diff changeset
719 if (arranged()){
prymula <prymula76@outlook.com>
parents:
diff changeset
720 String s1="Ulozyles wszystkie puzzle !\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
721 s2="Wykonales "+move+" ruchow.\n";
prymula <prymula76@outlook.com>
parents:
diff changeset
722 JOptionPane.showMessageDialog(frame,
prymula <prymula76@outlook.com>
parents:
diff changeset
723 s1+s2,
prymula <prymula76@outlook.com>
parents:
diff changeset
724 "Podsumowanie",
prymula <prymula76@outlook.com>
parents:
diff changeset
725 JOptionPane.PLAIN_MESSAGE);
prymula <prymula76@outlook.com>
parents:
diff changeset
726 go=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
727 }
prymula <prymula76@outlook.com>
parents:
diff changeset
728 System.out.println("PO ARRANGED");
prymula <prymula76@outlook.com>
parents:
diff changeset
729 }
prymula <prymula76@outlook.com>
parents:
diff changeset
730 }
prymula <prymula76@outlook.com>
parents:
diff changeset
731 private boolean arranged(){
prymula <prymula76@outlook.com>
parents:
diff changeset
732 int i=0, a=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
733 for (int y=0;y<6;y++){
prymula <prymula76@outlook.com>
parents:
diff changeset
734 for (int x=0;x<4;x++){
prymula <prymula76@outlook.com>
parents:
diff changeset
735 if (wallPaper[y][x] != null){
prymula <prymula76@outlook.com>
parents:
diff changeset
736 if (wallPaper[y][x].n==origPicture[y][x].n){
prymula <prymula76@outlook.com>
parents:
diff changeset
737 a++;
prymula <prymula76@outlook.com>
parents:
diff changeset
738 }
prymula <prymula76@outlook.com>
parents:
diff changeset
739 }
prymula <prymula76@outlook.com>
parents:
diff changeset
740 i++;
prymula <prymula76@outlook.com>
parents:
diff changeset
741 }
prymula <prymula76@outlook.com>
parents:
diff changeset
742 }
prymula <prymula76@outlook.com>
parents:
diff changeset
743 System.out.println("A: "+a);
prymula <prymula76@outlook.com>
parents:
diff changeset
744 if(a==24) return true;
prymula <prymula76@outlook.com>
parents:
diff changeset
745 return false;
prymula <prymula76@outlook.com>
parents:
diff changeset
746 }
prymula <prymula76@outlook.com>
parents:
diff changeset
747
prymula <prymula76@outlook.com>
parents:
diff changeset
748 }
prymula <prymula76@outlook.com>
parents:
diff changeset
749
prymula <prymula76@outlook.com>
parents:
diff changeset
750 }