Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. import biuoop.DrawSurface;
  2.  
  3. import java.awt.*;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6.  
  7. /**
  8. * A Shield Class.
  9. *
  10. * @author roy segev.
  11. */
  12. public class Shield implements Sprite {
  13. private int xstart;
  14. private int ystart;
  15. private Color color;
  16. private int width;
  17. private int hight;
  18. private List<Block> blockList;
  19. private List<Rectangle> listofrectangles = new ArrayList<>();
  20. private GameLevel gameLevel;
  21.  
  22. public Shield(int xstart, int ystart, Color color, int width, int hight,
  23. GameLevel gameLevel) {
  24. this.xstart = xstart;
  25. this.ystart = ystart;
  26. this.color = color;
  27. this.width = width;
  28. this.hight = hight;
  29. this.blockList = new ArrayList<>();
  30. this.gameLevel = gameLevel;
  31. }
  32.  
  33. public void createshild() {
  34. Counter numberofblockstoremove = new Counter(4 * 28 * 3);
  35. BlockRemover blockRemover1 = new BlockRemover(this.gameLevel, numberofblockstoremove);
  36. List<Block> shields = new ArrayList<>();
  37. for (int j = 0; j < 4; j++) {
  38. for (int i = 0; i < 28; i++) {
  39. for (int k = 0; k < 3; k++) {
  40. Rectangle r = new Rectangle(new Point(xstart + (i * 5) + (k * 270),
  41. ystart + (j * 5)), 5, 5);
  42. this.listofrectangles.add(r);
  43. Block b1 = new Block(r, this.color, 1, this.color);
  44. shields.add(b1);
  45. b1.addHitListener(blockRemover1);
  46. b1.addToGame(gameLevel);
  47.  
  48. }
  49. }
  50. }
  51. System.out.println("hello hell");
  52.  
  53. }
  54.  
  55. /**
  56. * @param d which represent our game.
  57. */
  58. public void drawOn(DrawSurface d) {
  59. // This is used to draw the black outlines outside the blocks.
  60. d.setColor(color);
  61. for (int i = 0; i < this.listofrectangles.size(); i++) {
  62.  
  63. d.drawRectangle((int) this.listofrectangles.get(i).getUpperLeft().getX() + 1,
  64. (int) this.listofrectangles.get(i).getUpperLeft().getY() + 1, (int) this.listofrectangles.get(i).getWidth(),
  65. (int) this.listofrectangles.get(i).getHeight());
  66. d.drawRectangle((int) this.listofrectangles.get(i).getUpperLeft().getX() - 1,
  67. (int) this.listofrectangles.get(i).getUpperLeft().getY() - 1, (int) this.listofrectangles.get(i).getWidth(),
  68. (int) this.listofrectangles.get(i).getHeight());
  69. // This is used to fill in the blocks with color.
  70. d.setColor(Color.blue);
  71. d.fillRectangle((int) this.listofrectangles.get(i).getUpperLeft().getX(),
  72. (int) this.listofrectangles.get(i).getUpperLeft().getY(), (int) this.listofrectangles.get(i).getWidth() + 1,
  73. (int) this.listofrectangles.get(i).getHeight() + 1);
  74.  
  75.  
  76. }
  77.  
  78.  
  79. }
  80.  
  81. /**
  82. * @Overide
  83. */
  84. public void timePassed() {
  85.  
  86. }
  87.  
  88.  
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement