! from Yongwoo s Park ZIP,,,,,,,??!?, 1,
1 1, 1 (Snow Ball), /,, 5,,,, 3, 3, 5, 7,,,,,,!
,, ZIP, ZIP, images/logojpg : images/imageszip :, backgroundjpg, shadowgif, fallgif, ballgif, sf1gif, sf2gif, sf3gif, sf4gif, asf1gif, asf2gif, asf3gif, asf4gif, asf5gif, asf6gif, asf7gif, asf8gif,, ZIP!, getimage Image, ZIP Image?, SnowCraftjava, getimagesfromzip 1) ZIP URL URL url = new URL(getDocumentBase(), "images/imageszip"); 2) URL, ZIP, ZipInputStream ZipInputStream zipinputstream = new ZipInputStream(new DataInputStream(urlopenStream())); 3) ZipInputStream ZipEntry,, ZipInputStream while((zipentry = zipinputstreamgetnextentry())!= null) { String name = zipentrygetname(); int pos = 0; int bytesread=0; int size = (int)zipentrygetsize(); byte[] buffer = new byte[size]; for(;size>0;size-=bytesread) { bytesread = zipinputstreamread(buffer, pos, size); pos += bytesread; /* 4) */
4), Toolkit, ZipEntry (1) 3) while((zipentry = zipinputstreamgetnextentry())!= null) { String name = zipentrygetname(); /* 3) */ if("backgroundjpg"equals(name)) { bg = tkcreateimage(buffer); else if("shadowgif"equals(name)) { shadow = tkcreateimage(buffer); else if("fallgif"equals(name)) { burst = tkcreateimage(buffer); else if("ballgif"equals(name)) { ball = tkcreateimage(buffer); else { /* sf1gif ~ sf4gif, asf1gif ~ asf8gif */ 5), MediaTracker Image getimagesfromzip(); trackeraddimage(bg, 0); trackeraddimage(ball, 1); trackeraddimage(shadow, 1); trackeraddimage(burst, 1); for(int i=0;i<images1length;i++) { trackeraddimage(images1[i], 2); for(int i=0;i<images2length;i++) { trackeraddimage(images2[i], 2); try { trackerwaitforall(); catch(exception exception1) {, Toolkit createimage Image ZIP, AudioClip,,
,,,,,, ImageCanvas :, Canvas Jr 8 TimeBar :, Canvas Jr 8 LoadingBarWindow : ImageCanvas TimeBar, Dialog modal,, < 1> SnowCraftjava, init, loadimages, getimagesfromzip, loadsounds, getaudioclip < 1> public class SnowCraft extends Applet implements Runnable, MouseListener, MouseMotionListener { LoadingBarWindow loadingbarwindow=null; int loadingbarcount = 0; public void init() { logoimage = getimage(getdocumentbase(), "images/logojpg"); // LoadingBarWindow loadingbarwindow = new LoadingBarWindow((Frame)thisgetParent(), logoimage, "loading images"); loadingbarwindowshow(); // loadingbarwindowsetmessage("loading images") ; // loadingbarwindowsetstatuslevel(0 ); // 0
loadimages(); // loadingbarwindowsetmessage("loading sounds"); // loadingbarwindowsetstatuslevel(0 ); // 0 loadsounds(); // loadingbarwindowdispose(); // private void getimagesfromzip() { try { while((zipentry = zipinputstreamgetnextentry())!= null) { loadingbarcount++; int level = (int)(((double)loadingbarcount/160)*1000) ; // loadingbarwindowsetstatuslevel(level); // catch(exception anyexception) { anyexceptionprintstacktrace(); private void loadimages() { public AudioClip getaudioclip(url url, String name) { AudioClip clip = supergetaudioclip(url, name); clipplay(); // play int level = (int)(((double)(++loadingbarcount) /110) * 1000) ; // loadingbarwindowsetstatuslevel(level) ); // clipstop(); // return(clip); private void loadsounds() { loadingbarcount = 0; //
audioclip = getaudioclip(getcodebase(), "audio/audioclipau"); levelclip = getaudioclip(getcodebase(), "audio/levelclipau"); /* */ loadingbarwindowsetstatuslevel(100);,, 2,,!, update,,,,
,, Component, repaint,, repaint, Repaint() : update(graphics g) update(graphics g) : update, paint(graphics g) paint(graphics g) :, update, update public void update(graphics g) { paint(g);,,,,,,,,,, (double-buffering) 3,,,,
Image Image Buffer Buffer Screen Screen Draw Switch offgraphics g 3,, << 2> < 2> public class SnowCraft extends Applet implements Runnable, MouseListener, MouseMotionListener { int[] type = new int[] { CursorCROSSHAIR_CURSOR ; Cursor cursor=null; Image bufferimage=null; Graphics buffergraphics=null; Thread manmovethread, ballmovethread, computeractionthread; public void init() { // CROSSHAIR (+) cursor = CursorgetPredefinedCursor(type[0]); thissetcursor(cursor); /* */ // bufferimage = createimage(thissize()width, thissize()height); buffergraphics = bufferimagegetgraphics(); public void run() { Thread currentthread=null; while(true) {
if(status[who] == 1 && power < 50) { //, power++; currentthread = ThreadcurrentThread(); if(currentthread == displaythread) { try { Threadsleep(DISPLAY_DELAY); catch(interruptedexception e) { ; showstatus(etostring()); // repaint(); else if(currentthread == computeractionthread) { try { Threadsleep(DISPLAY_COMPUTING); catch(interruptedexception e) { ; showstatus(etostring()); //, computeraction(); // public void tranject(int dirx, int diry, int dirz, int ith) { /*,, */ public void atranject(int adirx, int adiry, int adirz, int aith) { /*,, */ public void commove(int i) { /*, */
public void comthrow(int i) { /* */ public void computeraction() { for(int i=0;i<ams;i++) { if(astatus[i]!= 6 && astatus[i]!= 7) { if(aicom[i] == 0) { aicom[i] =(int)(mathrandom()*5); switch(aicom[i]) { case 0 : break; case 1 : commove(i); break; case 2 : comthrow(i); break; case 3 : commove(i); break; case 4 : comthrow(i); break; else if(astatus[i] == 6) { if(agetup[i]++ == 10) { agetup[i] = 0; astatus[i] = 0; public void ballxyz() { /*, */ // public void showall(graphics g) { buffergraphicsdrawimage(bg, 0, 0, this); for(int j=0;j<ms;j++) { if(j!= who) { buffergraphicsdrawimage(images1[status[j]], xpos[j], ypos[j], this); tempx[j]=xpos[j]; tempy[j]=ypos[j]; buffergraphicsdrawimage(images1[status[who]], xpos[who], ypos[who], this); /* */
public void initgame(graphics g) { int i, cx=400, cy=30; buffergraphicsdrawimage(bg, 0, 0, this); first = false; for(int j=0;j<ms;j++) { xpos[j] = 300+(int)(Mathrandom()*230); ypos[j] = 160+(int)(Mathrandom()*110); buffergraphicsdrawimage(images1[status[j]], xpos[j], ypos[j], this); try { Threadsleep(1000); catch(interruptedexception e) { showstatus(etostring()); ; /* */ public void update(graphics g) { paint(g); public void paint(graphics g) { if(first == true) { initgame(g); // showall(g); // ballxyz(); gdrawimage(bufferimage, 0, 0, this); // 12
: AIFF, AU, WAV : MIDI TYPE 0, MIDI TYPE 1, RMF 8kHz 48khz (sample rate) 8 16 (mono) (stereo),, 8, AudioClip,,, << 3> < 3> public class SnowCraft extends Applet implements Runnable, MouseListener, MouseMotionListener { AudioClip audioclip, levelclip, strikeclip, astrikeclip, endclip, notcomeclip, shootclip; AudioClip deadclip, adeadclip, dropclip, ashootclip; public void init() { loadsounds(); public AudioClip getaudioclip(url url, String name) { AudioClip clip = supergetaudioclip(url, name); clipplay(); // play int level = (int)(((double)(++loadingbarcount) / (double)11) * (double)100); loadingbarwindowsetstatuslevel(level); clipstop(); // return(clip); private void loadsounds() { audioclip = getaudioclip(getcodebase(), "audio/audioclipau"); /* */
public void start() { // /, if(audioclip!= null) { audiocliploop(); public void stop() { //, if(audioclip!= null) audioclipstop(); /* */ public void tranject(int dirx, int diry, int dirz, int ith) { //, if(shootclip!= null) { shootclipplay(); // public void atranject(int adirx, int adiry, int adirz, int aith) { if(ashootclip!= null) { ashootclipplay(); // public void gameover() { if(endclip!= null) { endclipplay(); // stop(); //
, (stop) HTML,, stop,,,,,,,,,,,, MouseListener MouseListener, MouseAdapter MouseListener MouseAdapter, void mouseclicked(mouseevent e): void mouseentered(mouseevent e): void mouseexited(mouseevent e):
void mousepressed(mouseevent e): void mousereleased(mouseevent e):,, < 4> < 4> public class SnowCraft extends Applet implements Runnable, MouseListener, MouseMotionListener { public void init() { addmouselistener(this); addmousemotionlistener(this); public void mousepressed(mouseevent e) { int x = egetx(); int y = egety(); for(int i=0;i<ms;i++) { if(status[i]!= 3) { dx = x - xpos[i]; dy = y - ypos[i]; if(dx < width && dx >= 0 && dy < height && dy >= 0) { status[i] = 1; who = i; break; public void run() { while(true) { if(status[who] == 1 && power < 50) { power++;
public void mousereleased(mouseevent e) { if(status[who]!= 3 && dx<width && dx>=0 && dy<height && dy>=0) { vxaddelement(new Integer(xpos[who]+5)); vyaddelement(new Integer(ypos[who]+10)); vzaddelement(new Integer(power/2)); status[who] = 2; power = 0; public void mouseclicked(mouseevent e) { public void mouseentered(mouseevent e) { public void mouseexited(mouseevent e) {, (mousepressed), (MS=3), (x, y) (xpos [i], ypos[i]) 0 (width, height),, status[i] 1, (i ) who, (x,y) (xpos[i], ypos[i]) (dx, dy),, who status [who], (power),, status[who] 1 (poser),, (mousereleased), vx, vy, vz (x+5,y+10) (power/2), status[who] 2 (power) 0 vx, vy, vz, MouseMotionListener MouseMotionListener, MouseMotionAdapter MouseMotionListener MouseMotionAdapter,
void mousedragged(mouseevent e): void mousemoved(mouseevent e):,, < 5 < 5> public class SnowCraft extends Applet implements Runnable, MouseListener, MouseMotionListener { public void init() { addmouselistener(this); addmousemotionlistener(this); public void mousedragged(mouseevent e) { if(status[who]!= 3) { int x = egetx(); int y = egety(); if((x+y) <= 400) { // if(notcomeclip!= null) { notcomeclipplay(); if(((x+y) > 400) && dx<width && dx >= 0 && dy < height && dy >= 0 && x < 582 && y < 312) { xpos[who] = x - dx; ypos[who] = y - dy; status[who] = 1; public void mousemoved(mouseevent e) {
, (x,y), x y 400!,, (mousepressed), (dx,dy) dx = x xpos[i] dy = y ypos[i], xpos[i] = x dx ypos[i] = y - dy,,,, ZIP,,, loginasp,, ScoreBoardasp, HTML,,, ~