Pipe Test
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										1
									
								
								Happy_Bird/.idea/.name
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Happy_Bird/.idea/.name
									
									
									
										generated
									
									
									
								
							@@ -1 +0,0 @@
 | 
				
			|||||||
HappyBirdMain.java
 | 
					 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -22,4 +22,5 @@ import java.io.IOException;
 | 
				
			|||||||
public class GameScreen extends HappyBirdMain
 | 
					public class GameScreen extends HappyBirdMain
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										104
									
								
								Happy_Bird/src/main/java/com/example/happy_bird/Pipe.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								Happy_Bird/src/main/java/com/example/happy_bird/Pipe.java
									
									
									
									
									
										Normal file
									
								
							@@ -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) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										103
									
								
								Happy_Bird/src/main/java/com/example/happy_bird/PipeTop.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								Happy_Bird/src/main/java/com/example/happy_bird/PipeTop.java
									
									
									
									
									
										Normal file
									
								
							@@ -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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user