Borschevskaya A.A. Lab Work 2 Hard #2

Merged
eegov merged 16 commits from lab2 into lab1 2022-11-07 10:48:13 +04:00
2 changed files with 10 additions and 4 deletions
Showing only changes of commit 4e3c6f6598 - Show all commits

View File

@ -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:

View File

@ -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);
}
}