-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcont.java
81 lines (71 loc) · 1.68 KB
/
cont.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
/* Controller : ゲーム画面に対してのコントローラー */
class GameCont implements ActionListener, KeyListener {
public Game frame;
// コンストラクタ
public GameCont(Game g) {
frame = g;
frame.addKeyListener(this);
}
// キーリスナーを取り外す
public void remove() {
frame.removeKeyListener(this);
}
// ボタンの定義
public void actionPerformed(ActionEvent e) {
}
// キーの定義
public void keyPressed(KeyEvent e) {
int k = e.getKeyCode();
if (frame.getPanelmode() == 1) {
switch (k) {
case KeyEvent.VK_W:
frame.chara.moveChar(-1, 0, 0); // row, col
if (!frame.isGoal()) {
frame.chara.isEnemy();
}
break;
case KeyEvent.VK_A:
frame.chara.moveChar(0, -1, 3);
if (!frame.isGoal()) {
frame.chara.isEnemy();
}
break;
case KeyEvent.VK_D:
frame.chara.moveChar(0, 1, 1);
if (!frame.isGoal()) {
frame.chara.isEnemy();
}
break;
case KeyEvent.VK_S:
frame.chara.moveChar(1, 0, 2);
if (!frame.isGoal()) {
frame.chara.isEnemy();
}
break;
case KeyEvent.VK_R:
frame.pushReset();
break;
case KeyEvent.VK_L:
frame.chara.useSword(frame.enemy);
break;
case KeyEvent.VK_K:
frame.chara.useHammer();
break;
case KeyEvent.VK_J:
frame.chara.useStar(frame.enemy);
break;
case KeyEvent.VK_I:
frame.chara.useBook();
break;
}
}
}
public void keyTyped(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
}