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) {
|
public void paint(Graphics2D g) {
|
||||||
g.setColor(color);
|
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.getMap().setIdExit(id);
|
||||||
WindowOfFreeMove.setMap(this.map);
|
WindowOfFreeMove.setMap(this.map);
|
||||||
WindowOfFreeMove.getMap().setIdExit(id);
|
WindowOfFreeMove.getMap().setIdExit(id);
|
||||||
|
WindowOfFreeMove.getMap().getPerson().stopPerson();
|
||||||
WindowOfFreeMove.paintMapOnWindow();
|
WindowOfFreeMove.paintMapOnWindow();
|
||||||
WindowOfFreeMove.repaintCanvas();
|
WindowOfFreeMove.repaintCanvas();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,6 +88,10 @@ public class Person extends Cell {
|
|||||||
directionMove = 0;
|
directionMove = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void stopPerson(){
|
||||||
|
directionMove = 0;
|
||||||
|
directionMoveLast = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInPerson(int x, int y) {
|
public boolean isInPerson(int x, int y) {
|
||||||
return this.getX() == x && this.getY() == y;
|
return this.getX() == x && this.getY() == y;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
inputTimer = new Timer(10, new ActionListener() {
|
inputTimer = new Timer(10, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
if (!map.getPerson().getIsMoving()) {
|
if (!map.getPerson().getIsMoving() && canPersonMove) {
|
||||||
map.getPerson().setDirectionMove(nextMove);
|
map.getPerson().setDirectionMove(nextMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
addKeyListener(new KeyAdapter() {
|
addKeyListener(new KeyAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent e) {
|
public void keyTyped(KeyEvent e) {
|
||||||
if (!map.getPerson().getIsMoving()) {
|
if (!map.getPerson().getIsMoving() && canPersonMove) {
|
||||||
map.getPerson().setDirectionMove(nextMove);
|
map.getPerson().setDirectionMove(nextMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +92,10 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
addKeyListener(new KeyAdapter() {
|
addKeyListener(new KeyAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (canPersonMove) {
|
||||||
nextMove = e.getKeyCode();
|
nextMove = e.getKeyCode();
|
||||||
inputTimer.start();
|
inputTimer.start();
|
||||||
|
}
|
||||||
// if (canPersonMove && !map.getPerson().getIsMoving() && preventDoubleMove) {
|
// if (canPersonMove && !map.getPerson().getIsMoving() && preventDoubleMove) {
|
||||||
// map.getPerson().setDirectionMove(e.getKeyCode());
|
// map.getPerson().setDirectionMove(e.getKeyCode());
|
||||||
// }
|
// }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user