質問編集履歴
2
質問の説明追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
プロセッシングでゲームを作成しています。
|
3
|
-
画面に表示する画像(スプライトシート)を3秒ごとに更新させたいのですが、上手く動かすことが出来ません。
|
3
|
+
エンターキーを押してから、画面に表示する画像(スプライトシート)を3秒ごとに更新させたいのですが、上手く動かすことが出来ません。
|
4
4
|
どうすれば動きますか?
|
5
5
|
試行錯誤中のコードなのでよくわからないことになってます…
|
6
6
|
|
1
文の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,20 +6,19 @@
|
|
6
6
|
|
7
7
|
##ソースコード
|
8
8
|
```processing-3.3.7
|
9
|
-
|
10
9
|
class Menu extends BaseCharacter
|
11
10
|
{
|
12
11
|
//メニュー選択のフラグ
|
13
12
|
public boolean kougeki_f;
|
14
13
|
public boolean nigeru_f;
|
15
|
-
|
14
|
+
|
16
15
|
//「逃げる」を選択した場合の判定
|
17
16
|
public int escape_f;
|
18
|
-
|
17
|
+
|
19
18
|
//Pointの変数
|
20
19
|
PImage point;
|
21
|
-
public int posX,posY;
|
20
|
+
public int posX, posY;
|
22
|
-
|
21
|
+
|
23
22
|
//
|
24
23
|
public int menu_state;
|
25
24
|
public int hyouji_time;
|
@@ -33,62 +32,62 @@
|
|
33
32
|
public static final int MENU_PLAYER_HP0 = 6;
|
34
33
|
public static final int MENU_NIGERU_Y = 7;
|
35
34
|
public static final int MENU_NIGERU_N = 8;
|
36
|
-
|
35
|
+
|
37
36
|
//
|
38
37
|
public Player_Battle player_b;
|
39
38
|
public Enemy_Battle enemy_b;
|
40
|
-
|
39
|
+
|
41
40
|
public Menu(MyGame parent)
|
42
41
|
{
|
43
|
-
super(parent,"MenuAll.png",1,9);
|
42
|
+
super(parent, "MenuAll.png", 1, 9);
|
44
|
-
|
45
43
|
}
|
46
44
|
void initialize()
|
47
45
|
{
|
48
46
|
kougeki_f = true;
|
49
47
|
nigeru_f = false;
|
50
|
-
|
48
|
+
|
51
49
|
//Menuの設定
|
52
50
|
this.menu_state = MENU_KOUGEKI;
|
53
51
|
changeAnimation(this.menu_state);
|
54
|
-
this.position.set(width/2,500);
|
52
|
+
this.position.set(width/2, 500);
|
55
53
|
//Pointの座標
|
56
54
|
this.posX = 200;
|
57
55
|
this.posY = 450;
|
58
|
-
|
56
|
+
|
59
57
|
//インスタンス化
|
60
58
|
this.player_b = new Player_Battle();
|
61
59
|
this.enemy_b = new Enemy_Battle();
|
62
|
-
|
60
|
+
|
63
61
|
frameRate(60);
|
64
62
|
}
|
65
|
-
|
63
|
+
|
66
64
|
void update(double deltaTime)
|
67
65
|
{
|
68
66
|
super.update(deltaTime);
|
69
67
|
this.draw();
|
70
|
-
|
71
68
|
}
|
72
69
|
void draw()
|
73
70
|
{
|
74
71
|
this.select();
|
75
72
|
/*
|
76
73
|
this.point = loadImage("MenuPoint.png");
|
77
|
-
|
74
|
+
imageMode(CENTER);
|
78
|
-
|
75
|
+
image(this.point, posX,posY,20,20);
|
79
|
-
|
76
|
+
*/
|
80
|
-
|
77
|
+
|
81
78
|
hyouji_time++;
|
82
|
-
if(hyouji_time
|
79
|
+
if (hyouji_time >= (60 * 3))
|
80
|
+
{
|
83
|
-
|
81
|
+
hyouji_f = true;
|
84
|
-
|
82
|
+
hyouji_time = 0;
|
83
|
+
}
|
85
84
|
}
|
86
85
|
|
87
86
|
public void select()
|
88
87
|
{
|
89
|
-
if(keyPressed)
|
88
|
+
if (keyPressed)
|
90
89
|
{
|
91
|
-
if(keyCode == LEFT)
|
90
|
+
if (keyCode == LEFT)
|
92
91
|
{
|
93
92
|
//println("攻撃");
|
94
93
|
this.menu_state = MENU_KOUGEKI;
|
@@ -96,27 +95,27 @@
|
|
96
95
|
|
97
96
|
kougeki_f = true;
|
98
97
|
nigeru_f = false;
|
99
|
-
}
|
98
|
+
}
|
100
|
-
else if(keyCode == RIGHT)
|
99
|
+
else if (keyCode == RIGHT)
|
101
100
|
{
|
102
101
|
//println("逃げる");
|
103
102
|
this.menu_state = MENU_NIGERU;
|
104
103
|
changeAnimation(this.menu_state);
|
105
|
-
|
104
|
+
|
106
105
|
kougeki_f = false;
|
107
106
|
nigeru_f = true;
|
108
107
|
}
|
109
|
-
|
108
|
+
|
110
|
-
if( key == ENTER)
|
109
|
+
if ( key == ENTER)
|
111
110
|
{
|
112
|
-
if(kougeki_f == true)
|
111
|
+
if (kougeki_f == true)
|
113
112
|
{
|
114
113
|
println("プレイヤーの攻撃");
|
115
114
|
attack();
|
116
115
|
attack_enemy();
|
117
116
|
kougeki_f = false;
|
118
|
-
}
|
117
|
+
}
|
119
|
-
else if(nigeru_f == true)
|
118
|
+
else if (nigeru_f == true)
|
120
119
|
{
|
121
120
|
println("逃げる");
|
122
121
|
escape(_parent.enemy);
|
@@ -132,90 +131,87 @@
|
|
132
131
|
BattleCharacter target = enemy_b;
|
133
132
|
player_b.attack(target);
|
134
133
|
//text(player_b._name + " が " + target.getName() + " を攻撃", 100,500);
|
135
|
-
if(enemy_b._hp > 0)
|
134
|
+
if (enemy_b._hp > 0)
|
136
135
|
{
|
137
136
|
this.menu_state = MENU_ENEMY_HP10;
|
138
137
|
changeAnimation(this.menu_state);
|
139
|
-
}
|
138
|
+
}
|
140
|
-
else if(enemy_b._hp <= 0)
|
139
|
+
else if (enemy_b._hp <= 0)
|
141
140
|
{
|
142
141
|
|
143
142
|
this.menu_state = MENU_ENEMY_HP0;
|
144
143
|
changeAnimation(this.menu_state);
|
145
|
-
|
146
|
-
|
144
|
+
|
145
|
+
|
147
146
|
this.menu_state = MENU_ENEMY_HP0_MS;
|
148
147
|
changeAnimation(this.menu_state);
|
149
|
-
|
148
|
+
|
150
|
-
_parent.enemy.position.set(0,5000);
|
149
|
+
_parent.enemy.position.set(0, 5000);
|
151
150
|
switch(_parent.map_c)
|
152
151
|
{
|
153
|
-
|
152
|
+
case 1:
|
154
153
|
_parent.state = _parent.STATE_MGAME1;
|
155
154
|
break;
|
156
|
-
|
155
|
+
case 2:
|
157
156
|
_parent.state = _parent.STATE_MGAME2;
|
158
157
|
break;
|
159
158
|
}
|
160
159
|
}
|
161
160
|
}
|
162
|
-
|
161
|
+
|
163
162
|
public void escape(Enemy enemy)
|
164
163
|
{
|
165
164
|
enemy.invincible = true;
|
166
|
-
escape_f = (int)random(0,10);
|
165
|
+
escape_f = (int)random(0, 10);
|
167
|
-
if(escape_f % 2 == 0)
|
166
|
+
if (escape_f % 2 == 0)
|
168
167
|
{
|
169
168
|
switch(_parent.map_c)//成功
|
170
169
|
{
|
171
|
-
|
170
|
+
case 1:
|
172
|
-
|
171
|
+
_parent.state = _parent.STATE_MGAME1;
|
173
|
-
|
172
|
+
break;
|
174
|
-
|
173
|
+
case 2:
|
175
|
-
|
174
|
+
_parent.state = _parent.STATE_MGAME2;
|
176
|
-
|
175
|
+
break;
|
177
|
-
|
176
|
+
}
|
178
|
-
}
|
177
|
+
}
|
179
|
-
else if( escape_f % 2 == 1)//失敗
|
178
|
+
else if ( escape_f % 2 == 1)//失敗
|
180
179
|
{
|
181
180
|
attack_enemy();
|
182
|
-
if(player_b._hp == 0) _parent.state = _parent.STATE_OVER;
|
181
|
+
if (player_b._hp == 0) _parent.state = _parent.STATE_OVER;
|
183
182
|
}
|
184
183
|
}
|
185
|
-
|
184
|
+
|
186
185
|
public void attack_enemy()
|
187
186
|
{
|
187
|
+
println(hyouji_f);
|
188
|
+
println(hyouji_time);
|
188
|
-
|
189
|
+
if (hyouji_f == true)
|
189
|
-
|
190
|
+
{
|
190
|
-
|
191
|
+
println("pp");
|
191
|
-
hyouji_f = true;
|
192
|
-
if(hyouji_f == true)
|
193
|
-
{
|
194
|
-
|
192
|
+
BattleCharacter target = player_b;
|
195
|
-
|
193
|
+
enemy_b.attack(target);
|
196
|
-
|
197
|
-
|
194
|
+
|
195
|
+
|
198
|
-
if(player_b._hp > 0)
|
196
|
+
if (player_b._hp > 0)
|
199
197
|
{
|
200
|
-
|
198
|
+
|
201
|
-
|
199
|
+
this.menu_state = MENU_PLAYER_HP10;
|
202
|
-
|
200
|
+
changeAnimation(this.menu_state);
|
203
|
-
|
201
|
+
hyouji_time = 0;
|
204
|
-
}
|
202
|
+
}
|
205
203
|
else
|
206
204
|
{
|
207
|
-
|
205
|
+
this.menu_state = MENU_PLAYER_HP10;
|
208
|
-
|
206
|
+
changeAnimation(this.menu_state);
|
209
|
-
|
207
|
+
|
210
|
-
|
208
|
+
_parent.state = _parent.STATE_OVER;
|
211
209
|
}
|
212
|
-
|
210
|
+
hyouji_f = false;
|
213
|
-
|
211
|
+
}
|
214
|
-
}
|
215
|
-
//敵の攻撃
|
216
|
-
|
217
212
|
}
|
218
213
|
}
|
214
|
+
|
219
215
|
```
|
220
216
|
|
221
217
|
|