added different main character

This commit is contained in:
musilto9 2020-03-31 11:50:56 +02:00
parent d2646790b3
commit 2f4d788874
20 changed files with 24 additions and 13 deletions

View File

@ -38,7 +38,7 @@ public class InteractionCell extends Cell {
public void readDialogFile(String name) {
try {
File dialogFile = new File("src/main/resources/" + name + ".txt");
File dialogFile = new File("src/main/resources/dialogs/" + name + ".txt");
scanner = new Scanner(dialogFile);
readNextLine();
} catch (FileNotFoundException e) {

View File

@ -5,10 +5,13 @@ import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class ImagePerson {
private BufferedImage image;
private BufferedImage[] imagesOfDirection;
private int subimageWidth;
private int subimageHeight;
public void setAllImagesOfDirection(Rectangle[] rectangles){
imagesOfDirection = new BufferedImage[12];
@ -16,14 +19,23 @@ public class ImagePerson {
if (rectangles.length < 12)
throw new IllegalArgumentException();
for (int i = 0; i < imagesOfDirection.length; i++) {
imagesOfDirection[i] = image.getSubimage(rectangles[i].x, rectangles[i].y, rectangles[i].height, rectangles[i].width);
int count = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
imagesOfDirection[count] = image.getSubimage(subimageWidth * i, subimageHeight * j, subimageWidth, subimageHeight);
count++;
}
}
}
public ImagePerson(String name, Rectangle[] rectangles) {
try {
image = ImageIO.read(new File("src/main/resources/" + name));
File dialogFile = new File("src/main/resources/characters/" + name + ".txt");
Scanner scanner = new Scanner(dialogFile);
String[] subimageSize = scanner.nextLine().split(" ");
subimageWidth = Integer.parseInt(subimageSize[0]);
subimageHeight = Integer.parseInt(subimageSize[1]);
image = ImageIO.read(new File("src/main/resources/characters/" + scanner.nextLine()));
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -6,11 +6,8 @@ import ruscz.game.gameOfProd.Map.Map;
import ruscz.game.gameOfProd.Map.MapPainter;
import ruscz.game.gameOfProd.Sounds.MusicManager;
import javax.sound.midi.MidiChannel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.LinkedList;
@ -154,27 +151,27 @@ public class WindowOfFreeMove extends JFrame {
}
Map m1 = Map.loadMapFromFile("m1", this);
m1.getPerson().setImagePerson("mainpng.png", rec);
m1.getPerson().setImagePerson("main", rec);
m1.setName("m1");
Map m2 = Map.loadMapFromFile("m2", this);
m2.getPerson().setImagePerson("mainpng.png", rec);
m2.getPerson().setImagePerson("main", rec);
m2.setName("m2");
Map m3 = Map.loadMapFromFile("m3", this);
m3.getPerson().setImagePerson("mainpng.png", rec);
m3.getPerson().setImagePerson("main", rec);
m3.setName("m3");
Map m4 = Map.loadMapFromFile("m4", this);
m4.getPerson().setImagePerson("mainpng.png", rec);
m4.getPerson().setImagePerson("main", rec);
m4.setName("m4");
Map m5 = Map.loadMapFromFile("m5", this);
m5.getPerson().setImagePerson("mainpng.png", rec);
m5.getPerson().setImagePerson("main", rec);
m5.setName("m5");
Map m6 = Map.loadMapFromFile("m6", this);
m6.getPerson().setImagePerson("mainpng.png", rec);
m6.getPerson().setImagePerson("main", rec);
m6.setName("m6");
mapLinkedList = new LinkedList<>();

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -0,0 +1,2 @@
32 48
main.png

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB