@@ -29,9 +29,9 @@ public class MyApplet extends JApplet implements KeyListener, ActionListener {
29
29
private Title title ;
30
30
private Image player ;
31
31
private Timer timer ;
32
- private ImageIcon apple_icon = new ImageIcon ( "image/apple_logo.png" ) ;
33
- private ImageIcon linux_icon = new ImageIcon ( "image/linux_logo.png" ) ;
34
- private ImageIcon windows_icon = new ImageIcon ( "image/windows_logo.png" ) ;
32
+ private ImageIcon apple_icon ;
33
+ private ImageIcon linux_icon ;
34
+ private ImageIcon windows_icon ;
35
35
private int px , py ;
36
36
private int [] ex ;
37
37
private int [] ey ;
@@ -55,15 +55,46 @@ public class MyApplet extends JApplet implements KeyListener, ActionListener {
55
55
private Image apple_logo ;
56
56
private Image linux_logo ;
57
57
private Image windows_logo ;
58
- private URL urlplayerimage ;
59
- private URL urlenemyimage ;
60
- private URL urlexplosionimage ;
61
- private URL urltitleimage ;
62
- private URL urlapple_logo ;
63
- private URL urllinux_logo ;
64
- private URL urlwindows_logo ;
58
+ private MediaTracker tracker ;
65
59
66
60
public void init () {
61
+ this .tracker = new MediaTracker (this );
62
+ this .title = new Title ();
63
+ URL urlplayerimage = MyApplet .class .getResource ("image/linux_logo.png" );
64
+ URL urlenemyimage = MyApplet .class .getResource ("image/windows_logo.png" );
65
+ URL urlexplosionimage = MyApplet .class .getResource ("image/explosion.png" );
66
+ URL urltitleimage = MyApplet .class .getResource ("image/title/OSBustersTitleImage3.png" );
67
+ URL urlapple_logo = MyApplet .class .getResource ("image/apple_logo.png" );
68
+ URL urllinux_logo = MyApplet .class .getResource ("image/linux_logo.png" );
69
+ URL urlwindows_logo = MyApplet .class .getResource ("image/windows_logo.png" );
70
+
71
+ this .playerimage = super .getImage (urlplayerimage );
72
+ System .out .println (playerimage );
73
+ this .enemyimage = super .getImage (urlenemyimage );
74
+ this .explosionimage = super .getImage (urlexplosionimage );
75
+ this .titleimage = super .getImage (urltitleimage );
76
+ this .apple_logo = super .getImage (urlapple_logo );
77
+ this .linux_logo = super .getImage (urllinux_logo );
78
+ this .windows_logo = super .getImage (urlwindows_logo );
79
+
80
+ this .tracker .addImage (playerimage , 0 );
81
+ this .tracker .addImage (enemyimage , 0 );
82
+ this .tracker .addImage (explosionimage , 0 );
83
+ this .tracker .addImage (titleimage , 0 );
84
+ this .tracker .addImage (apple_logo , 0 );
85
+ this .tracker .addImage (linux_logo , 0 );
86
+ this .tracker .addImage (windows_logo , 0 );
87
+
88
+ try {
89
+ this .tracker .waitForAll ();
90
+ System .out .println ("MediaTracker is ok" );
91
+ } catch (InterruptedException e ){}
92
+
93
+ this .apple_icon = new ImageIcon (apple_logo );
94
+ this .linux_icon = new ImageIcon (linux_logo );
95
+ this .windows_icon = new ImageIcon (windows_logo );
96
+ this .title .setTitleImage (titleimage );
97
+
67
98
this .selplayerbutton0 = new JButton (apple_icon );
68
99
this .selplayerbutton1 = new JButton (linux_icon );
69
100
this .selplayerbutton2 = new JButton (windows_icon );
@@ -80,6 +111,7 @@ public void init() {
80
111
this .selmenuplayerlabel .setFont (new Font ("MS ゴシック" , Font .BOLD , 40 ));
81
112
this .selmenuenemylabel = new JLabel ("Select Enemy" );
82
113
this .selmenuenemylabel .setFont (new Font ("MS ゴシック" , Font .BOLD , 40 ));
114
+
83
115
px = 640 ;
84
116
py = 600 ;
85
117
point = 0 ;
@@ -94,22 +126,6 @@ public void init() {
94
126
timer = new Timer (40 , this );
95
127
this .timer .stop ();
96
128
97
- urlplayerimage = MyApplet .class .getResource ("image/linux_logo.png" );
98
- urlenemyimage = MyApplet .class .getResource ("image/windows_logo.png" );
99
- urlexplosionimage = MyApplet .class .getResource ("image/explosion.png" );
100
- urltitleimage = MyApplet .class .getResource ("image/title/OSBustersTitleImage3.png" );
101
- urlapple_logo = MyApplet .class .getResource ("image/apple_logo.png" );
102
- urllinux_logo = MyApplet .class .getResource ("image/linux_logo.png" );
103
- urlwindows_logo = MyApplet .class .getResource ("image/windows_logo.png" );
104
-
105
- this .playerimage = super .getImage (urlplayerimage );
106
- this .enemyimage = super .getImage (urlenemyimage );
107
- this .explosionimage = super .getImage (urlexplosionimage );
108
- this .titleimage = super .getImage (urltitleimage );
109
- this .apple_logo = super .getImage (urlapple_logo );
110
- this .linux_logo = super .getImage (urllinux_logo );
111
- this .windows_logo = super .getImage (urlwindows_logo );
112
-
113
129
this .mm = new MyModel ();
114
130
this .mp = new MyPanel (px , py );
115
131
this .pb = new PlayerBullet [NUM_BULLET ];
@@ -125,7 +141,6 @@ public void init() {
125
141
enemy [i ].setEnemyImage (enemyimage );
126
142
enemy [i ].setExplosionImage (explosionimage );
127
143
}
128
- this .title = new Title ();
129
144
130
145
//set_image
131
146
mp .setPlayerImage (playerimage );
@@ -136,7 +151,6 @@ public void init() {
136
151
mp .setNUM_BULLET (NUM_BULLET );
137
152
mp .setNUM_ENEMY (NUM_ENEMY );
138
153
mp .setMyModel (this .mm );
139
- title .setMyModel (this .mm );
140
154
141
155
mp .addKeyListener (this );
142
156
0 commit comments