Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import biuoop.DrawSurface;
- import java.awt.*;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * A Shield Class.
- *
- * @author roy segev.
- */
- public class Shield implements Sprite {
- private int xstart;
- private int ystart;
- private Color color;
- private int width;
- private int hight;
- private List<Block> blockList;
- private List<Rectangle> listofrectangles = new ArrayList<>();
- private GameLevel gameLevel;
- public Shield(int xstart, int ystart, Color color, int width, int hight,
- GameLevel gameLevel) {
- this.xstart = xstart;
- this.ystart = ystart;
- this.color = color;
- this.width = width;
- this.hight = hight;
- this.blockList = new ArrayList<>();
- this.gameLevel = gameLevel;
- }
- public void createshild() {
- Counter numberofblockstoremove = new Counter(4 * 28 * 3);
- BlockRemover blockRemover1 = new BlockRemover(this.gameLevel, numberofblockstoremove);
- List<Block> shields = new ArrayList<>();
- for (int j = 0; j < 4; j++) {
- for (int i = 0; i < 28; i++) {
- for (int k = 0; k < 3; k++) {
- Rectangle r = new Rectangle(new Point(xstart + (i * 5) + (k * 270),
- ystart + (j * 5)), 5, 5);
- this.listofrectangles.add(r);
- Block b1 = new Block(r, this.color, 1, this.color);
- shields.add(b1);
- b1.addHitListener(blockRemover1);
- b1.addToGame(gameLevel);
- }
- }
- }
- System.out.println("hello hell");
- }
- /**
- * @param d which represent our game.
- */
- public void drawOn(DrawSurface d) {
- // This is used to draw the black outlines outside the blocks.
- d.setColor(color);
- for (int i = 0; i < this.listofrectangles.size(); i++) {
- d.drawRectangle((int) this.listofrectangles.get(i).getUpperLeft().getX() + 1,
- (int) this.listofrectangles.get(i).getUpperLeft().getY() + 1, (int) this.listofrectangles.get(i).getWidth(),
- (int) this.listofrectangles.get(i).getHeight());
- d.drawRectangle((int) this.listofrectangles.get(i).getUpperLeft().getX() - 1,
- (int) this.listofrectangles.get(i).getUpperLeft().getY() - 1, (int) this.listofrectangles.get(i).getWidth(),
- (int) this.listofrectangles.get(i).getHeight());
- // This is used to fill in the blocks with color.
- d.setColor(Color.blue);
- d.fillRectangle((int) this.listofrectangles.get(i).getUpperLeft().getX(),
- (int) this.listofrectangles.get(i).getUpperLeft().getY(), (int) this.listofrectangles.get(i).getWidth() + 1,
- (int) this.listofrectangles.get(i).getHeight() + 1);
- }
- }
- /**
- * @Overide
- */
- public void timePassed() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement