From c5b6896038493d1e9f1760667c6e71adaa58563c Mon Sep 17 00:00:00 2001 From: Newe666 Date: Thu, 20 Jan 2022 20:35:00 +0100 Subject: [PATCH] Stein.txt + enum Steintypen + Blockbuilder(Wie die steine generiert werden)+ stein constructor angepasst --- .idea/runConfigurations.xml | 10 +++ Steine/I.txt | 16 +++++ Steine/J.txt | 12 ++++ Steine/L.txt | 12 ++++ Steine/O.txt | 8 +++ Steine/S.txt | 12 ++++ Steine/T.txt | 12 ++++ Steine/Z.txt | 13 ++++ out/production/Tetris/Tetris/Board.class | Bin 3561 -> 3658 bytes out/production/Tetris/Tetris/GameGui.class | Bin 2201 -> 2083 bytes src/Tetris/Board.java | 4 +- src/Tetris/Stein.java | 75 +++++++++++++++++++-- src/Tetris/SteineTyp.java | 11 +++ 13 files changed, 179 insertions(+), 6 deletions(-) create mode 100644 .idea/runConfigurations.xml create mode 100644 Steine/I.txt create mode 100644 Steine/J.txt create mode 100644 Steine/L.txt create mode 100644 Steine/O.txt create mode 100644 Steine/S.txt create mode 100644 Steine/T.txt create mode 100644 Steine/Z.txt create mode 100644 src/Tetris/SteineTyp.java diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Steine/I.txt b/Steine/I.txt new file mode 100644 index 0000000..19339a2 --- /dev/null +++ b/Steine/I.txt @@ -0,0 +1,16 @@ +0000 +1111 +0000 +0000 +0010 +0010 +0010 +0010 +0000 +0000 +1111 +0000 +0100 +0100 +0100 +0100 \ No newline at end of file diff --git a/Steine/J.txt b/Steine/J.txt new file mode 100644 index 0000000..220248d --- /dev/null +++ b/Steine/J.txt @@ -0,0 +1,12 @@ +100 +111 +000 +011 +010 +010 +000 +111 +001 +010 +010 +110 \ No newline at end of file diff --git a/Steine/L.txt b/Steine/L.txt new file mode 100644 index 0000000..a299305 --- /dev/null +++ b/Steine/L.txt @@ -0,0 +1,12 @@ +001 +111 +000 +010 +010 +011 +000 +111 +100 +110 +010 +010 \ No newline at end of file diff --git a/Steine/O.txt b/Steine/O.txt new file mode 100644 index 0000000..5ab665e --- /dev/null +++ b/Steine/O.txt @@ -0,0 +1,8 @@ +11 +11 +11 +11 +11 +11 +11 +11 \ No newline at end of file diff --git a/Steine/S.txt b/Steine/S.txt new file mode 100644 index 0000000..dda0620 --- /dev/null +++ b/Steine/S.txt @@ -0,0 +1,12 @@ +011 +110 +000 +010 +011 +001 +000 +011 +110 +100 +110 +010 \ No newline at end of file diff --git a/Steine/T.txt b/Steine/T.txt new file mode 100644 index 0000000..ef4709e --- /dev/null +++ b/Steine/T.txt @@ -0,0 +1,12 @@ +010 +111 +000 +011 +010 +000 +111 +010 +010 +110 +010 + diff --git a/Steine/Z.txt b/Steine/Z.txt new file mode 100644 index 0000000..e3b7b55 --- /dev/null +++ b/Steine/Z.txt @@ -0,0 +1,13 @@ +110 +011 +000 +001 +011 +010 +000 +110 +011 +010 +110 +100 + diff --git a/out/production/Tetris/Tetris/Board.class b/out/production/Tetris/Tetris/Board.class index 37d34ffa5aa56ef60aca05b0316e670c11ec45b2..59105a7317aabd8bf00ce01fca0f6a2602f89f19 100644 GIT binary patch delta 801 zcmX|;NlX+`5Qe{=8R(wop#voB2ZIx$F$NViE(yjM4|rA%qSoTsECS) z+JK<4C~n}2_}NIZM>%GJb+2V=c~*qv1URqwB=|J7T}TgdNP`1|!6u$eD5Zt83{ zQg6~=vfC?hqe)o%CXeCW#X)(98xntAMU9Sut(CD6~3~F@WW*rYq z9_oyv&5$<3+KlM#k4#2Q#^!$Z83ijs!RVe?BoYiCi3V%K2EH|G%Z>)4k=mA`L}q6^ z=;|@tk9p!Ox~q(*PMN2;G^i+LTv5U<#RU5mlT0a|X>^6_#h|x~3__4Bd$dC9=FCwsDdzvOz!lI3>s>UGkUFfFOP95(TqMN>l=# z=8VXzaDJr}x+^*Bg~L8mfx dleaptLW__ymbyKwMhGryD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/Tetris/Board.java +++ b/src/Tetris/Board.java @@ -33,7 +33,7 @@ private Color[] colors ={Color.decode("#ff00bf"),Color.decode("#0000ff"),Color.d public Board() { ran = new Random(); - steine[0]= new Stein(new int[][]{ + /*steine[0]= new Stein(new int[][]{ {1,1,1}, {0,1,0} @@ -63,7 +63,7 @@ private Color[] colors ={Color.decode("#ff00bf"),Color.decode("#0000ff"),Color.d {1,1,1,1} }, this,colors[6]); - currenStein= steine[0]; + currenStein= steine[0];*/ loop = new Timer(delay, new ActionListener() { int n = 0; diff --git a/src/Tetris/Stein.java b/src/Tetris/Stein.java index 6e4fbfd..feea645 100644 --- a/src/Tetris/Stein.java +++ b/src/Tetris/Stein.java @@ -1,15 +1,21 @@ package Tetris; import java.awt.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; public class Stein { - private int x = 4, y = 0; + SteineTyp Block; + private int x = 4, y = -2; private int normal = 850; private int fast = 50; + private int rotation; private long beginTime; private int delayTime = normal; private int deltax = 0; private boolean collision = false; + private int size; public static final int BOARD_WIDTH = 11; public static final int BOARD_HEIGHT = 20; @@ -19,10 +25,70 @@ public class Stein { private Board board; private Color color; - public Stein(int[][] coords, Board board, Color color) { - this.coords = coords; + public Stein() { + /* this.coords = coords; this.board = board; - this.color = color; + this.color = color;*/ + //Ewen Kerbs still in progress + // Hier werden die verschiedene steine auf deren typ "analysiert" und dann ausgewertet wie viel platz die aufm spielbrett benötigen + Block = SteineTyp.randomSteine(); + switch (Block) + { + case I: + size = 4; + break; + case O: + size =2; + break; + default: + size =3; + break; + } + } + + //ewen Kerbs still in progress + public int[][][] BlockBuilder(SteineTyp type) throws FileNotFoundException { + int[][][] size; + switch(type) + { + case I: + /* 3 dimensionales array um die rotations zu erkennen + */ + size = new int[4][4][4]; + break; + case O: + size = new int[4][2][2]; + break; + default: + size = new int[4][3][3]; + break; + } + File file = new File("Steine/"+type+".txt"); + Scanner leser = new Scanner(file); + //i= 4 verschiedene stein varianten (1=0° 2=90° 3=180°4=270°) + for (int varianten = 0; varianten < 4 ; varianten++) { + for (int j = 0; j < size[0].length; j++) { + if(leser.hasNext()) + { + String[] srow = leser.next().split(""); + int[] row = new int[size[0].length]; + for (int k = 0; k