Guest User

Untitled

a guest
Feb 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. public Stone(int type, Position pos) {
  2. this.pos = pos;
  3. this.type = type;
  4. switch(this.type) {
  5. case 1:
  6. value = 5;
  7. color = Color.LIGHT_GRAY;
  8. break;
  9. case 2:
  10. value = 10;
  11. color = Color.orange;
  12. break;
  13. case 3:
  14. value = 15;
  15. color = Color.green;
  16. break;
  17. }
  18. }
  19.  
  20. private void drawStones(Graphics2D g2) {
  21. stones = view.getGame().getLevel().getStones();
  22.  
  23. for (int i = 0; i < stones.length; i++) {
  24. for (int j = 0; j < stones[1].length; j++) {
  25. int x_position = (int) stones[i][j].getPosition().getX();
  26. int y_position = (int) stones[i][j].getPosition().getY();
  27. if(stones[i][j].getType() >= 1) {
  28. g2.setColor(stones[i][j].getColor());
  29. g2.fillRoundRect(x_position, y_position,
  30. (int) ((double)Constants.SCREEN_WIDTH/Constants.SQUARES_X)-2,
  31. (int) ((double)Constants.SCREEN_HEIGHT/Constants.SQUARES_Y)-2 ,1,1);
  32. }
  33. }
  34. }
  35. }
  36.  
  37. private void updateStonesAndScore() {
  38. int posLine = ball.getHitStonePosition().getLine();
  39. int posColumn = ball.getHitStonePosition().getColumn();
  40. score = score + stones[posLine][posColumn].getValue();
  41. System.out.println(stones[posLine][posColumn].getType());
  42. stones[posLine][posColumn].setColor(stones[posLine][posColumn].getColor());
  43. stones[posLine][posColumn].setType(stones[posLine][posColumn].getType()-1);
  44. }
Add Comment
Please, Sign In to add comment