Small fixes
This commit is contained in:
parent
92d11b869f
commit
5269320951
@ -1,5 +1,5 @@
|
||||
public class Game {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
public static void main(String[] args) {
|
||||
new WindowOfFreeMove().start(); }
|
||||
}
|
||||
|
||||
|
||||
@ -121,23 +121,23 @@ public class Map {
|
||||
switch (cell.getDirectionOut()) {
|
||||
case 1:
|
||||
person.set(cell.getX(), cell.getY() - 1);
|
||||
person.directionMoveLast = 0;
|
||||
person.directionSight = 2;
|
||||
person.setDirectionMoveLast(0);
|
||||
person.setDirectionSight(2);
|
||||
break;
|
||||
case 2:
|
||||
person.set(cell.getX() + 1, cell.getY());
|
||||
person.directionMoveLast = 0;
|
||||
person.directionSight = 3;
|
||||
person.setDirectionMoveLast(0);
|
||||
person.setDirectionSight(3);
|
||||
break;
|
||||
case 3:
|
||||
person.set(cell.getX(), cell.getY() + 1);
|
||||
person.directionMoveLast = 0;
|
||||
person.directionSight = 0;
|
||||
person.setDirectionMoveLast(0);
|
||||
person.setDirectionSight(0);
|
||||
break;
|
||||
case 4:
|
||||
person.set(cell.getX() - 1, cell.getY());
|
||||
person.directionMoveLast = 0;
|
||||
person.directionSight = 1;
|
||||
person.setDirectionMoveLast(0);
|
||||
person.setDirectionSight(1);
|
||||
break;
|
||||
default:
|
||||
person.set(-1, -1);
|
||||
|
||||
@ -4,20 +4,30 @@ import java.awt.*;
|
||||
public class Person extends Cell {
|
||||
private ImagePerson imagePerson;
|
||||
private int directionMove;
|
||||
public int directionSight;
|
||||
public int directionMoveLast;
|
||||
boolean ready = true;
|
||||
private int directionSight;
|
||||
private int directionMoveLast;
|
||||
private boolean ready;
|
||||
|
||||
public void setDirectionMoveLast(int directionMoveLast) {
|
||||
this.directionMoveLast = directionMoveLast;
|
||||
}
|
||||
|
||||
public void setDirectionSight(int directionSight) {
|
||||
this.directionSight = directionSight;
|
||||
}
|
||||
|
||||
public Person() {
|
||||
super(-1, -1, WindowOfFreeMove.CELL_SIZE, Color.RED);
|
||||
this.directionMove = 0;
|
||||
this.directionSight = 3;
|
||||
this.ready = true;
|
||||
}
|
||||
|
||||
public Person(int x, int y) {
|
||||
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.RED);
|
||||
this.directionMove = 0;
|
||||
this.directionSight = 3;
|
||||
this.ready = true;
|
||||
}
|
||||
|
||||
public void setDirectionMove(int directionMove) {
|
||||
@ -71,8 +81,7 @@ public class Person extends Cell {
|
||||
imagePerson.getAnimationOfMoving()[2].flush();
|
||||
imagePerson.getAnimationOfMoving()[3].flush();
|
||||
ready = true;
|
||||
}
|
||||
else if (directionMove != 0 && WindowOfFreeMove.getMap().isBusyCell(x, y)) {
|
||||
} else if (directionMove != 0 && WindowOfFreeMove.getMap().isBusyCell(x, y)) {
|
||||
directionMoveLast = 0;
|
||||
}
|
||||
directionMove = 0;
|
||||
|
||||
@ -86,7 +86,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
public void start() throws InterruptedException {
|
||||
public void start() {
|
||||
String[] strings = {"main-walk-up-long.gif", "main-walk-right-long.gif", "main-walk-down-long.gif", "main-walk-left-long.gif"};
|
||||
Rectangle[] rec = new Rectangle[4];
|
||||
for (int i = 0; i < rec.length; i++){
|
||||
@ -151,7 +151,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
// lp.add(jf, JLayeredPane.POPUP_LAYER);
|
||||
|
||||
while (true) {
|
||||
Thread.sleep(1);
|
||||
//Thread.sleep();
|
||||
map.getPerson().move();
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user