From 4e3c6f6598cf6909bc1ee075df45835bb76840a8 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 23 Oct 2022 17:23:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F,=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=20SimpleMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/AbstractMap.java | 4 +++- src/main/java/SimpleMap.java | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/AbstractMap.java b/src/main/java/AbstractMap.java index c0af228..773a30e 100644 --- a/src/main/java/AbstractMap.java +++ b/src/main/java/AbstractMap.java @@ -26,8 +26,11 @@ public abstract class AbstractMap { } return DrawMapWithObject(); } + public Image MoveObject(Direction direction) { + if (drawingObject == null) + return null; boolean flag = true; float step = drawingObject.getStep(); @@ -47,7 +50,6 @@ public abstract class AbstractMap { int x2_obj_current = (int)(right / size_x); int y2_obj_current = (int)(bottom / size_y); - // Проверка возможности перемещения switch (direction) { case Left: diff --git a/src/main/java/SimpleMap.java b/src/main/java/SimpleMap.java index 984b144..0cc26ec 100644 --- a/src/main/java/SimpleMap.java +++ b/src/main/java/SimpleMap.java @@ -2,7 +2,7 @@ import java.awt.*; public class SimpleMap extends AbstractMap{ private final Color barrierColor = Color.BLACK; - private final Color roadColor = Color.GRAY; + private final Color roadColor = Color.DARK_GRAY; @Override protected void GenerateMap() { map = new int[100][100]; @@ -31,12 +31,16 @@ public class SimpleMap extends AbstractMap{ @Override protected void DrawRoadPart(Graphics2D g, int i, int j) { g.setColor(roadColor); - g.fillRect(i * (int)size_x, j * (int)size_y, (int)size_x, (int)size_y); + int new_size_x = Math.round(size_x); + int new_size_y = Math.round(size_y); + g.fillRect(i * new_size_x, j * new_size_y, new_size_x, new_size_y); } @Override protected void DrawBarrierPart(Graphics2D g, int i, int j) { g.setColor(barrierColor); - g.fillRect(i * (int)size_x, j * (int)size_y, (int)size_x, (int)size_y); + int new_size_x = Math.round(size_x); + int new_size_y = Math.round(size_y); + g.fillRect(i * new_size_x, j * new_size_y, new_size_x, new_size_y); } }