diff --git a/Programmierung2/src/Übungen/Flappy_Bird/GamePanel.java b/Programmierung2/src/Übungen/Flappy_Bird/GamePanel.java index 359e056..234d4dd 100644 --- a/Programmierung2/src/Übungen/Flappy_Bird/GamePanel.java +++ b/Programmierung2/src/Übungen/Flappy_Bird/GamePanel.java @@ -8,12 +8,13 @@ import javax.swing.*; public class GamePanel extends JPanel implements Runnable { final static int WIDTH_WINDOW = 600; - final static int HEIGH_WINDOW = 900; + final static int HEIGH_WINDOW = 800; Dimension fensterSize = new Dimension(WIDTH_WINDOW, HEIGH_WINDOW); DrawImages world; DrawImages flappy; DrawImages ground1,ground2; + DrawImages bottompipe,toppipe; Thread game; @@ -32,6 +33,11 @@ public class GamePanel extends JPanel implements Runnable { public void drawImage() { world = new DrawImages(0, 0, WIDTH_WINDOW, HEIGH_WINDOW, new ImageIcon("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\Übungen\\Flappy_Bird\\world.png").getImage()); flappy = new DrawImages(50, HEIGH_WINDOW / 2, 50, 50, new ImageIcon("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\Übungen\\Flappy_Bird\\flappy Bird.png").getImage()); + + + toppipe = new DrawImages(WIDTH_WINDOW/2,0,40,HEIGH_WINDOW - 300,new ImageIcon("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\Übungen\\Flappy_Bird\\toppipe.png").getImage()); + bottompipe = new DrawImages(WIDTH_WINDOW/2,HEIGH_WINDOW - 200,40,300,new ImageIcon("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\Übungen\\Flappy_Bird\\bottompipe.png").getImage()); + // Zwei Bodenbilder nebeneinander zeichnen ground1 = new DrawImages(0, HEIGH_WINDOW - 100, WIDTH_WINDOW, 200, new ImageIcon("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\Übungen\\Flappy_Bird\\ground.png").getImage()); ground2 = new DrawImages(WIDTH_WINDOW, HEIGH_WINDOW - 100, WIDTH_WINDOW, 200, new ImageIcon("C:\\Users\\obaya\\git\\Programmierung2\\Programmierung2\\src\\Übungen\\Flappy_Bird\\ground.png").getImage()); @@ -41,13 +47,16 @@ public class GamePanel extends JPanel implements Runnable { super.paint(g); world.draw(g); flappy.draw(g); + toppipe.draw(g); + bottompipe.draw(g); ground1.draw(g); - ground2.draw(g); - } + ground2.draw(g); + } public void move() { flappy.move(); move_ground(); + move_pips(); } public void move_ground() { @@ -65,9 +74,19 @@ public class GamePanel extends JPanel implements Runnable { } } + public void move_pips() { + toppipe.x -= 1; + bottompipe.x -= 1; + } + public void checkKollision() { if(flappy.intersects(ground1)) gameOver = true; + + if (flappy.intersects(toppipe)) + gameOver = true; + + } diff --git a/Programmierung2/src/Übungen/Flappy_Bird/bottompipe.png b/Programmierung2/src/Übungen/Flappy_Bird/bottompipe.png new file mode 100644 index 0000000..2c57b32 Binary files /dev/null and b/Programmierung2/src/Übungen/Flappy_Bird/bottompipe.png differ diff --git a/Programmierung2/src/Übungen/Flappy_Bird/toppipe.png b/Programmierung2/src/Übungen/Flappy_Bird/toppipe.png new file mode 100644 index 0000000..8b0a967 Binary files /dev/null and b/Programmierung2/src/Übungen/Flappy_Bird/toppipe.png differ