diff --git a/Happy_Bird/.gradle/buildOutputCleanup/outputFiles.bin b/Happy_Bird/.gradle/buildOutputCleanup/outputFiles.bin index e24dad9..a1d4ec7 100644 Binary files a/Happy_Bird/.gradle/buildOutputCleanup/outputFiles.bin and b/Happy_Bird/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/Happy_Bird/.idea/.name b/Happy_Bird/.idea/.name deleted file mode 100644 index dd712e9..0000000 --- a/Happy_Bird/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -HappyBirdMain.java \ No newline at end of file diff --git a/Happy_Bird/build/classes/java/main/module-info.class b/Happy_Bird/build/classes/java/main/module-info.class index 9ac6a58..f5441f6 100644 Binary files a/Happy_Bird/build/classes/java/main/module-info.class and b/Happy_Bird/build/classes/java/main/module-info.class differ diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/GameScreen.java b/Happy_Bird/src/main/java/com/example/happy_bird/GameScreen.java index 5bf395f..7d8ea08 100644 --- a/Happy_Bird/src/main/java/com/example/happy_bird/GameScreen.java +++ b/Happy_Bird/src/main/java/com/example/happy_bird/GameScreen.java @@ -22,4 +22,5 @@ import java.io.IOException; public class GameScreen extends HappyBirdMain { + } diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/Pipe.java b/Happy_Bird/src/main/java/com/example/happy_bird/Pipe.java new file mode 100644 index 0000000..b85698a --- /dev/null +++ b/Happy_Bird/src/main/java/com/example/happy_bird/Pipe.java @@ -0,0 +1,104 @@ +package com.example.happy_bird; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; + +public class Pipe extends SpielObjekt { + + private java.awt.Image lowerPipe; + // private java.awt.Image lowerPipe = new java.awt.Image("file:src/main/resources/com/example/happy_bird/pics/PipeUnten.png", 86, 300, false, false); + private int xWert = 0, yWert = 0; + + public Pipe(int xWert, int yWert) { + super(xWert, yWert); + lowerPipe = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("com/example/happy_bird/")); + //scale lowerPipe(initialWidth, initialHeight) + } + + public void scaleTopPipe(int width, int height) { + lowerPipe = lowerPipe.getScaledInstance(width, height, Image.SCALE_SMOOTH); + } + + public Image getPipe() { + return getPipe(); + } + + /** + * Method um die Breite des BottomPipe-Objekts zu erhalten + * @return int + */ + public int getWidth(int width) { + return lowerPipe.getWidth(null); + } + /** + * Methode um die Höhe des BottomPipe-Objekts zu erhalten + * @return int + */ + public int getHeight(int height) { + return lowerPipe.getHeight(null); + } + + /** + * Methode zum Festlegen der x-Position des BottomPipe-Objekts + * @param x + */ + public void setX(int x) { + xWert = x; + } + + /** + * Methode zum Abrufen der x-Position des BottomPipe-Objekts + * @return int + */ + public int getX() { + return xWert; + } + + /** + * Methode zum Festlegen der y-Position des BottomPipe-Objekts + * @param y + */ + public void setY(int y) { + yWert = y; + } + + /** + * Methode zum Abrufen der y-Position des BottomPipe-Objekts + * @return int + */ + public int getY() { + return yWert; + } + + /** + * Methode zum Erfassen eines Rechtecks, das das Bild des BottomPipe umreißt + * @return Rechteck, das die Position des BottomPipe auf dem Bildschirm umreißt + */ + public Rectangle getRectangle() { + return (new Rectangle(xWert, yWert, lowerPipe.getWidth(null), lowerPipe.getHeight(null))); + } + + /** + * Methode zum Erfassen eines BufferedImage, das das Bildobjekt der TopPipe darstellt + * @return TopPipe's BufferedImage-Objekt + */ + public BufferedImage getBI() { + BufferedImage bi = new BufferedImage(lowerPipe.getWidth(null), lowerPipe.getHeight(null), BufferedImage.TYPE_INT_ARGB); + Graphics g = bi.getGraphics(); + g.drawImage(lowerPipe, 0, 0, null); + g.dispose(); + return bi; + } + + + @Override + public void tick() { + + } + + @Override + public void render(Graphics2D g, ImageObserver obs) { + + } +} diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/PipeTop.java b/Happy_Bird/src/main/java/com/example/happy_bird/PipeTop.java new file mode 100644 index 0000000..4f086d4 --- /dev/null +++ b/Happy_Bird/src/main/java/com/example/happy_bird/PipeTop.java @@ -0,0 +1,103 @@ +package com.example.happy_bird; + +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Image; +import java.awt.image.BufferedImage; + +public class PipeTop { + //global variables + private Image topPipe; + private int xLoc = 0, yLoc = 0; + + public PipeTop(int initialWidth, int initialHeight) { + topPipe = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("resources/tube_top.png")); + scaleTopPipe(initialWidth, initialHeight); + } + + /** + * Methode zum Skalieren des topPipe-Sprites in die gewünschten Dimensionen + * @param width Die gewünschte Breite der topPipe + * @param height Die gewünschte Höhe der topPipe + */ + public void scaleTopPipe(int width, int height) { + topPipe = topPipe.getScaledInstance(width, height, Image.SCALE_SMOOTH); + } + + /** + * Getter-Methode für das TopPipe-Objekt. + * @return-Image + */ + public Image getPipe() { + return topPipe; + } + + /** + * Methode zum Abrufen der Breite des TopPipe-Objekts + * @return int + */ + public int getWidth() { + return topPipe.getWidth(null); + } + + /** + * Methode, um die Höhe des TopPipe-Objekts zu erhalten + * @return int + */ + public int getHeight() { + return topPipe.getHeight(null); + } + + /** + * Methode zum Festlegen der x-Position des TopPipe-Objekts + * @param x + */ + public void setX(int x) { + xLoc = x; + } + + /** + * Methode zum Abrufen der x-Position des TopPipe-Objekts + * @return int + */ + public int getX() { + return xLoc; + } + + /** + * Methode zum Festlegen der y-Position des TopPipe-Objekts + * @param y + */ + public void setY(int y) { + yLoc = y; + } + + /** + * Methode zum Abrufen der y-Position des TopPipe-Objekts + * @return int + */ + public int getY() { + return yLoc; + } + + /** + * Methode zum Erfassen eines Rechtecks, das das Bild der TopPipe umreißt + * @return Rechteck, das die Position der TopPipe auf dem Bildschirm umreißt + */ + public Rectangle getRectangle() { + return (new Rectangle(xLoc, yLoc, topPipe.getWidth(null), topPipe.getHeight(null))); + } + + /** + * Methode zum Erfassen eines BufferedImage, das das Bildobjekt der TopPipe darstellt + * @return BufferedImage-Objekt von TopPipe + */ + public BufferedImage getBI() { + BufferedImage bi = new BufferedImage(topPipe.getWidth(null), topPipe.getHeight(null), BufferedImage.TYPE_INT_ARGB); + Graphics g = bi.getGraphics(); + g.drawImage(topPipe, 0, 0, null); + g.dispose(); + return bi; + } +} \ No newline at end of file diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/TopClass.java b/Happy_Bird/src/main/java/com/example/happy_bird/TopClass.java new file mode 100644 index 0000000..8060490 --- /dev/null +++ b/Happy_Bird/src/main/java/com/example/happy_bird/TopClass.java @@ -0,0 +1,10 @@ +package com.example.happy_bird; + +public class TopClass { + + private static final int PIPE_GAP = 0; + private static final int PIPE_WIDTH = 0; + + + +}