Skip to content

Домашняя работа #1#1

Open
abercromb wants to merge 2 commits intomasterfrom
lesson1
Open

Домашняя работа #1#1
abercromb wants to merge 2 commits intomasterfrom
lesson1

Conversation

@abercromb
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@Ivan-Igorevich Ivan-Igorevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом, всё хорошо, ожидаемо не очень хорошо сделан фон, но его и нельзя было сделать хорошо, но неожиданно, в неправильном месте обработка мыши...

Comment thread GameCanvas.java

GameCanvas(MainCircles gameWindow) {
this.gameWindow = gameWindow;
addMouseListener(new MouseController(this));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

канва умеет рисоваться. канва ничего не знает о периферийных устройствах. нам нужно оставить её в максимально абстрагированном виде, чтобы мочь использовать в другом проекте. В Вашем случае, мы вынуждаем другой проект использовать мышку, хотя там может быть, например, клавиатура

Comment thread MainCircles.java
private static final int WINDOW_WIDTH = 800;
private static final int WINDOW_HEIGHT = 600;
Sprite[] sprites = new Sprite[10];
BackGround backGround = new BackGround(100);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не было желания сделать его спрайтом?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделать BackGround спрайтом? Не было) Как это вообще)

Comment thread MouseController.java
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class MouseController extends MouseAdapter {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не обязательно было создавать прям свой отдельный контроллер для такой простой задачи, адаптера было достаточно

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зато в конструкторе канвы на вызов обработчика одна строчка, а не забор

Comment thread GameCanvas.java
public int getRight() { return getWidth() - 1; }
public int getTop() { return 0; }
public int getBottom() { return getHeight() - 1; }
public MainCircles getGameWindow(){return gameWindow;};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

чую неладное, зачем расприватили?

Comment thread MouseController.java

if (e.getButton() == MouseEvent.BUTTON1)
{
canvas.getGameWindow().addSprite();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Самое интересное, что в Java 1 преподаватель делает цепочки вот такие

board.getGame().getCurrentPlayer().getPlayerSign()

Из чего делаешь вывод, что так делать и нужно)

Comment thread MainCircles.java

}

//Удаление шарика из массива
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на мой взгляд дороговато каждый раз пересоздавать массив и по + и по -... но об этом мы поговорим на уроке.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants