teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

文字数制限で書き込めなかった play\.javaの中身を記入しました。

2016/01/10 05:44

投稿

Puhu
Puhu

スコア31

title CHANGED
File without changes
body CHANGED
@@ -78,25 +78,7 @@
78
78
  JPanel p_select = new JPanel();
79
79
  p_select.setLayout(null);
80
80
  p_select.setOpaque(false);
81
-
82
- ImageIcon oneshall1 = new ImageIcon("./music/onedari_shall_we/oneshall_out.png");
83
- ImageIcon oneshall2 = new ImageIcon("./music/onedari_shall_we/oneshall_over.png");
84
- JButton music1 = new JButton(oneshall1);
85
- music1.setBounds(100,100,410,116);
86
- music1.setRolloverIcon(oneshall2);
87
- music1.setPressedIcon(oneshall2);
88
- music1.addActionListener(this);
89
- music1.setActionCommand("./music/onedari_shall_we/おねだり_Shall_We.wav");
90
81
 
91
- ImageIcon donten1 = new ImageIcon("./music/donten/donten_out.png");
92
- ImageIcon donten2 = new ImageIcon("./music/donten/donten_over.png");
93
- JButton music2 = new JButton(donten1);
94
- music2.setBounds(100,300,410,116);
95
- music2.setRolloverIcon(donten2);
96
- music2.setPressedIcon(donten2);
97
- music2.addActionListener(this);
98
- music2.setActionCommand("./music/donten/donten.wav");
99
-
100
82
  ImageIcon concon1 = new ImageIcon("./music/concon/concon_out.png");
101
83
  ImageIcon concon2 = new ImageIcon("./music/concon/concon_over.png");
102
84
  JButton music3 = new JButton(concon1);
@@ -105,49 +87,195 @@
105
87
  music3.setPressedIcon(concon2);
106
88
  music3.addActionListener(this);
107
89
  music3.setActionCommand("./music/concon/concon");
108
-
109
- ImageIcon iris1 = new ImageIcon("./music/iris/iris_out.png");
90
+
110
- ImageIcon iris2 = new ImageIcon("./music/iris/iris_over.png");
111
- JButton music4 = new JButton(iris1);
112
- music4.setBounds(100,700,410,116);
113
- music4.setRolloverIcon(iris2);
114
- music4.setPressedIcon(iris2);
115
- music4.addActionListener(this);
116
- music4.setActionCommand("./music/iris/iris.wav");
117
-
118
-
119
- p_select.add(music1);
120
- p_select.add(music2);
121
91
  p_select.add(music3);
122
- p_select.add(music4);
123
92
 
124
93
 
125
94
  Container contentPane2 = frames.getContentPane();
126
95
  contentPane2.add(p_select, BorderLayout.CENTER);
127
96
 
128
97
  frames.setVisible(true);
129
- }else if (cmd.equals("./music/onedari_shall_we/おねだり_Shall_We.wav")){
98
+
130
- audio = Applet.newAudioClip(getClass().getResource(cmd));
131
- audio.play();
132
- audio.stop();
133
- }else if (cmd.equals("./music/donten/donten.wav")){
134
- audio = Applet.newAudioClip(getClass().getResource(cmd));
135
- audio.play();
136
- audio.stop();
137
99
  }else if (cmd.equals("./music/concon/concon")){
138
100
  frames.setVisible(false);
139
101
  startgame.game();//ここでplay.javaを呼び出す。
140
- }else if (cmd.equals("./music/iris/iris.wav")){
141
- audio = Applet.newAudioClip(getClass().getResource(cmd));
142
- audio.play();
143
102
 
103
+
144
104
  audio.stop();
145
105
  }
146
106
  }
147
107
 
148
108
 
149
109
  }
110
+ ```
111
+ ```java
112
+ import 省略
150
113
 
114
+ public class play {
151
115
 
116
+ public static void game(){
117
+ vimani action = new vimani();
118
+ action.viner();
119
+ }
120
+ }
152
121
 
122
+ class vimani extends JPanel implements KeyListener{
123
+
124
+ private JFrame frameC;
125
+ public lanePanel violin;
126
+ public static int[] sec = new int[1000];
127
+ public static int[][] fumen = new int[1000][2];
128
+ public static long gets = 0;
129
+ static int muchmicros = 0;
130
+ static int y1ic=0;static int y2ic=0;static int y3ic=0;static int y4ic=0;
131
+ static int[] y1 = new int[300];
132
+ static int[] y2 = new int[300];
133
+ static int[] y3 = new int[300];
134
+ static int[] y4 = new int[300];
135
+ static int speed = 7;
136
+ static String filen = "concon";
137
+ static int startcounter=0;
138
+ static Sounder sounder = new Sounder();
139
+ public void viner(){
140
+ window();//ウィンドウを生成
141
+ for(int i=0;i<300;i++){
142
+ y1[i] = 0;
143
+ y2[i] = 0;
144
+ y3[i] = 0;
145
+ y4[i] = 0;
146
+ }
147
+ read_fumen(filen);
148
+ runi();
149
+ }
150
+
151
+ public void window(){
152
+
153
+ frameC = new JFrame();
154
+ frameC.setTitle("Violinist");
155
+ frameC.setBounds(600,10,600,1000);//x=600,y=10,横600,縦1000のフレームを準備
156
+ frameC.setLayout(null);//レイアウトマネージャ使用しない
157
+ frameC.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//一緒に消す
158
+
159
+ violin = new lanePanel();
160
+ violin.setOpaque(false);
161
+ violin.setLayout(null);
162
+
163
+ violin.setSize(600,1000);
164
+ violin.setBackground(new Color(31,38,56,255));
165
+
166
+ Container contentPane3 = frameC.getContentPane();
167
+ contentPane3.add(violin, BorderLayout.CENTER);
168
+
169
+
170
+ //frame.add(violin);
171
+
172
+ frameC.setVisible(true);
173
+
174
+ frameC.addKeyListener(this);
175
+ violin.addKeyListener(this);
176
+
177
+ }
178
+
179
+ public void runi(){//指定msでrepaint()を行うメソッド
180
+ violin.repaint();//repaintを呼び出す。
181
+ }
182
+
183
+ public static void fumeneed(){
184
+ //譜面データを読む処理
185
+ }
186
+
187
+ public static void musicstart(String selectMusic){
188
+ //音楽再生処理
189
+ }
190
+
191
+ public static void read_fumen(String fileName){
192
+ //譜面ファイルをオープンする処理
193
+ }
194
+
195
+ private static boolean checkBeforeReadfile(File file){
196
+ //譜面ファイルを読むのに必要な処理
197
+ }
198
+
199
+ public void keyPressed(KeyEvent e){
200
+ }
201
+ public void keyReleased(KeyEvent e){
202
+ }
203
+ public void keyTyped(KeyEvent e){
204
+ char key = e.getKeyChar();
205
+ System.out.println(key);
206
+ searchHitNotes(key);//キー判定
207
+ }
208
+ public void searchHitNotes(char hitKey){
209
+ //キーの押したタイミングで点数をつける処理
210
+ }
211
+ }
212
+
213
+ class Sounder implements LineListener{
214
+ //音楽再生準備、再生中かどうかの判定等をするクラス
215
+ }
216
+ class lanePanel extends JPanel{//譜面描画メソッド
217
+
218
+ @Override
219
+ public void paintComponent(Graphics g) {
220
+ super.paintComponent(g);
221
+
222
+ // レーン
223
+ g.setColor(new Color(153,51,51,255));
224
+ g.fillRect(220,10, 30, 650);
225
+ g.fillRect(255,10, 30, 650);
226
+ g.fillRect(290,10, 30, 650);
227
+ g.fillRect(325,10, 30, 650);
228
+
229
+ g.setColor(new Color(255,255,255,255));
230
+ g.fillRect(250,10, 5, 650);
231
+ g.fillRect(285,10, 5, 650);
232
+ g.fillRect(320,10, 5, 650);
233
+
234
+ g.setColor(new Color(255,180,0,255));
235
+ g.fillRect(220,590,135,20);
236
+ //ノート
237
+ g.setColor(new Color(102,255,204,255));//ノーツの色
238
+ for(int i=vimani.one+1;i<vimani.y1ic;i++){
239
+ if(vimani.y1[i] <640){
240
+ g.fillRoundRect(220, vimani.y1[i], 30, 20, 5, 10);
241
+ vimani.y1[i]+=vimani.speed;
242
+ }else{
243
+ vimani.y1[i] = 990;
244
+ vimani.one = i;
245
+ }
246
+ }
247
+ for(int i=vimani.two+1;i<vimani.y2ic;i++){
248
+ if(vimani.y2[i] <640){
249
+ g.fillRoundRect(255, vimani.y2[i], 30, 20, 5, 10);
250
+ vimani.y2[i]+=vimani.speed;
251
+ }else{
252
+ vimani.y2[i] = 990;
253
+ vimani.two = i;
254
+ }
255
+ }
256
+ for(int i=vimani.three+1;i<vimani.y3ic;i++){
257
+ if(vimani.y3[i] <640){
258
+ g.fillRoundRect(290, vimani.y3[i], 30, 20, 5, 10);
259
+ vimani.y3[i]+=vimani.speed;
260
+ }else{
261
+ vimani.y3[i] = 990;
262
+ vimani.three = i;
263
+ }
264
+ }
265
+ for(int i=vimani.four+1;i<vimani.y4ic;i++){
266
+ if(vimani.y4[i] <640){
267
+ g.fillRoundRect(325, vimani.y4[i], 30, 20, 5, 10);
268
+ vimani.y4[i]+=vimani.speed;
269
+ }else{
270
+ vimani.y4[i] = 990;
271
+ vimani.four=i;
272
+ }
273
+ }
274
+
275
+ }
276
+
277
+ public void addObj(){
278
+ }
279
+ }
280
+
153
281
  ```