Browse Source

Merge branch 'SnakeGame' into 'main'

Merge SnakeGame into main

See merge request fdai7382/fertigjavagamelauncher!8
remotes/origin/textadventure
fdai7551 2 years ago
parent
commit
d136919c33
  1. 4
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java
  2. 831
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/SnakeGame.java
  3. 114
      JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/SnakeGameTest.java

4
JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/GamelauncherMain.java

@ -110,8 +110,8 @@ public class GamelauncherMain extends JFrame {//class
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
//SnakeGame frameSnake = new SnakeGame();
//frameSnake.setVisible(true);
SnakeGame frameSnake = new SnakeGame();
frameSnake.setVisible(true);
} }
}); });

831
JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/SnakeGame.java

@ -0,0 +1,831 @@
package de.hs_fulda.gruppenprojekt.JavaGamelauncher;
import java.io.*;
import java.awt.Color;
import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class SnakeGame extends JFrame {
private JPanel cP;
public JPanel panel1;
public JPanel panel2;
public JPanel panel3;
public JPanel panel4;
public JPanel panel5;
public JPanel panel6;
public JPanel panel7;
public JPanel panel8;
public JPanel panel9;
public JPanel panel10;
public JPanel panel11;
public JPanel panel12;
public JPanel panel13;
public JPanel panel14;
public JPanel panel15;
public JPanel panel16;
public JPanel panel17;
public JPanel panel18;
public JPanel panel19;
public JPanel panel20;
public JPanel panel21;
public JPanel panel22;
public JPanel panel23;
public JPanel panel24;
public JPanel panel25;
public JPanel panel26;
public JPanel panel27;
public JPanel panel28;
public JPanel panel29;
public JPanel panel30;
public JPanel panel31;
public JPanel panel32;
public JPanel panel33;
public JPanel panel34;
public JPanel panel35;
public JPanel panel36;
public int breite = 1200;
public int hoehe = 600;
public String titel = "Snake";
public int hoeheP1 = 100;
public int breiteP1 = 100;
public int hoeheP2 = 100;
public int breiteP2 = 100;
public int hoeheP3 = 100;
public int breiteP3 = 100;
public int hoeheP4 = 100;
public int breiteP4 = 100;
public int xCords1 = 300;
public int xCords2 = 400;
public int xCords3 = 500;
public int xCords4 = 600;
public int xCords5 = 700;
public int xCords6 = 800;
public int yCords1 = 0;
public int yCords2 = 100;
public int yCords3 = 200;
public int yCords4 = 300;
public int yCords5 = 400;
public int yCords6 = 500;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GamelauncherMain frame = new GamelauncherMain();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public SnakeGame() {
setTitle("Snake");
setBounds(0, 0, 1200, 600);
cP = new JPanel();
cP.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(cP);
cP.setLayout(null);
panel1 = new JPanel();
panel1.setBounds(xCords1, yCords1, hoeheP1, breiteP1);
panel1.setVisible(true);
panel1.setBackground(Color.BLACK);
cP.add(panel1);
panel2 = new JPanel();
panel2.setBounds(xCords2, yCords1, 100, 100);
panel2.setVisible(true);
panel2.setBackground(Color.BLACK);
cP.add(panel2);
panel3 = new JPanel();
panel3.setBounds(xCords3, yCords1, 100, 100);
panel3.setVisible(true);
panel3.setBackground(Color.BLACK);
cP.add(panel3);
panel4 = new JPanel();
panel4.setBounds(xCords4, yCords1, 100, 100);
panel4.setVisible(true);
panel4.setBackground(Color.BLACK);
cP.add(panel4);
panel5 = new JPanel();
panel5.setBounds(xCords5, yCords1, 100, 100);
panel5.setVisible(true);
panel5.setBackground(Color.BLACK);
cP.add(panel5);
panel6 = new JPanel();
panel6.setBounds(xCords6, yCords1, 100, 100);
panel6.setVisible(true);
panel6.setBackground(Color.BLACK);
cP.add(panel6);
panel7 = new JPanel();
panel7.setBounds(xCords1, yCords2, 100, 100);
panel7.setVisible(true);
panel7.setBackground(Color.BLACK);
cP.add(panel7);
panel8 = new JPanel();
panel8.setBounds(xCords2, yCords2, 100, 100);
panel8.setVisible(true);
panel8.setBackground(Color.BLUE);
cP.add(panel8);
panel9 = new JPanel();
panel9.setBounds(xCords3, yCords2, 100, 100);
panel9.setVisible(true);
panel9.setBackground(Color.BLACK);
cP.add(panel9);
panel10 = new JPanel();
panel10.setBounds(xCords4, yCords2, 100, 100);
panel10.setVisible(true);
panel10.setBackground(Color.BLACK);
cP.add(panel10);
panel11 = new JPanel();
panel11.setBounds(xCords5, yCords2, 100, 100);
panel11.setVisible(true);
panel11.setBackground(Color.BLACK);
cP.add(panel11);
panel12 = new JPanel();
panel12.setBounds(xCords6, yCords2, hoeheP2, breiteP2);
panel12.setVisible(true);
panel12.setBackground(Color.BLACK);
cP.add(panel12);
panel13 = new JPanel();
panel13.setBounds(xCords1, yCords3, 100, 100);
panel13.setVisible(true);
panel13.setBackground(Color.BLACK);
cP.add(panel13);
panel14 = new JPanel();
panel14.setBounds(xCords2, yCords3, 100, 100);
panel14.setVisible(true);
panel14.setBackground(Color.WHITE);
cP.add(panel14);
panel15 = new JPanel();
panel15.setBounds(xCords3, yCords3, 100, 100);
panel15.setVisible(true);
panel15.setBackground(Color.BLACK);
cP.add(panel15);
panel16 = new JPanel();
panel16.setBounds(xCords4, yCords3, 100, 100);
panel16.setVisible(true);
panel16.setBackground(Color.BLACK);
cP.add(panel16);
panel17 = new JPanel();
panel17.setBounds(xCords5, yCords3, 100, 100);
panel17.setVisible(true);
panel17.setBackground(Color.BLACK);
cP.add(panel17);
panel18 = new JPanel();
panel18.setBounds(xCords6, yCords3, 100, 100);
panel18.setVisible(true);
panel18.setBackground(Color.BLACK);
cP.add(panel18);
panel19 = new JPanel();
panel19.setBounds(xCords1, yCords4, 100, 100);
panel19.setVisible(true);
panel19.setBackground(Color.BLACK);
cP.add(panel19);
panel20 = new JPanel();
panel20.setBounds(xCords2, yCords4, 100, 100);
panel20.setVisible(true);
panel20.setBackground(Color.WHITE);
cP.add(panel20);
panel21 = new JPanel();
panel21.setBounds(xCords3, yCords4, 100, 100);
panel21.setVisible(true);
panel21.setBackground(Color.BLACK);
cP.add(panel21);
panel22 = new JPanel();
panel22.setBounds(xCords4, yCords4, 100, 100);
panel22.setVisible(true);
panel22.setBackground(Color.BLACK);
cP.add(panel22);
panel23 = new JPanel();
panel23.setBounds(xCords5, yCords4, 100, 100);
panel23.setVisible(true);
panel23.setBackground(Color.BLACK);
cP.add(panel23);
panel24 = new JPanel();
panel24.setBounds(xCords6, yCords4, 100, 100);
panel24.setVisible(true);
panel24.setBackground(Color.BLACK);
cP.add(panel24);
panel25 = new JPanel();
panel25.setBounds(xCords1, yCords5, 100, 100);
panel25.setVisible(true);
panel25.setBackground(Color.BLACK);
cP.add(panel25);
panel26 = new JPanel();
panel26.setBounds(xCords2, yCords5, 100, 100);
panel26.setVisible(true);
panel26.setBackground(Color.BLACK);
cP.add(panel26);
panel27 = new JPanel();
panel27.setBounds(xCords3, yCords5, 100, 100);
panel27.setVisible(true);
panel27.setBackground(Color.BLACK);
cP.add(panel27);
panel28 = new JPanel();
panel28.setBounds(xCords4, yCords5, 100, 100);
panel28.setVisible(true);
panel28.setBackground(Color.BLACK);
cP.add(panel28);
panel29 = new JPanel();
panel29.setBounds(xCords5, yCords5, 100, 100);
panel29.setVisible(true);
panel29.setBackground(Color.BLACK);
cP.add(panel29);
panel30 = new JPanel();
panel30.setBounds(xCords6, yCords5, 100, 100);
panel30.setVisible(true);
panel30.setBackground(Color.BLACK);
cP.add(panel30);
panel31 = new JPanel();
panel31.setBounds(xCords1, yCords6, 100, 100);
panel31.setVisible(true);
panel31.setBackground(Color.BLACK);
cP.add(panel31);
panel32 = new JPanel();
panel32.setBounds(xCords2, yCords6, 100, 100);
panel32.setVisible(true);
panel32.setBackground(Color.BLACK);
cP.add(panel32);
panel33 = new JPanel();
panel33.setBounds(xCords3, yCords6, 100, 100);
panel33.setVisible(true);
panel33.setBackground(Color.BLACK);
cP.add(panel33);
panel34 = new JPanel();
panel34.setBounds(xCords4, yCords6, 100, 100);
panel34.setVisible(true);
panel34.setBackground(Color.BLACK);
cP.add(panel34);
panel35 = new JPanel();
panel35.setBounds(xCords5, yCords6, 100, 100);
panel35.setVisible(true);
panel35.setBackground(Color.BLACK);
cP.add(panel35);
panel36 = new JPanel();
panel36.setBounds(xCords6, yCords6, 100, 100);
panel36.setVisible(true);
panel36.setBackground(Color.BLACK);
cP.add(panel36);
}
public JPanel getPanel19() {
return panel19;
}
public void setPanel19(JPanel panel19) {
this.panel19 = panel19;
}
public JPanel getPanel20() {
return panel20;
}
public void setPanel20(JPanel panel20) {
this.panel20 = panel20;
}
public JPanel getPanel21() {
return panel21;
}
public void setPanel21(JPanel panel21) {
this.panel21 = panel21;
}
public JPanel getPanel22() {
return panel22;
}
public void setPanel22(JPanel panel22) {
this.panel22 = panel22;
}
public JPanel getPanel23() {
return panel23;
}
public void setPanel23(JPanel panel23) {
this.panel23 = panel23;
}
public JPanel getPanel24() {
return panel24;
}
public void setPanel24(JPanel panel24) {
this.panel24 = panel24;
}
public JPanel getPanel25() {
return panel25;
}
public void setPanel25(JPanel panel25) {
this.panel25 = panel25;
}
public JPanel getPanel26() {
return panel26;
}
public void setPanel26(JPanel panel26) {
this.panel26 = panel26;
}
public JPanel getPanel27() {
return panel27;
}
public void setPanel27(JPanel panel27) {
this.panel27 = panel27;
}
public JPanel getPanel28() {
return panel28;
}
public void setPanel28(JPanel panel28) {
this.panel28 = panel28;
}
public JPanel getPanel29() {
return panel29;
}
public void setPanel29(JPanel panel29) {
this.panel29 = panel29;
}
public JPanel getPanel30() {
return panel30;
}
public void setPanel30(JPanel panel30) {
this.panel30 = panel30;
}
public JPanel getPanel31() {
return panel31;
}
public void setPanel31(JPanel panel31) {
this.panel31 = panel31;
}
public JPanel getPanel32() {
return panel32;
}
public void setPanel32(JPanel panel32) {
this.panel32 = panel32;
}
public JPanel getPanel33() {
return panel33;
}
public void setPanel33(JPanel panel33) {
this.panel33 = panel33;
}
public JPanel getPanel34() {
return panel34;
}
public void setPanel34(JPanel panel34) {
this.panel34 = panel34;
}
public JPanel getPanel35() {
return panel35;
}
public void setPanel35(JPanel panel35) {
this.panel35 = panel35;
}
public JPanel getPanel36() {
return panel36;
}
public void setPanel36(JPanel panel36) {
this.panel36 = panel36;
}
public int getxCords1() {
return xCords1;
}
public void setxCords1(int xCords1) {
this.xCords1 = xCords1;
}
public int getxCords2() {
return xCords2;
}
public void setxCords2(int xCords2) {
this.xCords2 = xCords2;
}
public int getxCords3() {
return xCords3;
}
public void setxCords3(int xCords3) {
this.xCords3 = xCords3;
}
public int getxCords4() {
return xCords4;
}
public void setxCords4(int xCords4) {
this.xCords4 = xCords4;
}
public int getxCords5() {
return xCords5;
}
public void setxCords5(int xCords5) {
this.xCords5 = xCords5;
}
public int getxCords6() {
return xCords6;
}
public void setxCords6(int xCords6) {
this.xCords6 = xCords6;
}
public int getyCords1() {
return yCords1;
}
public void setyCords1(int yCords1) {
this.yCords1 = yCords1;
}
public int getyCords2() {
return yCords2;
}
public void setyCords2(int yCords2) {
this.yCords2 = yCords2;
}
public int getyCords3() {
return yCords3;
}
public void setyCords3(int yCords3) {
this.yCords3 = yCords3;
}
public int getyCords4() {
return yCords4;
}
public void setyCords4(int yCords4) {
this.yCords4 = yCords4;
}
public int getyCords5() {
return yCords5;
}
public void setyCords5(int yCords5) {
this.yCords5 = yCords5;
}
public int getyCords6() {
return yCords6;
}
public void setyCords6(int yCords6) {
this.yCords6 = yCords6;
}
public JPanel getPanel1() {
return panel1;
}
public void setPanel1(JPanel panel1) {
this.panel1 = panel1;
}
public JPanel getPanel2() {
return panel2;
}
public void setPanel2(JPanel panel2) {
this.panel2 = panel2;
}
public JPanel getPanel3() {
return panel3;
}
public void setPanel3(JPanel panel3) {
this.panel3 = panel3;
}
public JPanel getPanel4() {
return panel4;
}
public void setPanel4(JPanel panel4) {
this.panel4 = panel4;
}
public int getBreite() {
return breite;
}
public void setBreite(int breite) {
this.breite = breite;
}
public int getHoehe() {
return hoehe;
}
public void setHoehe(int hoehe) {
this.hoehe = hoehe;
}
public JPanel getPanel5() {
return panel5;
}
public void setPanel5(JPanel panel5) {
this.panel5 = panel5;
}
public JPanel getPanel6() {
return panel6;
}
public void setPanel6(JPanel panel6) {
this.panel6 = panel6;
}
public JPanel getPanel7() {
return panel7;
}
public void setPanel7(JPanel panel7) {
this.panel7 = panel7;
}
public JPanel getPanel8() {
return panel8;
}
public void setPanel8(JPanel panel8) {
this.panel8 = panel8;
}
public JPanel getPanel9() {
return panel9;
}
public void setPanel9(JPanel panel9) {
this.panel9 = panel9;
}
public JPanel getPanel10() {
return panel10;
}
public void setPanel10(JPanel panel10) {
this.panel10 = panel10;
}
public JPanel getPanel11() {
return panel11;
}
public void setPanel11(JPanel panel11) {
this.panel11 = panel11;
}
public JPanel getPanel12() {
return panel12;
}
public void setPanel12(JPanel panel12) {
this.panel12 = panel12;
}
public JPanel getPanel13() {
return panel13;
}
public void setPanel13(JPanel panel13) {
this.panel13 = panel13;
}
public JPanel getPanel14() {
return panel14;
}
public void setPanel14(JPanel panel14) {
this.panel14 = panel14;
}
public JPanel getPanel15() {
return panel15;
}
public void setPanel15(JPanel panel15) {
this.panel15 = panel15;
}
public JPanel getPanel16() {
return panel16;
}
public void setPanel16(JPanel panel16) {
this.panel16 = panel16;
}
public JPanel getPanel17() {
return panel17;
}
public void setPanel17(JPanel panel17) {
this.panel17 = panel17;
}
public JPanel getPanel18() {
return panel18;
}
public void setPanel18(JPanel panel18) {
this.panel18 = panel18;
}
public int getHoeheP2() {
return hoeheP2;
}
public void setHoeheP2(int hoeheP2) {
this.hoeheP2 = hoeheP2;
}
public int getBreiteP2() {
return breiteP2;
}
public void setBreiteP2(int breiteP2) {
this.breiteP2 = breiteP2;
}
public int getHoeheP3() {
return hoeheP3;
}
public void setHoeheP3(int hoeheP3) {
this.hoeheP3 = hoeheP3;
}
public int getBreiteP3() {
return breiteP3;
}
public void setBreiteP3(int breiteP3) {
this.breiteP3 = breiteP3;
}
public int getHoeheP4() {
return hoeheP4;
}
public void setHoeheP4(int hoeheP4) {
this.hoeheP4 = hoeheP4;
}
public int getBreiteP4() {
return breiteP4;
}
public void setBreiteP4(int breiteP4) {
this.breiteP4 = breiteP4;
}
public String getTitel() {
return titel;
}
public void setTitel(String titel) {
this.titel = titel;
}
public int getHoeheP1() {
return hoeheP1;
}
public void setHoeheP1(int hoeheP) {
this.hoeheP1 = hoeheP;
}
public int getBreiteP1() {
return breiteP1;
}
public void setBreiteP1(int breiteP) {
this.breiteP1 = breiteP;
}
}

114
JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/SnakeGameTest.java

@ -0,0 +1,114 @@
package de.hs_fulda.gruppenprojekt.JavaGamelauncher;
import static org.junit.Assert.*;
import org.junit.Test;
public class SnakeGameTest {
SnakeGame snek = new SnakeGame();
@Test
public void test() {
assertTrue(true);
}
@Test
public void hoeheTest() {
assertTrue(snek.hoehe == 600);
}
@Test
public void breiteTest() {
assertTrue(snek.breite == 1200);
}
@Test
public void titelTest() {
assertTrue(snek.titel == "Snake");
}
@Test
public void hoehePanelTest() {
int hoehe = 100;
assertTrue(snek.getHoeheP1() == hoehe );
}
@Test
public void breitePanelTest() {
int breite = 100;
assertTrue(snek.getBreiteP1() == breite );
}
@Test
public void hoehePane2Test() {
int hoehe = 100;
assertTrue(snek.getHoeheP2() == hoehe );
}
@Test
public void breitePane2Test() {
int breite = 100;
assertTrue(snek.getBreiteP2() == breite );
}
@Test
public void hoehePane3Test() {
int hoehe = 100;
assertTrue(snek.getHoeheP3() == hoehe );
}
@Test
public void breitePane3Test() {
int breite = 100;
assertTrue(snek.getBreiteP3() == breite );
}
@Test
public void hoehePane4Test() {
int hoehe = 100;
assertTrue(snek.getHoeheP4() == hoehe );
}
@Test
public void breitePane4Test() {
int breite = 100;
assertTrue(snek.getBreiteP4() == breite );
}
@Test
public void xCords1Test() {
int Cords = 300;
assertTrue(snek.getxCords1() == Cords );
}
@Test
public void xCords2Test() {
int Cords = 400;
assertTrue(snek.getxCords2() == Cords );
}
@Test
public void xCords3Test() {
int Cords = 500;
assertTrue(snek.getxCords3() == Cords );
}
@Test
public void xCords4Test() {
int Cords = 600;
assertTrue(snek.getxCords4() == Cords );
}
@Test
public void xCords5Test() {
int Cords = 700;
assertTrue(snek.getxCords5() == Cords );
}
@Test
public void xCords6Test() {
int Cords = 800;
assertTrue(snek.getxCords6() == Cords );
}
}
Loading…
Cancel
Save