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