From 11818054364b6248be8ff092d2914598f1081dc5 Mon Sep 17 00:00:00 2001 From: Przemyslaw Date: Thu, 18 Apr 2024 18:46:24 +0200 Subject: Init --- desktop/samegame/Changelog.txt | 12 + desktop/samegame/DEBIAN/HOWTO.txt | 2 + desktop/samegame/DEBIAN/debian.changelog | 5 + desktop/samegame/DEBIAN/debian.control | 13 + desktop/samegame/DEBIAN/debian.rules | 22 ++ desktop/samegame/DEBIAN/format.sh | 2 + desktop/samegame/DEBIAN/samegame.dsc | 40 ++ desktop/samegame/Makefile | 25 ++ desktop/samegame/PKG/PKGBUILD | 23 ++ desktop/samegame/RPM/samegame.spec | 67 ++++ desktop/samegame/SameGame.desktop | 13 + desktop/samegame/build.xml | 25 ++ desktop/samegame/res/samegame.png | Bin 0 -> 3838 bytes .../samegame/src/pietraszczyk/samegame/Field.java | 331 +++++++++++++++++ .../src/pietraszczyk/samegame/SameGame.java | 408 +++++++++++++++++++++ 15 files changed, 988 insertions(+) create mode 100644 desktop/samegame/Changelog.txt create mode 100644 desktop/samegame/DEBIAN/HOWTO.txt create mode 100644 desktop/samegame/DEBIAN/debian.changelog create mode 100644 desktop/samegame/DEBIAN/debian.control create mode 100644 desktop/samegame/DEBIAN/debian.rules create mode 100755 desktop/samegame/DEBIAN/format.sh create mode 100644 desktop/samegame/DEBIAN/samegame.dsc create mode 100644 desktop/samegame/Makefile create mode 100644 desktop/samegame/PKG/PKGBUILD create mode 100644 desktop/samegame/RPM/samegame.spec create mode 100644 desktop/samegame/SameGame.desktop create mode 100644 desktop/samegame/build.xml create mode 100644 desktop/samegame/res/samegame.png create mode 100644 desktop/samegame/src/pietraszczyk/samegame/Field.java create mode 100644 desktop/samegame/src/pietraszczyk/samegame/SameGame.java (limited to 'desktop') diff --git a/desktop/samegame/Changelog.txt b/desktop/samegame/Changelog.txt new file mode 100644 index 0000000..ce437bf --- /dev/null +++ b/desktop/samegame/Changelog.txt @@ -0,0 +1,12 @@ +0.240417-2 - Pakietowanie +0.240417-1 - Poprawki w naliczaniu punktacji z promowaaniem wyższych poziomów +0.240417-0 - Dodalem punktacje oraz poziomy +0.240416-0 - Plik Makefile oraz desktop +0.240414-0 - Dodanie funkcji reset - dla nowego rozdania +0.240412-3 - Chodzi po byku, można resetować grę +0.240412-2 - Prawie dobrze usuwa w pionie, prawie +0.240412-0 - Wyglada na to że już się nie zawiesza, tylko potrafi długo przeliczać +0.240411-1 - Działa czysto, choć dlugo liczy +0.240411-0 - Wychrzania się na drugim dobieraniu, daleko mu do wersji z Androida, szczerze mówiąc +0.240410-0 - Stan podobny do portu z Androida +0.240329-0 - Inicjacja diff --git a/desktop/samegame/DEBIAN/HOWTO.txt b/desktop/samegame/DEBIAN/HOWTO.txt new file mode 100644 index 0000000..a371e0b --- /dev/null +++ b/desktop/samegame/DEBIAN/HOWTO.txt @@ -0,0 +1,2 @@ +foramt zapisu nazwy pliku: + photocrop_0.221225-0~alpha.tar.gz diff --git a/desktop/samegame/DEBIAN/debian.changelog b/desktop/samegame/DEBIAN/debian.changelog new file mode 100644 index 0000000..b05edc8 --- /dev/null +++ b/desktop/samegame/DEBIAN/debian.changelog @@ -0,0 +1,5 @@ +samegame (0.240417-2) unstable; urgency=low + + * Last release + + -- Przemysław R. Pietraszczyk Wed, 17 Apr 2022 14:11:41 +0200 diff --git a/desktop/samegame/DEBIAN/debian.control b/desktop/samegame/DEBIAN/debian.control new file mode 100644 index 0000000..bb02b65 --- /dev/null +++ b/desktop/samegame/DEBIAN/debian.control @@ -0,0 +1,13 @@ +Source: samegame +Section: java +Priority: extra +Maintainer: Przemysław R. Pietraszczyk +Build-Depends: debhelper-compat (= 12), default-jdk, default-jdk-headless, fakeroot, ant +Standards-Version: 0.0000 +Homepage: https://pietraszczyk.smallhost.pl + + +Package: samegame +Architecture: all +Depends: ${misc:Depends}, default-jdk | default-jre +Description: My implementation Same Game diff --git a/desktop/samegame/DEBIAN/debian.rules b/desktop/samegame/DEBIAN/debian.rules new file mode 100644 index 0000000..b7f75b6 --- /dev/null +++ b/desktop/samegame/DEBIAN/debian.rules @@ -0,0 +1,22 @@ +#!/usr/bin/make -f + +export DH_VERBOSE = 1 + +clean: + ant clean + +build: + ant compile + ant jar + +binary: + mkdir -pm 0755 debian/samegame + mkdir -pm 0755 debian/samegame/usr/games + mkdir -pm 0755 debian/samegame/usr/share/samegame + mkdir -pm 0755 debian/samegame/usr/share/applications + cp build/jar/SameGame.jar debian/samegame/usr/games + cp res/samegame.png debian/samegame/usr/share/samegame + cp SameGame.desktop debian/samegame/usr/share/applications + dh_gencontrol + dh_builddeb + diff --git a/desktop/samegame/DEBIAN/format.sh b/desktop/samegame/DEBIAN/format.sh new file mode 100755 index 0000000..7a807b6 --- /dev/null +++ b/desktop/samegame/DEBIAN/format.sh @@ -0,0 +1,2 @@ +mkdir ./exec +exec /usr/lib/build/debtransform ./ ./samegame.dsc ./exec diff --git a/desktop/samegame/DEBIAN/samegame.dsc b/desktop/samegame/DEBIAN/samegame.dsc new file mode 100644 index 0000000..3e2cdc8 --- /dev/null +++ b/desktop/samegame/DEBIAN/samegame.dsc @@ -0,0 +1,40 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA256 + +Format: 1.0 +Source: samegame +Binary: samegame +Architecture: all +Version: 0.210503-2 +Maintainer: Przemysław R. Pietraszczyk +Homepage: https://pietraszczyk.smallhost.pl +DEBTRANSFORM-TAR: samegame-0.240417-2.tar.gz + +Standards-Version: 0.000000 +Build-Depends: debhelper-compat (>= 12), default-jdk, default-jdk-headless, fakeroot, ant +Package-List: +colorsmemory deb x11 optional arch=all +Files: + b31649bc23b2b7bca9ab70ea3410711a 128820 samegame-0.240417-2.tar.gz + 29e7e7e60bc81891e3da3871b9eeb549 764 samegame-0.240417-2.debian.tar.xz + +-----BEGIN PGP SIGNATURE----- + +mQENBGEf/c4BCAC2d4ymW0pRZV36qLtlt/WGb83kos5UX5UbwvkQrbUjAbOPOY8w +DT3M1neYOAPZx38924aPTFKbZPcz+rK/7Wcv1kzgfux5zXQJTLeqpkhUYAgXUg2p +oK9ZXsai82fOicTrClOyJLLYQ8C1vj8yUh7e3ERljEyp5Nxg/lY92rwcZ4WYR193 +nGDInlDl5JlWUcLlk/RFnC5bB+T6ZZr5FBX/eDnKAPEl+N3MWpDs2JLDy7EUPhcG +U/60X0wuXHPTwMoNbB3ep/bWRxwEej0sFad5GXeCh7hKCroi/kLmLTDIxSD8lsRr +Y4H/8H2lBBsQq7bRL88N6ZDGCocPo11V83kFABEBAAG0NmhvbWU6cHJ6ZW0gT0JT +IFByb2plY3QgPGhvbWU6cHJ6ZW1AYnVpbGQub3BlbnN1c2Uub3JnPokBPgQTAQgA +KAUCYR/9zgIbAwUJBB6wAAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQcXEc +NPcNefFEAAf+Kg4cs/C99kEIMv/PO85VW+p8rcTwCViOFUX5WrBhwsRyPAKrJPPG +KD6PdnvoplcNQwhQ8nRsRiiaiUtPcj8Bvi6EdPgSgXXObKKJtCyaAa1rURdlb9iW +CfvXA6oW+PGlii9BMnXOAtkeFIzZooO9oXd+wez66P+4VWFiFzxanLfLn/hwbWxQ +68rlO3QNGbrMeODBgwh9s83XGmAg47mn2fldTAmTbJDf9tMi1LhX2MmLyN9wjqsd +4IZ9JMri2JTnIhYfxWdKT9gsu7q0g8LqonaXMvlOEyHFRF1YQ0i7G6fFbvDcKCZN +W1Eja55FdN7smv5Eck6UTIIYyWPuAv45uohGBBMRAgAGBQJhH/3PAAoJEDswEbdr +nWUj4M0AniJ389dyvUjjgS91AcOb08E4moV9AJ9WDL3/7GYYUL/Azw43QucWPnXr +uw== +=+lfH +-----END PGP SIGNATURE----- diff --git a/desktop/samegame/Makefile b/desktop/samegame/Makefile new file mode 100644 index 0000000..980961a --- /dev/null +++ b/desktop/samegame/Makefile @@ -0,0 +1,25 @@ +prefix=/usr + +all: + ant compile + ant jar + +clean: + ant clean + +install: build/jar/SameGame.jar + mkdir -pm 0755 $(DESTDIR)$(prefix)/games + install -m 0644 build/jar/SameGame.jar $(DESTDIR)$(prefix)/games + mkdir -pm 0755 $(DESTDIR)$(prefix)/share/samegame + mkdir -pm 0755 $(DESTDIR)$(prefix)/share/applications + install -m 0644 res/samegame.png $(DESTDIR)$(prefix)/share/samegame + install -m 0644 SameGame.desktop $(DESTDIR)$(prefix)/share/applications + +.PHONY: install + +uninstall: + rm $(prefix)/games/SameGame.jar + rm -r $(prefix)/share/samegame + rm $(prefix)/share/applications/SameGame.desktop + +.PHONY: uninstall diff --git a/desktop/samegame/PKG/PKGBUILD b/desktop/samegame/PKG/PKGBUILD new file mode 100644 index 0000000..d0dbf59 --- /dev/null +++ b/desktop/samegame/PKG/PKGBUILD @@ -0,0 +1,23 @@ +# Maintainer: Przemyslaw R. Pietraszczyk + +pkgname=samegame +pkgver=0.240417 +pkgrel=2 +pkgdesc="My implementation Same Game" +arch=('any') +url="pietraszczyk.smallhost.pl" +license=('GPL3') +provides=('samegame') +depends=('jdk-openjdk') +makedepends=('jdk-openjdk' 'ant') +source=("${pkgname}-${pkgver}-${pkgrel}.tar.gz::file://${pkgname}-${pkgver}-${pkgrel}.tar.gz") +sha256sums=('fee822aff2c249ba0b93b9dad2967442de5c39a4f35fa7cfb125fe590a37d1a8') #generate with 'makepkg -g' || sha256sum +build() { + cd "$srcdir/${pkgname}-${pkgver}-${pkgrel}" + make -f Makefile +} + +package() { + cd "$srcdir/${pkgname}-${pkgver}-${pkgrel}" + make -f Makefile DESTDIR="${pkgdir}" install +} diff --git a/desktop/samegame/RPM/samegame.spec b/desktop/samegame/RPM/samegame.spec new file mode 100644 index 0000000..abca6c8 --- /dev/null +++ b/desktop/samegame/RPM/samegame.spec @@ -0,0 +1,67 @@ +# +# spec file for package samegame +# +# Copyright (c) 2020 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + +%define unmangled_version 0.240417-2 +Name: samegame +Version: 0.240417 +Release: 2 +Summary: My implementation Same Game +License: GPL +URL: https://pietraszczyk.smallhost.pl +Source0: %{name}-%{unmangled_version}.tar.gz +%if 0%{?suse_version}==1530 +BuildRequires: java-11-openjdk, ant +Requires: java-11-openjdk +%else +BuildRequires: java-11-openjdk, ant +Requires: java-11-openjdk +%endif +BuildArch: noarch + +%description + + +%prep +%setup -n %{name}-%{unmangled_version} -n %{name}-%{unmangled_version} + +%build +ant compile +ant jar + +%install +mkdir -p %{buildroot}/usr +mkdir -p %{buildroot}/usr/games +mkdir -p %{buildroot}/usr/share +mkdir -p %{buildroot}/usr/share/samegame +mkdir -p %{buildroot}/usr/share/applications + +#%make_install + +install -m 0644 build/jar/SameGame.jar %{buildroot}/usr/games +install -m 0644 res/samegame.png %{buildroot}/usr/share/samegame +install -m 0644 SameGame.desktop %{buildroot}/usr/share/applications + +%files +%defattr(0755,root,root) +/usr/games/ +%{_datadir}/samegame/ +%defattr(0644,root,root) +/usr/games/SameGame.jar +%{_datadir}/samegame/samegame.png +%{_datadir}/applications/SameGame.desktop + +%changelog diff --git a/desktop/samegame/SameGame.desktop b/desktop/samegame/SameGame.desktop new file mode 100644 index 0000000..0463928 --- /dev/null +++ b/desktop/samegame/SameGame.desktop @@ -0,0 +1,13 @@ +#!/usr/bin/env xdg-open + +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Categories=Game; + +Name=Same Game + +Exec=java -jar /usr/games/SameGame.jar +Terminal=false +Icon=/usr/share/samegame/samegame.png + diff --git a/desktop/samegame/build.xml b/desktop/samegame/build.xml new file mode 100644 index 0000000..ddf813a --- /dev/null +++ b/desktop/samegame/build.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/desktop/samegame/res/samegame.png b/desktop/samegame/res/samegame.png new file mode 100644 index 0000000..3a978c4 Binary files /dev/null and b/desktop/samegame/res/samegame.png differ diff --git a/desktop/samegame/src/pietraszczyk/samegame/Field.java b/desktop/samegame/src/pietraszczyk/samegame/Field.java new file mode 100644 index 0000000..17a82ae --- /dev/null +++ b/desktop/samegame/src/pietraszczyk/samegame/Field.java @@ -0,0 +1,331 @@ +/* +Same Game - My first application built in Kotlin +date: 19-III-2024 +code: Przemyslaw R. Pietraszczyk +license: GPL v3 +IDE: Android Studio Iguana +*/ +package pietraszczyk.samegame; + +import java.util.*; +import java.lang.*; +import javax.swing.*; +import java.awt.*; + +public class Field { + int index; + int groupIndex; + //String color; + //int x, y; + boolean visit; + public java.util.List groupList = new ArrayList(); + public java.util.List listIndex = new ArrayList(); + + public int value; // czy kolor (0) czy bialy (1) + public int resource; + + + + JButton button; + private Color colorHide, color; + private int x,y; + boolean found; + //boolean reserve; + boolean postReserve; + + + public Field () { + postReserve=false; + } + + public Field(int i, int j) { + + visit = false; + value = 0; + + button = new JButton("?"); + color=new Color(255,255,255); + y = i; + x = j; + found=false; + // reserve=false; + postReserve=false; + + } + + public void reset() { + visit = false; + value = 0; + } + + public void setIndex(int n) { + int index = n; + } + + public void setGroupIndex(int n) { + groupIndex = n; + } + + public void setColorName(Color c) { + color = c; + } + + public void setVelocity(int _x, int _y) { + x = _x; + y = _y; + } + + public int getGroupIndex() { + return groupIndex; + } + + public int getVelocityY() { + return y; + } + + public int getVelocityX() { + return x; + } + + public Color getColorHide(){ + return colorHide; + } + public Color getColor() { + return color; + } + public void setColorHide(int r, int g, int b){ + color=new Color(r,g,b); + } + public void setFound(boolean f){ + found=f; + } + public boolean getFound(){ + return found; + } + + + + + private String toRgb(Color arg){ + return String.format("%02X%02X%02X", arg.getRed(), arg.getGreen(), arg.getBlue()); + } + + + + + + public void like(Color color, Field [][] squares, int y, int x, int origy, int origx){ + + Color white = new Color(255,255, 255); + + // if ( squares[y][x].getColor() != white) { + // if (squares[y][x].getColor() == color) { + //System.out.println("Adr: "+squares[y][x].getColor()); + if (squares[y][x].visit == false) { + if ( (toRgb(squares[y][x].getColor()).equals(toRgb(white))) == false) { + if (toRgb(squares[y][x].getColor()).equals(toRgb(color))) { + + //if (squares[y][x].visit == false) { + // squares[origy][origx].groupList.add(String.valueOf(squares[y][x].getGroupIndex())); + // squares[origy][origx].listIndex.add(squares[y][x].getGroupIndex()); + //} + + + if (y >= 1) { + if (squares[y - 1][x].visit == false) { + squares[origy][origx].groupList.add(String.valueOf(squares[y][x].getGroupIndex())); + squares[origy][origx].listIndex.add(squares[y][x].getGroupIndex()); + + squares[y][x].visit = true; + like(color, squares, y - 1, x, origy, origx); + } + } + if (x >= 1) { + if (squares[y][x - 1].visit == false) { + squares[origy][origx].groupList.add(String.valueOf(squares[y][x].getGroupIndex())); + squares[origy][origx].listIndex.add(squares[y][x].getGroupIndex()); + + squares[y][x].visit = true; + like(color, squares, y, x - 1, origy, origx); + } + } + + if (y < 8) { + if (squares[y + 1][x].visit == false) { + squares[origy][origx].groupList.add(String.valueOf(squares[y][x].getGroupIndex())); + squares[origy][origx].listIndex.add(squares[y][x].getGroupIndex()); + + squares[y][x].visit = true; + like(color, squares, y + 1, x, origy, origx); + } + } + + if (x < 5) { + if (squares[y][x + 1].visit == false) { + squares[origy][origx].groupList.add(String.valueOf(squares[y][x].getGroupIndex())); + squares[origy][origx].listIndex.add(squares[y][x].getGroupIndex()); + + squares[y][x].visit = true; + like(color, squares, y, x + 1, origy, origx); + } + } + squares[y][x].visit = false; + } + + } + } + } + + // Mozliwe ze wogole nie potrzebne + public void blank() { + this.setColorName(new Color(255, 255, 255)); + this.value = 1; + + } + + public void toUp(Field [][] squares, int y, int x) { + + int n = 9; + Color temp; // String + int v; // = new Box(); + for(int i=0; i < n; i++){ + for(int j=1; j < (n-i); j++){ + if(squares[j-1][x].value > squares[j][x].value) { + //swap elements + temp = squares[j-1][x].getColor(); + v = squares[j-1][x].value; + squares[j-1][x].setColorName(squares[j][x].getColor()); + squares[j-1][x].value = squares[j][x].value; + squares[j][x].setColorName(temp); + squares[j][x].value = v; + } + + } + } + } + + public void toLeft(Field [][] squares, int y, int x) { + + int n = 6; + Color temp; //String + int v; // = new Box(); + for(int i=0; i < n; i++){ + for(int j=1; j < (n-i); j++){ + if(squares[y][j-1].value > squares[y][j].value) { + //swap elements + temp = squares[y][j-1].getColor(); + v = squares[y][j-1].value; + squares[y][j-1].setColorName(squares[y][j].getColor()); + squares[y][j-1].value = squares[y][j].value; + squares[y][j].setColorName(temp); + squares[y][j].value = v; + } + + } + } + } + + public void removeDuplicates() { + + java.util.List tmp = new ArrayList (); + + for(String item:this.groupList){ + boolean find = false; + for (String t:tmp) { + if (t.equals(item)){ + find = true; + } + } + if (find == false) { + tmp.add(item); + } + } + this.groupList.clear(); + this.groupList = tmp; + } + + public void removeDuplicatesIndex() { + + java.util.List tmp = new ArrayList (); + + for(Integer item:this.listIndex){ + boolean find = false; + for (Integer t:tmp) { + if (t.equals(item)){ + find = true; + } + } + if (find == false) { + tmp.add(item); + } + } + this.listIndex.clear(); + this.listIndex = tmp; + } + + public void clearVisit(){ + this.visit = false; + } + + public void sort() { + + // Zbyt nowe dopiero od API 24 + //String[] strings = b.groupList.toArray(String[]::new); + String[] strings = new String[this.groupList.size()]; + for (int i = 0; i < this.groupList.size(); i++) { + strings[i] = this.groupList.get(i); + } + + Integer[] numbers = new Integer[strings.length]; + for(int i = 0;i < strings.length;i++) + { + try + { + numbers[i] = Integer.parseInt(strings[i]); + } + catch (NumberFormatException nfe) + { + numbers[i] = null; + } + } + + Arrays.sort(numbers, Collections.reverseOrder()); + + this.groupList.clear(); + for(int i = 0;i < numbers.length;i++) + { + try + { + this.groupList.add(Integer.toString(numbers[i])); + } + catch (NumberFormatException nfe) + { + //numbers[i] = null; + } + } + + } + + public void sortReverseIndex() { + // Zbyt nowe dopiero od API 24 + //String[] strings = b.groupList.toArray(String[]::new); + Integer[] integers = new Integer[this.listIndex.size()]; + for (int i = 0; i < this.listIndex.size(); i++) { + integers[i] = this.listIndex.get(i); + } + + Arrays.sort(integers, Collections.reverseOrder()); + + this.listIndex.clear(); + for(int i = 0;i < integers.length;i++) + { + try + { + this.listIndex.add(integers[i]); + } + catch (NumberFormatException nfe) + { + } + } + } +} diff --git a/desktop/samegame/src/pietraszczyk/samegame/SameGame.java b/desktop/samegame/src/pietraszczyk/samegame/SameGame.java new file mode 100644 index 0000000..ae923d8 --- /dev/null +++ b/desktop/samegame/src/pietraszczyk/samegame/SameGame.java @@ -0,0 +1,408 @@ +/* + * Same Game - desktop - third approach to the problem + * 29-III-2024 + * code: Przemyslaw R. Pietraszczyk + * licence: GPL v3 + * IDE: Geany + */ +package pietraszczyk.samegame; + +import java.awt.*; // Toolkit +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +//import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JMenuBar; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.Box; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.util.Timer; +import java.util.*; //Timer +import java.lang.*; + +public class SameGame extends JPanel + implements ActionListener { + static JMenuBar menuBar; + JMenu menu, info; + JMenuItem menuItem, menuExit, menuInfo, l1, l2, l3, l4; + static final int NW = 6, NH = 9; //NW=9, NH=6; // weight - height + static JFrame frame; + static Timer timer; + static Field [][]field = new Field[NH][NW]; + static int []tmpi = new int[2]; + static int []tmpj = new int[2]; + static boolean showColor=false; + static boolean press=false; + static boolean lockClick=false; + static int nmove=0; + static int nFields; // ilosc pozostalych pol do odkrycia + static JLabel label = new JLabel("Witaj w Same Game - poziom 1"); + static int score; + static int level; + + public SameGame() { + super(new GridBagLayout()); + GridBagLayout gridbag = (GridBagLayout)getLayout(); + GridBagConstraints c = new GridBagConstraints(); + int i; + int j; + // int x, y; + int k=0; + level = 1; + + menuBar = new JMenuBar(); + menu = new JMenu("Plik"); + menuBar.add(menu); + // przenosi INFO na prawa strone + menuBar.add(Box.createHorizontalGlue()); + info = new JMenu("Info"); + info.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + menuBar.add(info); + menuItem = new JMenuItem("Nowa Gra", null); + menuItem.setActionCommand("NewGame"); + menuItem.addActionListener(this); + menuItem.setToolTipText("Rozpoczyna nowa gre"); + menu.add(menuItem); + + JMenu med = new JMenu("Poziom"); + l1 = new JMenuItem("Dwa kolory"); + l1.setActionCommand("L1"); + l1.addActionListener(this); + med.add(l1); + l2 = new JMenuItem("Trzy kolory"); + l2.setActionCommand("L2"); + l2.addActionListener(this); + med.add(l2); + l3 = new JMenuItem("Cztery kolory"); + l3.setActionCommand("L3"); + l3.addActionListener(this); + med.add(l3); + l4 = new JMenuItem("Piec kolorow"); + l4.setActionCommand("L4"); + l4.addActionListener(this); + med.add(l4); + + menu.add(med); + + menu.addSeparator(); + menuItem = new JMenuItem("Zakoncz", null); + menuItem.setActionCommand("Exit"); + menuItem.addActionListener(this); + menuItem.setToolTipText("Wyjscie z programu"); + menu.add(menuItem); + menuItem = new JMenuItem("O Programie", null); + menuItem.setActionCommand("About"); + menuItem.addActionListener(this); + menuItem.setToolTipText("Informacje o programie"); + info.add(menuItem); + + for (i=0; i 1) { + + int c = 0; + for (int l : field[i][j].listIndex) { + int y = l / 6; + int x = l % 6; + field[y][x].blank(); + } + // Przesuniecie w lerwo + for (int l :field[i][j].listIndex) { + int y = l / 6; + int x = l % 6; + field[y][x].toLeft(field, y, x); + } + + int s = 0; + s = field[i][j].listIndex.size(); + s = (s * (s -1)) * level * level; + score += s; + // Usuwanie elementow + for (int y : _y) { + for (int x : _x) { + field[y][x].groupList.clear(); + field[y][x].listIndex.clear(); + } + } + + + for (int y=0;y= 2) game_in_progress = true; + if (field[y][x].groupList.size() == 0) ++path_to_win; + } + } + if (!game_in_progress){ + String l = new String("Nieskonczona gra, wynik: "); + l += String.valueOf(score * level); + label.setText(l); + } + if (path_to_win == 54) { + String l = new String("Wygrana ! wynik: "); + l += String.valueOf(2 * (score * level)); + label.setText(l); + } + return; + } + } + } + } + if(e.getActionCommand().equals("NewGame")) { + int i,j; + for (i=0; i