From a12ee8537faef783dc914f7e1f886982b93427fc Mon Sep 17 00:00:00 2001 From: toksikk Date: Thu, 18 Dec 2014 15:11:00 +0100 Subject: [PATCH] fuuuu --- HeatUp/src/de/heatup/objects/ImageLoader.java | 5 +- HeatUp/src/de/heatup/objects/PowerUp.java | 56 +++---------------- 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/HeatUp/src/de/heatup/objects/ImageLoader.java b/HeatUp/src/de/heatup/objects/ImageLoader.java index 06b0ab2..2559d8b 100644 --- a/HeatUp/src/de/heatup/objects/ImageLoader.java +++ b/HeatUp/src/de/heatup/objects/ImageLoader.java @@ -28,7 +28,10 @@ public class ImageLoader { break; case Config.wallChar: imageFileName="de/heatup/resources/images/25x25_wall_orange_2.png"; - break; + break; + case 'b': + imageFileName="de/heatup/resources/images/25x25_powerup.png"; + break; case 'u': imageFileName="de/heatup/resources/images/little_green_guy_verysmall.png"; break; diff --git a/HeatUp/src/de/heatup/objects/PowerUp.java b/HeatUp/src/de/heatup/objects/PowerUp.java index b7d770b..05ed187 100644 --- a/HeatUp/src/de/heatup/objects/PowerUp.java +++ b/HeatUp/src/de/heatup/objects/PowerUp.java @@ -17,59 +17,17 @@ import de.heatup.cfg.Config; import de.heatup.logging.Logger; import de.heatup.mapengine.CollisionHandler; -public class PowerUp extends JComponent { - private static final long serialVersionUID = 1L; - protected BufferedImage bf1; - protected Graphics2D g2d; - private Point currentGridPosition; - private int type; +public class PowerUp extends StaticObject { - public PowerUp() { + private int pType; + + public PowerUp(Point location) { + super('b', location); Random rand = new Random(); - CollisionHandler.addPowerUpObject(this); - this.type = rand.nextInt(3); + this.pType = rand.nextInt(2); + // TODO Auto-generated constructor stub } - public void setGridLocation(int x, int y) { - currentGridPosition.setLocation(x, y); - } - public Point getGridLocation() { - return currentGridPosition; - } - - public void paintComponent(Graphics g) { - g2d = (Graphics2D) g; - if (bf1 == null) { - loadBufferedImage(); - } - - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.drawImage(bf1, 0, 0, this); - g2d.setStroke(new BasicStroke(8.0f)); - g2d.finalize(); - } - public void spawnAt(Point spawnPoint) { - this.currentGridPosition = spawnPoint; - this.setAutoBounds(spawnPoint.x*25, spawnPoint.y*25); - this.repaint(); - } - - protected void loadBufferedImage() { - try { - this.bf1 = ImageIO.read(new File("src/de/heatup/resources/images/powerup.png")); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void setImage(BufferedImage image) { - this.bf1 = image; - } - - public void setAutoBounds(int x, int y) { - this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight()); - } - }