Added function stopper for Person (buged)
This commit is contained in:
parent
97271b1480
commit
44d3732275
@ -26,5 +26,6 @@ public class Cell {
|
||||
|
||||
public void paint(Graphics2D g) {
|
||||
g.setColor(color);
|
||||
g.fillOval(x*size, y*size, size, size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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());
|
||||
// }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user