Added function stopper for Person (buged)

This commit is contained in:
iryupnik 2020-03-04 13:16:58 +02:00
parent 97271b1480
commit 44d3732275
4 changed files with 12 additions and 4 deletions

View File

@ -26,5 +26,6 @@ public class Cell {
public void paint(Graphics2D g) {
g.setColor(color);
g.fillOval(x*size, y*size, size, size);
}
}

View File

@ -36,6 +36,7 @@ public class EventMoveToCell extends Cell {
WindowOfFreeMove.getMap().setIdExit(id);
WindowOfFreeMove.setMap(this.map);
WindowOfFreeMove.getMap().setIdExit(id);
WindowOfFreeMove.getMap().getPerson().stopPerson();
WindowOfFreeMove.paintMapOnWindow();
WindowOfFreeMove.repaintCanvas();
}

View File

@ -88,6 +88,10 @@ public class Person extends Cell {
directionMove = 0;
}
}
public void stopPerson(){
directionMove = 0;
directionMoveLast = 0;
}
public boolean isInPerson(int x, int y) {
return this.getX() == x && this.getY() == y;

View File

@ -74,7 +74,7 @@ public class WindowOfFreeMove extends JFrame {
inputTimer = new Timer(10, new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (!map.getPerson().getIsMoving()) {
if (!map.getPerson().getIsMoving() && canPersonMove) {
map.getPerson().setDirectionMove(nextMove);
}
}
@ -83,7 +83,7 @@ public class WindowOfFreeMove extends JFrame {
addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (!map.getPerson().getIsMoving()) {
if (!map.getPerson().getIsMoving() && canPersonMove) {
map.getPerson().setDirectionMove(nextMove);
}
}
@ -92,8 +92,10 @@ public class WindowOfFreeMove extends JFrame {
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (canPersonMove) {
nextMove = e.getKeyCode();
inputTimer.start();
}
// if (canPersonMove && !map.getPerson().getIsMoving() && preventDoubleMove) {
// map.getPerson().setDirectionMove(e.getKeyCode());
// }