Jawa / Говнокод #28697 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
package sample.Model;

import static sample.Main.*;
import static sample.Model.Move.countEnemy;

class EnemyBang {
    private static double here[] = {0, 0, 0, 0};

    static void create() {
        int speedOfCreate = 150;
        if (countEnemy % speedOfCreate == 0) EnemyBang.start();
        else if (countEnemy % speedOfCreate == speedOfCreate - 1) EnemyBang.finish();
        else {
            EnemyBang.move();
            EnemyBang.heroPain();
        }
    }

    private static void whereIsPlayer(){
        if (image.getY()<enemy.getY()) here[0] = enemy.getY()-image.getY(); //w
        if (image.getY()>enemy.getY()) here[1] = image.getY()-enemy.getY();//s
        if (image.getX()<enemy.getX()) here[2] = enemy.getX()-image.getX();//a
        if (image.getX()>enemy.getX()) here[3] = image.getX()-enemy.getX();//d
    }

    private static void start() {
        bang.setX(enemy.getX()+10);
        bang.setY(enemy.getY()+10);
        bang.setVisible(true);
        here[0] = 0;
        here[1] = 0;
        here[2] = 0;
        here[3] = 0;
        EnemyBang.whereIsPlayer();
    }

    private static void finish() {
        bang.setVisible(false);

    }

    private static void heroPain() {
        int pain = 40;
        Health.change(bang, pain);
            if (CollisionObjects.check(bang, image)) {
                bang.setVisible(false);
                explosive.stop();
                explosive.play();
            }
        }

    private static void move(){
        int i = 0;
        int mover = 5;
        for (double a: here) {
            if (a != 0) i++;
        }
        if (i > 1) mover /= Math.sqrt(2);
        if (here[0]!=0 && ((here[2]/here[0]<=Math.sqrt(3) && here[2]!=0)||(here[3]/here[0]<=Math.sqrt(3) && here[3]!=0)
                || (here[2]==0 && here[3]==0))) {
            bang.setY(bang.getY() - mover);
        }
        if (here[1]!=0 && ((here[2]/here[1]<=Math.sqrt(3) && here[2]!=0)||(here[3]/here[1]<=Math.sqrt(3) && here[3]!=0)
                || (here[2]==0 && here[3]==0))) {
            bang.setY(bang.getY() + mover);
        }
        if (here[2]!=0 && ((here[0]/here[2]<=Math.sqrt(3) && here[0]!=0)||(here[1]/here[2]<=Math.sqrt(3) && here[1]!=0)
                || (here[1]==0 && here[0]==0))) {
            bang.setX(bang.getX() - mover);
        }
        if (here[3]!=0 && ((here[0]/here[3]<=Math.sqrt(3) && here[0]!=0)||(here[1]/here[3]<=Math.sqrt(3) && here[1]!=0)
                || (here[1]==0 && here[0]==0))) {
            bang.setX(bang.getX() + mover);
        }
    }
}

Всем привет, это моя третья программа, друг который мне помогает учиться отправил меня на этот сайт - сказал сюда отправить, потому что хуже кода он не видел. Подскажите, что тут не так? Он просто не комментирует

Запостил: Tkachenko1380 Tkachenko1380, (Updated )

Комментарии (9) RSS

  • паттерн «В смысле, в Жабе нет глобалок и свободных функций? А если найду?»
    Ответить
  • Добрый день.

    Действительно, на этом сайте поощряется спокойное обсуждение плюсов и минусов програмного обеспечения. И без лишних эмоций.

    Статические переменные (особенно из чужих классов) это плохо. Что такое "here"? Четырехмерное пространство? Почему void where?
    Ответить
  • > потому что хуже кода он не видел
    Какой анскилл)))
    Ответить
  • >друг который мне помогает учиться

    Нельзя ли поподробней, в каком плане помогает? Поддерживает морально, или манально?
    Ответить

Добавить комментарий

Из-за тебя ушел bormand, guest!

    А не использовать ли нам bbcode?


    8