solved the animation problem which was irrelevant but i solved it

This commit is contained in:
2020-08-19 23:13:17 +02:00
parent 818786cfba
commit 8b8e5f6c92
12 changed files with 48 additions and 58 deletions

View File

@@ -1,19 +1,25 @@
import javax.imageio.ImageIO;
import javax.swing.text.Position;
import java.awt.*;
import java.io.File;
import java.io.IOException;
public class Chip {
private String path = "ConnectFour/res/yellowChip.png";
private static int tileWidth, tileHeight = 100;
private String red = "ConnectFour/res/redChip.png";
private String yellow = "ConnectFour/res/yellowChip.png";
private Point position;
private boolean isRed;
private Image chip;
public Chip(String path, boolean isRed, int tileWidth, int tileHeight) {
public Chip(boolean isRed, int x, int y) {
this.isRed = isRed;
position = new Point();
position.setLocation(x, y);
try {
chip = ImageIO.read(new File(path)).getScaledInstance(tileWidth - 15, tileHeight - 15, Image.SCALE_DEFAULT);
if (isRed){
chip = ImageIO.read(new File(red)).getScaledInstance(tileWidth - 15, tileHeight - 15, Image.SCALE_DEFAULT);
} else {
chip = ImageIO.read(new File(yellow)).getScaledInstance(tileWidth - 15, tileHeight - 15, Image.SCALE_DEFAULT);
}
} catch (IOException e) {
e.printStackTrace();
}