Hard_version
This commit is contained in:
parent
1ebbf7412c
commit
1c11f7062c
@ -40,7 +40,7 @@ public abstract class AbstractMap {
|
||||
int x = _random.nextInt(0, 10);
|
||||
int y = _random.nextInt(0, 10);
|
||||
_drawingObject.SetObject(x, y, _width, _height);
|
||||
return CheckCollision();
|
||||
return !CheckCollision();
|
||||
}
|
||||
|
||||
private void DrawMapWithObject()
|
||||
@ -93,9 +93,9 @@ public abstract class AbstractMap {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int y = startY; y <= endY; y++)
|
||||
for (int y = startY; y <= endY + 1; y++)
|
||||
{
|
||||
for (int x = startX; x <= endX; x++)
|
||||
for (int x = startX; x <= endX + 1; x++)
|
||||
{
|
||||
try {
|
||||
if (_map[x][y] == _barrier)
|
||||
|
@ -3,10 +3,12 @@ package com.example.doubledeckerbus;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingBus {
|
||||
public EntityBus Bus;
|
||||
|
||||
public DrawingDoors Doors;
|
||||
public IDrawingDoors Doors;
|
||||
|
||||
public EntityBus getBus() {
|
||||
return Bus;
|
||||
@ -22,8 +24,13 @@ public class DrawingBus {
|
||||
|
||||
public DrawingBus(int speed, float weight, Color bodyColor, int countOfDoors) {
|
||||
Bus = new EntityBus(speed, weight, bodyColor);
|
||||
Doors = new DrawingDoors();
|
||||
switch (new Random().nextInt(3)) {
|
||||
case 0 -> Doors = new DrawingTriangleDoors();
|
||||
case 1 -> Doors = new DrawingDoors();
|
||||
case 2 -> Doors = new DrawingEllipsoidDoors();
|
||||
}
|
||||
Doors.setCountOfDoors(countOfDoors);
|
||||
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height) {
|
||||
@ -81,7 +88,6 @@ public class DrawingBus {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gc.setFill(Bus.BodyColor);
|
||||
gc.fillRect(_startPosX, _startPosY + 10, 100, 30);
|
||||
|
||||
|
@ -3,10 +3,11 @@ package com.example.doubledeckerbus;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class DrawingDoors {
|
||||
public class DrawingDoors implements IDrawingDoors {
|
||||
private CountOfDoors _countOfDoors;
|
||||
|
||||
public void DrawDoors(GraphicsContext gc, int _startPosX, int _startPosY) {
|
||||
@Override
|
||||
public void DrawDoors(GraphicsContext gc, float _startPosX, float _startPosY) {
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillRect(_startPosX, _startPosY + 20, 10, 20);
|
||||
gc.fillRect(_startPosX + 20, _startPosY + 20, 10, 20);
|
||||
@ -19,13 +20,13 @@ public class DrawingDoors {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCountOfDoors(int number) {
|
||||
@Override
|
||||
public void setCountOfDoors(int count) {
|
||||
for (CountOfDoors item: CountOfDoors.values()) {
|
||||
if (item.getId() == number) {
|
||||
if (item.getId() == count) {
|
||||
_countOfDoors = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.example.doubledeckerbus;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class DrawingEllipsoidDoors implements IDrawingDoors{
|
||||
private CountOfDoors _countOfDoors;
|
||||
|
||||
@Override
|
||||
public void DrawDoors(GraphicsContext gc, float _startPosX, float _startPosY) {
|
||||
gc.setFill(Color.GRAY);
|
||||
gc.fillOval(_startPosX, _startPosY + 20, 10, 20);
|
||||
gc.fillOval(_startPosX + 20, _startPosY + 20, 10, 20);
|
||||
gc.fillOval(_startPosX + 40, _startPosY + 20, 10, 20);
|
||||
if (_countOfDoors.getId() >= 4) {
|
||||
gc.fillOval(_startPosX + 60, _startPosY + 20, 10, 20);
|
||||
}
|
||||
if (_countOfDoors.getId() >= 5) {
|
||||
gc.fillOval(_startPosX + 80, _startPosY + 20, 10, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountOfDoors(int count) {
|
||||
for (CountOfDoors item: CountOfDoors.values()) {
|
||||
if (item.getId() == count) {
|
||||
_countOfDoors = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.example.doubledeckerbus;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class DrawingTriangleDoors implements IDrawingDoors{
|
||||
private CountOfDoors _countOfDoors;
|
||||
|
||||
public void FillTriangle(GraphicsContext gc, float x, float y) {
|
||||
gc.fillPolygon(new double[] {(double) x, (double) (x + 5), (double) (x + 10)},
|
||||
new double[] {(double) y + 20, (double) (y), (double) y + 20}, 3) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawDoors(GraphicsContext gc, float _startPosX, float _startPosY) {
|
||||
gc.setFill(Color.BLUE);
|
||||
FillTriangle(gc, _startPosX, _startPosY + 20);
|
||||
FillTriangle(gc,_startPosX + 20, _startPosY + 20);
|
||||
FillTriangle(gc,_startPosX + 40, _startPosY + 20);
|
||||
if (_countOfDoors.getId() >= 4) {
|
||||
FillTriangle(gc, _startPosX + 60, _startPosY + 20);
|
||||
}
|
||||
if (_countOfDoors.getId() >= 5) {
|
||||
FillTriangle(gc, _startPosX + 80, _startPosY + 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountOfDoors(int count) {
|
||||
for (CountOfDoors item: CountOfDoors.values()) {
|
||||
if (item.getId() == count) {
|
||||
_countOfDoors = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.example.doubledeckerbus;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public interface IDrawingDoors {
|
||||
void DrawDoors(GraphicsContext gc, float _startPosX, float _startPosY);
|
||||
void setCountOfDoors(int count);
|
||||
}
|
@ -32,7 +32,7 @@ public class WaterMap extends AbstractMap{
|
||||
|
||||
@Override
|
||||
protected void DrawRoadPart(int i, int j) {
|
||||
if (_random.nextInt(0,10) == 9) {
|
||||
if (_random.nextInt(0,20) == 9) {
|
||||
gc.setFill(Color.GREEN);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user