Repository navigation
Conversation
trpfrog
reviewed
Jan 22, 2021
| public Background(){ | ||
| mv = MainView.getInstance(); | ||
|
|
||
| Path imagePath = Paths.get(".", "resource", "mini_game", "shonben_kozou", "background.jpg"); |
Owner
There was a problem hiding this comment.
background.jpg、アップロードされてなくないですか?
| g.setColor(Color.WHITE); | ||
| g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 25)); | ||
| g.drawString("score " + model.getCircles().getScore(), mv.getWidth() - 150, 20); | ||
| g.drawString(String.format("time %d.%02d",model.getGameTimer().getRemain()/100, model.getGameTimer().getRemain() % 100 ), 0, 20); |
Owner
There was a problem hiding this comment.
横に長いので
int timeRemaining = model.getGameTimer().getRemain();
String timerStr = String.format("%d.%02d", timeRemaining / 100, timeRemaining % 100);
g.drawString(timerStr, 0, 20);とすると読みやすくなると思います!
| this.model = model; | ||
| mv = MainView.getInstance(); | ||
| size = 20; | ||
| vy = r.nextDouble()*36 - 17; |
Owner
There was a problem hiding this comment.
実は Random#nextDouble() と Math.random() は完全に実装が同じなので、変数を増やさない意味では Math.random() の方を使用した方が良いように思われます。
Comment on lines
+37
to
+38
| setX(getX() + vx); | ||
| setY(getY() + vy); |
| } | ||
|
|
||
| public void addCircle(){ | ||
| if(model.getGameTimer().getCount() >= 300 && model.getGameTimer().getCount() % 5 == 0 && model.getGameTimer().getCount() < 1300) { |
Owner
There was a problem hiding this comment.
int count = model.getGameTimer().getCount(); とおいた方が
if(300 <= count && count < 1300 && count % 5 == 0) {
// do something
}と短く書けるので楽そう
Comment on lines
+45
to
+57
| public void repulsion(){ | ||
| if(getX() > mv.getWidth() - sizeX){ | ||
| direction = 1; | ||
| setX(2 * (double)mv.getWidth() - 3 * (double)sizeX - getX()); | ||
| vx = -vx; | ||
| } | ||
|
|
||
| if(getX() < sizeX){ | ||
| direction = -1; | ||
| setX(3 * (double)sizeX - getX()); | ||
| vx = -vx; | ||
| } | ||
| } |
Owner
There was a problem hiding this comment.
似たようなコードを置くならSymbolを継承してrepulsionを持ったSymbolクラスを作ってそれをKozouが継承する、というようなことをすると後で管理しやすくなると思います。あと単純に共通化でコピペミス由来のバグを減らせます。
| return p; | ||
| } | ||
|
|
||
| public int getdirection(){ |
| this.model = model; | ||
| sizeX = 112; | ||
| sizeY = 267; | ||
| direction = -1; // -1のとき右向き。 |
Owner
There was a problem hiding this comment.
これ、-1と1以外使わないならbooleanとかにした方が壊れなそうです。もしくは setAngleDegrees() などを使い向きを指定、 Math.cos(getAngleRadians()) で値を得るなど
またはenumで
public enum FaceTo {
LEFT(1), RIGHT(-1)
private int dirVector;
private FaceTo(int dir) {
this.dirVector = dir;
}
public int getDirVector() {
return dirVector;
}
}など
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
一通りできたので投げます。発表頑張ってください。