Small fixes
This commit is contained in:
parent
961f5a3b0e
commit
05f2ac726d
@ -35,10 +35,25 @@ public class EventMoveToCell extends Cell {
|
||||
public void moveToMap() {
|
||||
WindowOfFreeMove.getMap().setIdExit(id);
|
||||
WindowOfFreeMove.setMap(this.map);
|
||||
WindowOfFreeMove.getMap().getPerson().setDirectionSight(idToDirectionSight());
|
||||
WindowOfFreeMove.getMap().setIdExit(id);
|
||||
WindowOfFreeMove.paintMapOnWindow();
|
||||
}
|
||||
|
||||
private int idToDirectionSight(){
|
||||
switch (directionOut){
|
||||
case 1:
|
||||
return 0;
|
||||
case 2:
|
||||
return 1;
|
||||
case 3:
|
||||
return 2;
|
||||
case 4:
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics2D g) {
|
||||
super.paint(g);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.IOException;
|
||||
@ -26,7 +27,7 @@ public class ImagePerson {
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
for (int i = 0; i < animationOfMoving.length; i++){
|
||||
animationOfMoving[i] = Toolkit.getDefaultToolkit().createImage(getClass().getResource(animationOfMovingNames[i]));
|
||||
animationOfMoving[i] = new ImageIcon(getClass().getResource(animationOfMovingNames[i])).getImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,13 +22,14 @@ public class Person extends Cell {
|
||||
this.directionMove = directionMove;
|
||||
}
|
||||
|
||||
public void setImagePerson(String name, Rectangle[] rectangles) {
|
||||
this.imagePerson = new ImagePerson(name, rectangles);
|
||||
public void setDirectionSight(int directionSight) {
|
||||
if ((directionSight >= 0) && (directionSight <= 3))
|
||||
this.directionSight = directionSight;
|
||||
}
|
||||
|
||||
public void setAnimation(String[] names){
|
||||
this.imagePerson.setAnimationOfMoving(names);
|
||||
}
|
||||
public void setImagePerson(String name, Rectangle[] rectangles) { this.imagePerson = new ImagePerson(name, rectangles); }
|
||||
|
||||
public void setAnimation(String[] names) { this.imagePerson.setAnimationOfMoving(names); }
|
||||
|
||||
public void move() {
|
||||
int x = this.getX();
|
||||
@ -84,7 +85,8 @@ public class Person extends Cell {
|
||||
else {
|
||||
switch (directionMove) {
|
||||
case WindowOfFreeMove.KEY_LEFT:
|
||||
g.drawImage(imagePerson.getAnimationOfMoving()[3], getX()*WindowOfFreeMove.CELL_SIZE, getY()*WindowOfFreeMove.CELL_SIZE, null);
|
||||
g.drawImage(imagePerson.getAnimationOfMoving()[3], getX() * WindowOfFreeMove.CELL_SIZE, getY() * WindowOfFreeMove.CELL_SIZE,
|
||||
WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null);
|
||||
break;
|
||||
case WindowOfFreeMove.KEY_RIGHT:
|
||||
g.drawImage(imagePerson.getAnimationOfMoving()[1], getX() * WindowOfFreeMove.CELL_SIZE, getY() * WindowOfFreeMove.CELL_SIZE, null);
|
||||
|
||||
@ -122,10 +122,11 @@ public class WindowOfFreeMove extends JFrame {
|
||||
|
||||
setMap(m1);
|
||||
map.createMap();
|
||||
//
|
||||
|
||||
// String s1 = "> Test";
|
||||
// for (int i = 0; i < s1.length() + 1; i++) {
|
||||
// lp.remove(dialogBar);
|
||||
//
|
||||
//
|
||||
// final String text = s1.substring(0, i);
|
||||
// JPanel jf = new JPanel() {
|
||||
// Font f = new Font("Times New Roman", Font.ITALIC, 50);
|
||||
//
|
||||
@ -134,7 +135,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
// super.paint(g);
|
||||
// g.setColor(Color.green);
|
||||
// g.setFont(f);
|
||||
// g.drawString("> Test", 10, 50);
|
||||
// g.drawString(text, 10, 50);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
@ -146,6 +147,9 @@ public class WindowOfFreeMove extends JFrame {
|
||||
// dialogBar.setVisible(true);
|
||||
//setCanPersonMove(false);
|
||||
// lp.add(jf, JLayeredPane.POPUP_LAYER);
|
||||
//
|
||||
// sleep(300);
|
||||
// }
|
||||
|
||||
while (true) {
|
||||
map.getPerson().move();
|
||||
@ -170,9 +174,9 @@ public class WindowOfFreeMove extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
protected static void sleep() {
|
||||
protected static void sleep(int i) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(i);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user