mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 08:39:45 +02:00
fuuuu
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user