Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. public class Bomb {
  2. private int time;
  3. private int power;
  4. private int xPos;
  5. private int yPos;
  6. public Bomb(int xpos,int ypos, int power){
  7. xPos = xpos;
  8. yPos = ypos;
  9. bomberman.BomberMan.board[xPos][yPos] = 3;
  10. }
  11.  
  12. public void time(){
  13. time--;
  14. if(time==0){
  15. explode();
  16. }
  17. }
  18. public void explode(){
  19. boolean up = true;
  20. boolean down = true;
  21. boolean left = true;
  22. boolean right = true;
  23. for(int a=1;a<=power;a++){
  24. if(up){
  25. if(bomberman.BomberMan.board[xPos][yPos+a]==0){
  26. up = false;
  27. }
  28. else if(bomberman.BomberMan.board[xPos][yPos+a]==4){
  29. up = false;
  30. bomberman.BomberMan.board[xPos][yPos+a]=1;
  31. }
  32. else{
  33. bomberman.BomberMan.board[xPos][yPos+a]=2;
  34. }
  35. }
  36. if(down){
  37. if(bomberman.BomberMan.board[xPos][yPos-a]==0){
  38. down = false;
  39. }
  40. else if(bomberman.BomberMan.board[xPos][yPos-a]==4){
  41. down = false;
  42. bomberman.BomberMan.board[xPos][yPos-a]=1;
  43. }
  44. else{
  45. bomberman.BomberMan.board[xPos][yPos-a]=2;
  46. }
  47. }
  48. if(left){
  49. if(bomberman.BomberMan.board[xPos+a][yPos]==0){
  50. left = false;
  51. }
  52. else if(bomberman.BomberMan.board[xPos+a][yPos]==4){
  53. left = false;
  54. bomberman.BomberMan.board[xPos+a][yPos]=1;
  55. }
  56. else{
  57. bomberman.BomberMan.board[xPos+a][yPos]=2;
  58. }
  59. }
  60. if(right){
  61. if(bomberman.BomberMan.board[xPos-a][yPos]==0){
  62. right = false;
  63. }
  64. else if(bomberman.BomberMan.board[xPos-a][yPos]==4){
  65. right = false;
  66. bomberman.BomberMan.board[xPos-a][yPos]=1;
  67. }
  68. else{
  69. bomberman.BomberMan.board[xPos-a][yPos]=2;
  70. }}}
  71. //make it check alive.
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement