Fix Window.java
This commit is contained in:
parent
2855b634c9
commit
fb636c427e
@ -71,60 +71,57 @@ public class Window extends AbstractView {
|
|||||||
g.drawString(upperText, (int) (window.width /2 - (upperText.length() * 2.5)), 50);
|
g.drawString(upperText, (int) (window.width /2 - (upperText.length() * 2.5)), 50);
|
||||||
int width = window.width;
|
int width = window.width;
|
||||||
int height = window.height;
|
int height = window.height;
|
||||||
for (int abscisse = width / 24; abscisse< width +1; abscisse+= width / 24) {
|
int initialHeight = height / 12;
|
||||||
g.drawLine(abscisse, height /6, abscisse, height);
|
int initialWidth = width / 23;
|
||||||
if ( width * 0.44167 < abscisse && abscisse < width / 2) {
|
for(int abscisse = initialWidth; abscisse < width; abscisse += initialWidth) {
|
||||||
abscisse += width / 24 ;
|
g.drawLine(abscisse, initialHeight * 2, abscisse, height);
|
||||||
|
if(abscisse == initialWidth * 11)
|
||||||
|
abscisse += initialWidth;
|
||||||
}
|
}
|
||||||
}
|
for(int ordonnee = initialHeight * 2; ordonnee < height + 1; ordonnee += initialHeight) {
|
||||||
for (int ordonnee = height / 6; ordonnee< height +1; ordonnee+= height / 12) {
|
g.drawLine(initialWidth, ordonnee, initialWidth * 11, ordonnee);
|
||||||
g.drawLine(width / 24, ordonnee, (int) (width /2.18), ordonnee);
|
g.drawLine(initialWidth * 13, ordonnee, width - 4, ordonnee);
|
||||||
g.drawLine((int) (width / 1.845), ordonnee, width, ordonnee);
|
|
||||||
}
|
}
|
||||||
// TODO: 12/04/2021 Dessiner les navires
|
// TODO: 12/04/2021 Dessiner les navires
|
||||||
int initialHeight = height / 12;
|
|
||||||
for(int i = 1; i < 3; ++i) {
|
for(int i = 1; i < 3; ++i) {
|
||||||
int initialWidth = width / 24;
|
|
||||||
Player player = game.players[i-1];
|
Player player = game.players[i-1];
|
||||||
System.out.println(i);
|
|
||||||
for(Ship ship : player.getShips()) {
|
for(Ship ship : player.getShips()) {
|
||||||
int x1 = 0;
|
int x1 = i == 1 ? initialWidth : initialWidth * 13;
|
||||||
int y1 = 0;
|
int y1 = initialHeight * 2;
|
||||||
int shipWidth = 0;
|
int shipWidth = initialWidth;
|
||||||
int shipHeight = 0;
|
int shipHeight = initialHeight;
|
||||||
|
System.out.println(ship);
|
||||||
switch(ship.getDirection()) {
|
switch(ship.getDirection()) {
|
||||||
case DOWN:
|
case DOWN:
|
||||||
x1 = initialWidth * ship.getCoords().getRight();
|
x1 += initialWidth * ship.getCoords().getRight();
|
||||||
y1 = initialHeight * ship.getCoords().getLeft();
|
y1 += initialHeight * ship.getCoords().getLeft();
|
||||||
shipWidth = initialWidth;
|
|
||||||
shipHeight = initialHeight * ship.getSize();
|
shipHeight = initialHeight * ship.getSize();
|
||||||
|
g.setColor(new Color(255, 0, 0));
|
||||||
break;
|
break;
|
||||||
case UP:
|
case UP:
|
||||||
shipWidth = initialWidth;
|
x1 += initialWidth * ship.getCoords().getRight();
|
||||||
shipHeight = initialHeight * ship.getSize();
|
shipHeight = initialHeight * ship.getSize();
|
||||||
x1 = initialWidth * ship.getCoords().getRight();
|
y1 += initialHeight * ship.getCoords().getLeft() - shipHeight + initialHeight;
|
||||||
y1 = initialHeight * ship.getCoords().getLeft() - shipHeight;
|
g.setColor(new Color(255, 255, 0));
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
x1 = initialWidth * ship.getCoords().getRight();
|
x1 += initialWidth * ship.getCoords().getRight();
|
||||||
y1 = initialHeight * ship.getCoords().getLeft();
|
y1 += initialHeight * ship.getCoords().getLeft();
|
||||||
shipWidth = initialWidth * ship.getSize();
|
shipWidth = initialWidth * ship.getSize();
|
||||||
shipHeight = initialHeight;
|
g.setColor(new Color(0, 255, 0));
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
shipWidth = initialWidth * ship.getSize();
|
shipWidth = initialWidth * ship.getSize();
|
||||||
shipHeight = initialHeight;
|
x1 += initialWidth * ship.getCoords().getRight() - shipWidth + initialWidth;
|
||||||
x1 = initialWidth * ship.getCoords().getRight() - shipWidth;
|
y1 += initialHeight * ship.getCoords().getLeft();
|
||||||
y1 = initialHeight * ship.getCoords().getLeft();
|
g.setColor(new Color(0, 0, 255));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x1 += i == 1 ? initialWidth : initialWidth + width / 2;
|
|
||||||
y1 += height / 6;
|
|
||||||
g.setColor(new Color(255, 0, 0));
|
|
||||||
g.fillRect(x1, y1, shipWidth, shipHeight);
|
g.fillRect(x1, y1, shipWidth, shipHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(window.toString());
|
System.out.println(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user