This commit is contained in:
toksikk
2014-12-18 15:11:00 +01:00
parent b0e30848fa
commit a12ee8537f
2 changed files with 11 additions and 50 deletions
@@ -29,6 +29,9 @@ public class ImageLoader {
case Config.wallChar: case Config.wallChar:
imageFileName="de/heatup/resources/images/25x25_wall_orange_2.png"; 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': case 'u':
imageFileName="de/heatup/resources/images/little_green_guy_verysmall.png"; imageFileName="de/heatup/resources/images/little_green_guy_verysmall.png";
break; break;
+7 -49
View File
@@ -17,59 +17,17 @@ import de.heatup.cfg.Config;
import de.heatup.logging.Logger; import de.heatup.logging.Logger;
import de.heatup.mapengine.CollisionHandler; import de.heatup.mapengine.CollisionHandler;
public class PowerUp extends JComponent { public class PowerUp extends StaticObject {
private static final long serialVersionUID = 1L;
protected BufferedImage bf1;
protected Graphics2D g2d;
private Point currentGridPosition;
private int type;
public PowerUp() { private int pType;
public PowerUp(Point location) {
super('b', location);
Random rand = new Random(); Random rand = new Random();
CollisionHandler.addPowerUpObject(this); this.pType = rand.nextInt(2);
this.type = rand.nextInt(3); // 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());
}
} }