package bubble.test.ex05;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class Bubble extends JLabel {
private Player player; // 포함관계
private int x;
private int y;
// 움직임 상태
private boolean left;
private boolean right;
private boolean up;
// 적군을 맞춘 상태
private int state; // 0번은 (기본 물방울), 1번은 (적을 가둔 상태 물방울)
private ImageIcon bubble; // 기본 물방울
private ImageIcon bubbled; // 적을 가둔 물방울
private ImageIcon bomb; // 물방울 팡 !!
// 연관관계, 의존성 컴포지션 관계, 생성자 의존 (DI)
public Bubble(Player player) {
this.player = player;
initData();
setInitLayout();
initLayout();
}
private void initData() {
bubble = new ImageIcon("img/bubble.png");
bubbled = new ImageIcon("img/bubbled.png");
bomb = new ImageIcon("img/bomb.png");
left = false;
right = false;
up = false;
//state = false;
}
// GET, SET
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public boolean isLeft() {
return left;
}
public void setLeft(boolean left) {
this.left = left;
}
public boolean isRight() {
return right;
}
public void setRight(boolean right) {
this.right = right;
}
public boolean isUp() {
return up;
}
public void setUp(boolean up) {
this.up = up;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public ImageIcon getBubble() {
return bubble;
}
public void setBubble(ImageIcon bubble) {
this.bubble = bubble;
}
public ImageIcon getBubbled() {
return bubbled;
}
public void setBubbled(ImageIcon bubbled) {
this.bubbled = bubbled;
}
public ImageIcon getBumb() {
return bomb;
}
public void setBumb(ImageIcon bumb) {
this.bomb = bumb;
}
private void setInitLayout() {
// x, y, setIcon(bubble), setSize(50, ),setLocation(x, y);
x = player.getX();
y = player.getY();
setIcon(bubble);
setSize(50, 50);
setLocation(x, y);
}
private void initLayout() {}
}

결과

'Java' 카테고리의 다른 글
| 2024.05.03 Swing 프로젝트 bubble - 7 (버블 동작 처리) (0) | 2024.05.03 |
|---|---|
| 2024.05.03 Swing 프로젝트 bubble - 6 (바닥 층 감지 기능 추가) (0) | 2024.05.03 |
| 2024.05.03 자료구조(Data Structure) 배열을 활용한 Stack 구현해보기 (0) | 2024.05.03 |
| 2024.05.02 Swing 프로젝트 bubble - 4 (중복쓰레드 생성 방지) (0) | 2024.05.02 |
| 2024.05.02 Swing 프로젝트 bubble - 3 (이미지 올리기) (0) | 2024.05.02 |